From 3104a830ae8b7f948ef52bb673afa0f950806e1a Mon Sep 17 00:00:00 2001 From: Jeremy Wharton Date: Thu, 14 Sep 2023 22:17:06 -0500 Subject: [PATCH] web/satellite/vuetify-poc: unmock list of owned and shared projects This change shows real projects in the Project dropdown of the project navigation sidebar, replacing mock data. Resolves #6283 Change-Id: Id8eef6cc02b5b773f89a00d41d5335ae2feb1729 --- .../src/layouts/default/ProjectNav.vue | 130 ++++++++++++------ 1 file changed, 88 insertions(+), 42 deletions(-) diff --git a/web/satellite/vuetify-poc/src/layouts/default/ProjectNav.vue b/web/satellite/vuetify-poc/src/layouts/default/ProjectNav.vue index 661aa64455e4..4e2f0a6c2350 100644 --- a/web/satellite/vuetify-poc/src/layouts/default/ProjectNav.vue +++ b/web/satellite/vuetify-poc/src/layouts/default/ProjectNav.vue @@ -11,50 +11,69 @@ - - - - - My Projects - - - - - - - - - My First Project - - - - + - - - - - Shared Projects - - - - - - - - Storj Labs - - - - + @@ -263,6 +282,7 @@ import { Project } from '@/types/projects'; import { useProjectsStore } from '@/store/modules/projectsStore'; import { useAnalyticsStore } from '@/store/modules/analyticsStore'; import { useAppStore } from '@poc/store/appStore'; +import { useUsersStore } from '@/store/modules/usersStore'; import IconProject from '@poc/components/icons/IconProject.vue'; import IconSettings from '@poc/components/icons/IconSettings.vue'; @@ -282,6 +302,7 @@ import CreateProjectDialog from '@poc/components/dialogs/CreateProjectDialog.vue const analyticsStore = useAnalyticsStore(); const projectsStore = useProjectsStore(); const appStore = useAppStore(); +const usersStore = useUsersStore(); const { mdAndDown } = useDisplay(); @@ -299,6 +320,22 @@ const selectedProject = computed((): Project => { return projectsStore.state.selectedProject; }); +/* + * Returns user's own projects. + */ +const ownProjects = computed((): Project[] => { + const projects = projectsStore.projects.filter((p) => p.ownerId === usersStore.state.user.id); + return projects.sort(compareProjects); +}); + +/** + * Returns projects the user is a member of but doesn't own. + */ +const sharedProjects = computed((): Project[] => { + const projects = projectsStore.projects.filter((p) => p.ownerId !== usersStore.state.user.id); + return projects.sort(compareProjects); +}); + /** * Conditionally closes the navigation drawer and tracks page visit. */ @@ -316,6 +353,15 @@ function trackPageVisitEvent(page: string): void { analyticsStore.pageVisit(page); } +/** + * This comparator is used to sort projects by isSelected. + */ +function compareProjects(a: Project, b: Project): number { + if (a.isSelected) return -1; + if (b.isSelected) return 1; + return 0; +} + onBeforeMount(() => { if (mdAndDown.value) { model.value = false;