@@ -12,15 +12,15 @@ import {
1212 useEventsStore ,
1313} from " ~/src/shared/stores" ;
1414import { useConnectionStore } from " ~/src/shared/stores/connections" ;
15- import type { TProjects } from " ~/src/shared/types" ;
1615import { BadgeNumber , IconSvg } from " ~/src/shared/ui" ;
1716import { version } from " ../../../../package.json" ;
1817import { EVENTS_LINKS_MAP , EVENTS_NAV_ORDER } from " ./constants" ;
1918
2019const { isConnectedWS } = storeToRefs (useConnectionStore ());
2120const { isVisibleEventCounts, auth } = storeToRefs (useSettingsStore ());
2221const eventsStore = useEventsStore ();
23- const { availableProjects, activeProjectKey } = storeToRefs (eventsStore );
22+ const { availableProjects, isMultipleProjects, activeProject } =
23+ storeToRefs (eventsStore );
2424
2525const profileStore = useProfileStore ();
2626const { profile } = storeToRefs (profileStore );
@@ -35,6 +35,9 @@ const userMenu = ref<HTMLElement | null>(null);
3535const isVisibleProfile = ref (false );
3636const isVisibleProjects = ref (false );
3737
38+ // TODO: need to check why project is empty on first load
39+ const isProjectLoading = computed (() => ! activeProject .value );
40+
3841onClickOutside (projectMenu , () => {
3942 isVisibleProjects .value = false ;
4043});
@@ -93,14 +96,6 @@ const toggleProjects = () => {
9396 isVisibleProjects .value = ! isVisibleProjects .value ;
9497};
9598
96- const activeProject = computed (() => {
97- const project = availableProjects .value .find (
98- (p ) => p .key === activeProjectKey .value ,
99- );
100-
101- return project as unknown as TProjects [" data" ][number ];
102- });
103-
10499const logout = () => {
105100 profileStore .removeToken ();
106101 const router = useRouter ();
@@ -123,15 +118,15 @@ const serverVersion = computed(() =>
123118 : ` @${apiVersion .value } ` ,
124119);
125120
126- const setProject = (project : string ) => {
127- eventsStore .setActiveProject ( project );
121+ const setProject = (projectKey : string ) => {
122+ eventsStore .setActiveProjectKey ( projectKey );
128123
129124 isVisibleProjects .value = false ;
130125};
131126
132- const makeShortTitle = (title : string ) => title .substring (0 , 2 );
127+ const makeShortTitle = (title : string ) => ( title || " " ) .substring (0 , 2 );
133128const generateRadialGradient = (input : string ) =>
134- ` linear-gradient(to right, ${textToColors (input ).join (" , " )}) ` ;
129+ ` linear-gradient(to right, ${textToColors (input || " " ).join (" , " )}) ` ;
135130 </script >
136131
137132<template >
@@ -146,7 +141,7 @@ const generateRadialGradient = (input: string) =>
146141 <IconSvg class =" layout-sidebar__link-icon" name =" logo-short" />
147142 </NuxtLink >
148143
149- <template v-if =" availableProjects . length > 0 " >
144+ <template v-if =" ! isProjectLoading && isMultipleProjects " >
150145 <hr class =" layout-sidebar__sep" />
151146
152147 <div class =" layout-sidebar__projects" >
@@ -171,7 +166,7 @@ const generateRadialGradient = (input: string) =>
171166 <hr class =" layout-sidebar__sep" />
172167 </template >
173168
174- <template v-if =" ! availableProjects . length " >
169+ <template v-if =" ! isMultipleProjects || isProjectLoading " >
175170 <NuxtLink to =" /" title =" Events" class =" layout-sidebar__link" >
176171 <IconSvg class =" layout-sidebar__link-icon" name =" events" />
177172 </NuxtLink >
@@ -230,7 +225,12 @@ const generateRadialGradient = (input: string) =>
230225 {{ makeShortTitle(project.name) }}
231226 </span >
232227
233- {{ project.name }}
228+ <div class =" layout-sidebar__dropdown-item-text" >
229+ <span class =" layout-sidebar__dropdown-item-text-key" >
230+ {{ project.key }}
231+ </span >
232+ {{ project.name }}
233+ </div >
234234 </button >
235235 </div >
236236
@@ -354,7 +354,16 @@ const generateRadialGradient = (input: string) =>
354354 @apply text-2xs font-semibold uppercase ;
355355 @apply h-6 md :h- 8 w- 7 md:w- 8 rounded- lg;
356356 @apply flex items-center justify-center relative flex-shrink- 0;
357- @apply text-white dark :text- black;
357+ @apply text-white dark :text- black self- start;
358+ }
359+
360+ .layout-sidebar__dropdown-item-text {
361+ @apply flex flex-col ;
362+ }
363+
364+ .layout-sidebar__dropdown-item-text-key {
365+ @apply text-2xs uppercase font-normal -mt- 0.5 ;
366+ @apply text-gray-600 dark :text- gray- 400;
358367}
359368
360369.layout-sidebar__dropdown {
0 commit comments