@@ -3,44 +3,56 @@ Copyright (c) 2025 The Linux Foundation and each contributor.
33SPDX-License-Identifier: MIT
44-->
55<template >
6- <div class =" flex flex-row gap-4" >
7- <div >
8- <div
9- :class =" iconBGColor"
10- class =" rounded-full h-6 w-6 flex items-center justify-center"
11- >
12- <lfx-benchmark-icon
13- :type =" pointDetails?.type || 'positive'"
14- use-triangle
15- :size =" 12"
16- />
6+ <nuxt-link :to =" linkUrl" >
7+ <div class =" flex flex-row gap-4" >
8+ <div >
9+ <div
10+ :class =" iconBGColor"
11+ class =" rounded-full h-6 w-6 flex items-center justify-center"
12+ >
13+ <lfx-benchmark-icon
14+ :type =" pointDetails?.type || 'positive'"
15+ use-triangle
16+ :size =" 12"
17+ />
18+ </div >
1719 </div >
18- </ div >
19- <div class =" flex flex-col gap-2 " >
20- < div class = " text-sm font-semibold text-neutral-900 " >
21- {{ title }}
22- </ div >
23- < div class = " text-xs text-neutral-500 " >
24- {{ description }}
20+ < div class = " flex flex-col gap-2 " >
21+ <div class =" text-sm font-semibold text-neutral-900 " >
22+ {{ title }}
23+ </ div >
24+ < div class = " text-xs text-neutral-500 " >
25+ {{ description }}
26+ </ div >
2527 </div >
28+ <!-- need to add this because tailwind won't import them in the computed property -->
29+ <span class =" bg-negative-100 bg-positive-100 bg-warning-100" />
2630 </div >
27- <!-- need to add this because tailwind won't import them in the computed property -->
28- <span class =" bg-negative-100 bg-positive-100 bg-warning-100" />
29- </div >
31+ </nuxt-link >
3032</template >
3133
3234<script setup lang="ts">
3335import { computed } from ' vue' ;
36+ import { useRoute } from ' nuxt/app' ;
37+ import { storeToRefs } from ' pinia' ;
3438import LfxBenchmarkIcon from ' ~/components/uikit/benchmarks/benchmark-icon.vue' ;
3539import { formatNumber } from ' ~/components/shared/utils/formatter' ;
3640import { lfxWidgets } from ' ~/components/modules/widget/config/widget.config' ;
41+ import { lfxWidgetArea } from ' ~/components/modules/widget/config/widget-area.config' ;
42+ import { Widget } from ' ~/components/modules/widget/types/widget' ;
43+ import { lfProjectLinks } from ' ~/components/modules/project/config/links' ;
44+ import { useProjectStore } from ' ~/components/modules/project/store/project.store' ;
3745
3846const props = defineProps <{
3947 widgetKey: string ;
4048 value: number ;
4149 benchmark: number ;
4250}>();
4351
52+ const route = useRoute ();
53+ const repoName = computed (() => route .params .name as string );
54+ const { selectedRepositoryGroup } = storeToRefs (useProjectStore ());
55+
4456const widget = computed (() => Object .values (lfxWidgets ).find (w => w .key === props .widgetKey ));
4557const title = computed (() => widget .value ?.benchmark ?.title );
4658const benchmarkValue = computed (() => Math .ceil (props .value || 0 ));
@@ -49,6 +61,42 @@ const description = computed(() => `
4961 ${pointDetails .value ?.description .replace (' {value}' , formatNumber (benchmarkValue .value || 0 ).toString ())}
5062 - ${pointDetails .value ?.text } ` );
5163const iconBGColor = computed (() => ` bg-${pointDetails .value ?.type }-100 ` );
64+ const widgetKebabCase = computed (
65+ () => props .widgetKey ?
66+ props .widgetKey .replace (/ ([a-z ] )([A-Z ] )/ g , ' $1-$2' ).toLowerCase () as Widget : undefined
67+ );
68+ const widgetArea = computed (() => {
69+ // Find the widget area where this widgetKey belongs to
70+ if (! widgetKebabCase .value ) return undefined ;
71+ // Go through each area and check if its widgets array includes this key
72+ for (const [area, config] of Object .entries (lfxWidgetArea )) {
73+ if (config .widgets && config .widgets .includes (widgetKebabCase .value )) {
74+ return area ;
75+ }
76+ }
77+ return undefined ;
78+ });
79+ const link = computed (() => lfProjectLinks .find (l => l .key === widgetArea .value ));
80+ const linkUrl = computed (() => {
81+ if (! link .value ) return undefined ;
82+
83+ const query = {
84+ ... route .query ,
85+ widget: widgetKebabCase .value // remove the widget from the query
86+ }
87+ let name = link .value .projectRouteName ;
88+ if (selectedRepositoryGroup .value ) {
89+ name = link .value .repoGroupRouteName ;
90+ }
91+ else if (repoName .value ) {
92+ name = link .value .repoRouteName ;
93+ }
94+
95+ return {
96+ name ,
97+ query
98+ };
99+ });
52100
53101 </script >
54102<script lang="ts">
0 commit comments