|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import type { PackageVulnerabilities } from '#shared/types' |
| 3 | +import { SEVERITY_LEVELS } from '#shared/types' |
3 | 4 | import { SEVERITY_COLORS, SEVERITY_BADGE_COLORS, getHighestSeverity } from '#shared/utils/severity' |
4 | 5 |
|
5 | 6 | const props = defineProps<{ |
@@ -42,18 +43,11 @@ const hasVulnerabilities = computed(() => vulnData.value.counts.total > 0) |
42 | 43 | const isExpanded = shallowRef(false) |
43 | 44 | const highestSeverity = computed(() => getHighestSeverity(vulnData.value.counts)) |
44 | 45 |
|
45 | | -const { $t } = useNuxtApp() |
46 | | -
|
47 | 46 | const summaryText = computed(() => { |
48 | | - const counts = vulnData.value.counts |
49 | | - const parts: string[] = [] |
50 | | - if (counts.critical > 0) |
51 | | - parts.push(`${counts.critical} ${$t('package.vulnerabilities.severity.critical')}`) |
52 | | - if (counts.high > 0) parts.push(`${counts.high} ${$t('package.vulnerabilities.severity.high')}`) |
53 | | - if (counts.moderate > 0) |
54 | | - parts.push(`${counts.moderate} ${$t('package.vulnerabilities.severity.moderate')}`) |
55 | | - if (counts.low > 0) parts.push(`${counts.low} ${$t('package.vulnerabilities.severity.low')}`) |
56 | | - return parts.join(', ') |
| 47 | + const { counts } = vulnData.value |
| 48 | + return SEVERITY_LEVELS.filter(s => counts[s] > 0) |
| 49 | + .map(s => `${counts[s]} ${$t(`package.vulnerabilities.severity.${s}`)}`) |
| 50 | + .join(', ') |
57 | 51 | }) |
58 | 52 | </script> |
59 | 53 |
|
@@ -122,7 +116,7 @@ const summaryText = computed(() => { |
122 | 116 | class="px-2 py-0.5 text-xs font-mono rounded" |
123 | 117 | :class="SEVERITY_BADGE_COLORS[vuln.severity]" |
124 | 118 | > |
125 | | - {{ vuln.severity }} |
| 119 | + {{ $t(`package.vulnerabilities.severity.${vuln.severity}`) }} |
126 | 120 | </span> |
127 | 121 | </div> |
128 | 122 | <p class="text-sm text-fg-muted line-clamp-2 m-0"> |
|
0 commit comments