Skip to content

Commit

Permalink
#139 fix error on load projects without is_default key
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreezag committed Jul 28, 2024
1 parent c32f55a commit 421ec35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/shared/stores/events/events-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const useEventsStore = defineStore("eventsStore", {
availableProjects: ({ projects }) => projects.available,
isMultipleProjects: ({ projects }) => (
projects.available.length > 1 ||
projects.available.find((proj) => !proj.is_default)
!projects.available.some((proj) => proj.is_default)
),
},
actions: {
Expand Down Expand Up @@ -213,18 +213,18 @@ export const useEventsStore = defineStore("eventsStore", {

if (!this.projects.activeKey) {
const defaultProject = projects.find((proj) => proj.is_default) || projects[0];
this.setActiveProject(defaultProject.key);
this.setActiveProjectKey(defaultProject.key);
}
} else {
this.resetActiveProject();
this.resetActiveProjectKey();
}
},
setActiveProject(project: string) {
setActiveProjectKey(project: string) {
this.projects.activeKey = project;

setStoredProject(project);
},
resetActiveProject() {
resetActiveProjectKey() {
this.projects.activeKey = undefined;

removeStoredProject();
Expand Down
15 changes: 9 additions & 6 deletions src/widgets/ui/layout-sidebar/layout-sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ const userMenu = ref<HTMLElement | null>(null);
const isVisibleProfile = ref(false);
const isVisibleProjects = ref(false);
// TODO: need to check why project is empty on first load
const isProjectLoading = computed(() => !activeProject.value);
onClickOutside(projectMenu, () => {
isVisibleProjects.value = false;
});
Expand Down Expand Up @@ -115,15 +118,15 @@ const serverVersion = computed(() =>
: `@${apiVersion.value}`,
);
const setProject = (project: string) => {
eventsStore.setActiveProject(project);
const setProject = (projectKey: string) => {
eventsStore.setActiveProjectKey(projectKey);
isVisibleProjects.value = false;
};
const makeShortTitle = (title: string) => title.substring(0, 2);
const makeShortTitle = (title: string) => (title || "").substring(0, 2);
const generateRadialGradient = (input: string) =>
`linear-gradient(to right, ${textToColors(input).join(", ")})`;
`linear-gradient(to right, ${textToColors(input || "").join(", ")})`;
</script>

<template>
Expand All @@ -138,7 +141,7 @@ const generateRadialGradient = (input: string) =>
<IconSvg class="layout-sidebar__link-icon" name="logo-short" />
</NuxtLink>

<template v-if="isMultipleProjects">
<template v-if="!isProjectLoading && isMultipleProjects">
<hr class="layout-sidebar__sep" />

<div class="layout-sidebar__projects">
Expand All @@ -163,7 +166,7 @@ const generateRadialGradient = (input: string) =>
<hr class="layout-sidebar__sep" />
</template>

<template v-if="!isMultipleProjects">
<template v-if="!isMultipleProjects || isProjectLoading">
<NuxtLink to="/" title="Events" class="layout-sidebar__link">
<IconSvg class="layout-sidebar__link-icon" name="events" />
</NuxtLink>
Expand Down

0 comments on commit 421ec35

Please sign in to comment.