Skip to content

Commit 1fa8814

Browse files
authored
feat: disabled score metric tab and added tooltip if unavailable (#1587)
Signed-off-by: Efren Lim <elim@linuxfoundation.org>
1 parent 9e0197d commit 1fa8814

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

frontend/app/components/modules/project/components/overview/score-details/score-tab-view.vue

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,48 @@ SPDX-License-Identifier: MIT
66
<lfx-tabs-panels>
77
<lfx-tabs
88
v-model="selectedTab"
9-
:tabs="tabs"
9+
:tabs="tabsOptions"
1010
>
1111
<template #slotItem="{ option }">
12-
<div class="flex flex-col gap-2 items-start">
13-
<div class="text-neutral-900 font-secondary text-sm tab-label">
12+
<lfx-tooltip
13+
v-if="!scoreDisplay[option.value as keyof typeof scoreDisplay]"
14+
class="!w-full"
15+
>
16+
<template #content>
17+
<p class="max-w-60">
18+
{{ option.label }} metrics are unavailable because the required data isn't available for this project.
19+
<a
20+
:href="links.securityScore"
21+
target="_blank"
22+
class="text-brand-500"
23+
>Learn more</a
24+
>
25+
</p>
26+
</template>
27+
<div class="flex flex-col gap-2 items-start cursor-not-allowed">
28+
<div class="text-sm tab-label text-neutral-400">
29+
{{ option.label }}
30+
</div>
31+
<div class="text-sm text-gray-500 w-full">
32+
<lfx-skeleton-state
33+
:status="status"
34+
height=".188rem"
35+
width="100%"
36+
>
37+
<lfx-progress-bar
38+
size="small"
39+
:values="[getValues(option.value)]"
40+
:color="getColor(getValues(option.value))"
41+
/>
42+
</lfx-skeleton-state>
43+
</div>
44+
</div>
45+
</lfx-tooltip>
46+
<div
47+
v-else
48+
class="flex flex-col gap-2 items-start"
49+
>
50+
<div class="text-sm tab-label text-neutral-900">
1451
{{ option.label }}
1552
</div>
1653
<div class="text-sm text-gray-500 w-full">
@@ -79,6 +116,8 @@ import type { ScoreDisplay } from '~~/types/overview/score-display.types';
79116
import LfxProjectLoadState from '~~/app/components/modules/project/components/shared/load-state.vue';
80117
import LfxSkeletonState from '~/components/modules/project/components/shared/skeleton-state.vue';
81118
import type { WidgetArea } from '~/components/modules/widget/types/widget-area';
119+
import { links } from '~/config/links';
120+
import LfxTooltip from '~/components/uikit/tooltip/tooltip.vue';
82121
83122
const props = defineProps<{
84123
trustScoreSummary: TrustScoreSummary | undefined;
@@ -97,6 +136,13 @@ const selectedTab = computed({
97136
set: (value: string) => emit('update:modelValue', value),
98137
});
99138
139+
const tabsOptions = computed(() => {
140+
return props.tabs.map((tab) => ({
141+
...tab,
142+
disabled: !props.scoreDisplay[tab.value as keyof typeof props.scoreDisplay],
143+
}));
144+
});
145+
100146
const getColor = (value: number) => {
101147
switch (true) {
102148
case value > 75:

frontend/app/components/uikit/tabs/tabs.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SPDX-License-Identifier: MIT
1111
option-value="value"
1212
:allow-empty="false"
1313
:class="`tabs-width-${props.widthType}`"
14+
option-disabled="disabled"
1415
>
1516
<template #option="slotProps">
1617
<slot

frontend/app/components/uikit/tabs/types/tab.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface Tab {
44
value: string;
55
label: string;
66
icon?: string;
7+
disabled?: boolean;
78
}
89

910
export interface TabsProps {

0 commit comments

Comments
 (0)