Skip to content

Commit 5c2261f

Browse files
authored
fix: make 'show more' button clickable in vulnerability banner (#389)
1 parent f94b7de commit 5c2261f

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

app/components/PackageVulnerabilityTree.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ onMounted(() => fetchVulnTree())
2020
2121
const isExpanded = shallowRef(false)
2222
const showAllPackages = shallowRef(false)
23+
const showAllVulnerabilities = shallowRef(false)
2324
2425
const hasVulnerabilities = computed(
2526
() => vulnTree.value && vulnTree.value.vulnerablePackages.length > 0,
@@ -142,7 +143,7 @@ function getDepthStyle(depth: string | undefined) {
142143
<!-- Show first 2 vulnerabilities -->
143144
<ul class="space-y-1 list-none m-0 p-0">
144145
<li
145-
v-for="vuln in pkg.vulnerabilities.slice(0, 2)"
146+
v-for="vuln in pkg.vulnerabilities.slice(0, showAllVulnerabilities ? undefined : 2)"
146147
:key="vuln.id"
147148
class="flex items-center gap-2 text-xs text-fg-muted"
148149
>
@@ -156,8 +157,15 @@ function getDepthStyle(depth: string | undefined) {
156157
</a>
157158
<span class="truncate w-0 flex-1">{{ vuln.summary }}</span>
158159
</li>
159-
<li v-if="pkg.vulnerabilities.length > 2" class="text-xs text-fg-subtle">
160-
{{ $t('package.vulnerabilities.more', { count: pkg.vulnerabilities.length - 2 }) }}
160+
<li
161+
v-if="pkg.vulnerabilities.length > 2 && !showAllVulnerabilities"
162+
class="text-xs text-fg-subtle"
163+
>
164+
<button type="button" @click="showAllVulnerabilities = true">
165+
{{
166+
$t('package.vulnerabilities.more', { count: pkg.vulnerabilities.length - 2 })
167+
}}
168+
</button>
161169
</li>
162170
</ul>
163171
</li>

shared/utils/severity.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
// @unocss-include
2+
13
import type { OsvSeverityLevel } from '../types'
24
import { SEVERITY_LEVELS } from '../types'
35

46
/**
57
* Color classes for severity levels (banner style)
68
*/
79
export const SEVERITY_COLORS: Record<OsvSeverityLevel, string> = {
8-
critical: 'text-red-300 bg-red-500/15 border-red-500/40',
10+
critical: 'text-red-500 bg-red-500/10 border-red-500/50',
911
high: 'text-red-400 bg-red-500/10 border-red-500/30',
1012
moderate: 'text-orange-400 bg-orange-500/10 border-orange-500/30',
1113
low: 'text-yellow-400 bg-yellow-500/10 border-yellow-500/30',

0 commit comments

Comments
 (0)