diff --git a/frontend/app/components/modules/collection/components/details/collection-health-score-pill.vue b/frontend/app/components/modules/collection/components/details/collection-health-score-pill.vue index b5f16d276..d06e113eb 100644 --- a/frontend/app/components/modules/collection/components/details/collection-health-score-pill.vue +++ b/frontend/app/components/modules/collection/components/details/collection-health-score-pill.vue @@ -31,6 +31,7 @@ import LfxChip from '~/components/uikit/chip/chip.vue'; const props = defineProps<{ score: number; + healthLabel?: string | null; unavailable?: boolean; }>(); @@ -39,19 +40,32 @@ const props = defineProps<{ // labeled metrics chip). Duplicated rather than shared: only two call sites (row/card) and the // logic is ~10 lines, so a composable would be more ceremony than the duplication it avoids. // health-score.vue itself is intentionally left untouched (used elsewhere in the app). +// +// Prefers the API's real healthLabel (v2) when present; falls back to deriving the label from +// the score for sparse rows where the pipe didn't return a label. const healthScoreLabel = computed(() => { + if (props.healthLabel) { + return props.healthLabel.charAt(0).toUpperCase() + props.healthLabel.slice(1); + } const score = props.score; - if (score >= 80) return 'Excellent'; - if (score >= 60) return 'Healthy'; - if (score >= 40) return 'Fair'; - if (score >= 20) return 'Concerning'; + if (score >= 85) return 'Excellent'; + if (score >= 70) return 'Healthy'; + if (score >= 50) return 'Fair'; + if (score >= 30) return 'Concerning'; return 'Critical'; }); const healthScoreDotClass = computed(() => { + if (props.healthLabel) { + if (props.healthLabel === 'excellent' || props.healthLabel === 'healthy') return 'bg-health-healthy'; + if (props.healthLabel === 'fair') return 'bg-health-fair'; + if (props.healthLabel === 'concerning') return 'bg-health-concerning'; + return 'bg-health-critical'; + } const score = props.score; - if (score >= 60) return 'bg-health-healthy'; - if (score >= 20) return 'bg-health-concerning'; + if (score >= 70) return 'bg-health-healthy'; + if (score >= 50) return 'bg-health-fair'; + if (score >= 30) return 'bg-health-concerning'; return 'bg-health-critical'; }); diff --git a/frontend/app/components/modules/collection/components/details/collection-metrics-row.vue b/frontend/app/components/modules/collection/components/details/collection-metrics-row.vue index ed022e8e0..eede8b35a 100644 --- a/frontend/app/components/modules/collection/components/details/collection-metrics-row.vue +++ b/frontend/app/components/modules/collection/components/details/collection-metrics-row.vue @@ -103,17 +103,18 @@ const avgHealthScore = computed(() => props.metrics?.avgHealthScore); // intentionally left untouched. Colors use the shared health-* tokens from colors.ts. const healthScoreLabel = computed(() => { const score = avgHealthScore.value ?? 0; - if (score >= 80) return 'Excellent'; - if (score >= 60) return 'Healthy'; - if (score >= 40) return 'Fair'; - if (score >= 20) return 'Concerning'; + if (score >= 85) return 'Excellent'; + if (score >= 70) return 'Healthy'; + if (score >= 50) return 'Fair'; + if (score >= 30) return 'Concerning'; return 'Critical'; }); const healthScoreDotClass = computed(() => { const score = avgHealthScore.value ?? 0; - if (score >= 60) return 'bg-health-healthy'; - if (score >= 20) return 'bg-health-concerning'; + if (score >= 70) return 'bg-health-healthy'; + if (score >= 50) return 'bg-health-fair'; + if (score >= 30) return 'bg-health-concerning'; return 'bg-health-critical'; }); diff --git a/frontend/app/components/modules/collection/components/details/collection-project-item.vue b/frontend/app/components/modules/collection/components/details/collection-project-item.vue index 0e0af44db..ed5cfe3e2 100644 --- a/frontend/app/components/modules/collection/components/details/collection-project-item.vue +++ b/frontend/app/components/modules/collection/components/details/collection-project-item.vue @@ -68,17 +68,11 @@ SPDX-License-Identifier: MIT :unavailable="true" :score="0" /> - - - - + :score="project.healthScoreV2 ?? 0" + :health-label="project.healthLabel" + /> {{ formatNumber(props.project.contributorCount) }} @@ -161,7 +155,8 @@ SPDX-License-Identifier: MIT