mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-25 06:35:21 +00:00
KpiTile and StatGroup carry the totals, BarChart draws download activity, ActivityFeed lists live events and DataTable lists recent packages and registries. Loading, empty and error states use the library states. Severity badges are StatusBadge with the tones critical danger, high warning, moderate info and low neutral, and always print the word.
84 lines
2.5 KiB
Vue
84 lines
2.5 KiB
Vue
<template>
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
<StatusBadge
|
|
v-if="isBlocked"
|
|
status="blocked"
|
|
label="Blocked"
|
|
variant="solid"
|
|
title="Download blocked: exceeds vulnerability thresholds"
|
|
/>
|
|
|
|
<button
|
|
v-for="level in presentLevels"
|
|
:key="level"
|
|
type="button"
|
|
:class="buttonVariants({ variant: 'ghost', size: 'xs' })"
|
|
:aria-label="`${counts[level]} ${level} ${counts[level] === 1 ? 'vulnerability' : 'vulnerabilities'}, view details`"
|
|
@click="handleClick(level)"
|
|
>
|
|
<StatusBadge :status="level" :tones="SEVERITY_TONES" :label="`${formatSeverityName(level)}: ${counts[level]}`" />
|
|
</button>
|
|
|
|
<template v-if="status === 'clean' && total === 0">
|
|
<StatusBadge
|
|
status="clean"
|
|
label="Clean"
|
|
:tones="{ clean: 'success' }"
|
|
:title="scannedAt ? `No vulnerabilities found. Scanned ${formatDate(scannedAt)}` : 'No vulnerabilities found'"
|
|
/>
|
|
<RelativeTime v-if="scannedAt" :datetime="scannedAt" variant="muted" size="xs" />
|
|
</template>
|
|
|
|
<StatusBadge
|
|
v-if="status === 'pending'"
|
|
status="pending"
|
|
label="Scanning"
|
|
pulse
|
|
title="Security scan in progress"
|
|
/>
|
|
|
|
<StatusBadge
|
|
v-if="status === 'not_scanned' || !scanned"
|
|
status="not_scanned"
|
|
label="Not scanned"
|
|
:tones="{ not_scanned: 'neutral' }"
|
|
title="Not yet scanned for vulnerabilities"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
import { RelativeTime, StatusBadge, buttonVariants } from '@perfect-design/ui'
|
|
import type { VulnerabilityCounts } from '../stores/packages'
|
|
import { formatDate } from '@/lib/format'
|
|
import { NO_VULNERABILITIES, SEVERITY_LEVELS, SEVERITY_TONES, formatSeverityName } from '@/lib/severity'
|
|
|
|
interface Props {
|
|
scanned?: boolean
|
|
status?: 'clean' | 'vulnerable' | 'pending' | 'not_scanned'
|
|
counts?: VulnerabilityCounts
|
|
total?: number
|
|
scannedAt?: string // ISO 8601 timestamp
|
|
isBlocked?: boolean // Whether download is blocked due to vulnerabilities
|
|
}
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
scanned: false,
|
|
status: 'not_scanned',
|
|
total: 0,
|
|
isBlocked: false,
|
|
})
|
|
|
|
const emit = defineEmits<{
|
|
click: [severity: string]
|
|
}>()
|
|
|
|
const counts = computed(() => props.counts || NO_VULNERABILITIES)
|
|
const presentLevels = computed(() => SEVERITY_LEVELS.filter((level) => counts.value[level] > 0))
|
|
|
|
function handleClick(severity: string) {
|
|
emit('click', severity)
|
|
}
|
|
</script>
|