-
Notifications
You must be signed in to change notification settings - Fork 387
/
ProjectNav.vue
370 lines (331 loc) · 16.4 KB
/
ProjectNav.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
// Copyright (C) 2023 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
<v-navigation-drawer v-model="model" class="py-1">
<v-sheet>
<v-list class="px-2" color="default" variant="flat">
<!-- Project -->
<v-list-item link class="pa-4 rounded-lg">
<v-menu activator="parent" location="end" transition="scale-transition">
<!-- Project Menu -->
<v-list class="pa-2">
<!-- My Projects -->
<template v-if="ownProjects.length">
<v-list-item rounded="lg" link router-link to="/projects" @click="() => registerLinkClick('/projects')">
<template #prepend>
<!-- <img src="@poc/assets/icon-project.svg" alt="Projects"> -->
<IconProject />
</template>
<v-list-item-title class="text-body-2 ml-3">
<v-chip color="purple2" variant="tonal" size="small" rounded="xl" class="font-weight-bold" link>
My Projects
</v-chip>
</v-list-item-title>
</v-list-item>
<!-- Selected Project -->
<v-list-item
v-for="project in ownProjects"
:key="project.id"
rounded="lg"
:active="project.isSelected"
:to="!project.isSelected ? `/projects/${project.id}/dashboard` : undefined"
>
<template v-if="project.isSelected" #prepend>
<img src="@poc/assets/icon-check-color.svg" alt="Selected Project">
</template>
<v-list-item-title class="text-body-2" :class="project.isSelected ? 'ml-3' : 'ml-7'">
{{ project.name }}
</v-list-item-title>
</v-list-item>
<v-divider class="my-2" />
</template>
<!-- Shared With Me -->
<template v-if="sharedProjects.length">
<v-list-item rounded="lg" link router-link to="/projects" @click="() => registerLinkClick('/projects')">
<template #prepend>
<IconProject />
</template>
<v-list-item-title class="text-body-2 ml-3">
<v-chip color="green" variant="tonal" size="small" rounded="xl" class="font-weight-bold" link>
Shared Projects
</v-chip>
</v-list-item-title>
</v-list-item>
<!-- Other Project -->
<v-list-item
v-for="project in sharedProjects"
:key="project.id"
rounded="lg"
:active="project.isSelected"
:to="!project.isSelected ? `/projects/${project.id}/dashboard` : undefined"
>
<template v-if="project.isSelected" #prepend>
<img src="@poc/assets/icon-check-color.svg" alt="Selected Project">
</template>
<v-list-item-title class="text-body-2" :class="project.isSelected ? 'ml-3' : 'ml-7'">
{{ project.name }}
</v-list-item-title>
</v-list-item>
<v-divider class="my-2" />
</template>
<!-- Project Settings -->
<v-list-item link rounded="lg" :to="`/projects/${selectedProject.id}/settings`">
<template #prepend>
<IconSettings />
</template>
<v-list-item-title class="text-body-2 ml-3">
Project Settings
</v-list-item-title>
</v-list-item>
<!-- <v-divider class="my-2"></v-divider> -->
<!-- View All Projects -->
<v-list-item link rounded="lg" router-link to="/projects" @click="() => registerLinkClick('/projects')">
<template #prepend>
<IconAllProjects />
</template>
<v-list-item-title class="text-body-2 ml-3">
View All Projects
</v-list-item-title>
</v-list-item>
<!-- Create New Project -->
<v-list-item link rounded="lg" @click="isCreateProjectDialogShown = true">
<template #prepend>
<IconNew />
</template>
<v-list-item-title class="text-body-2 ml-3">
Create New Project
</v-list-item-title>
</v-list-item>
<v-divider class="my-2" />
<!-- Manage Passphrase -->
<v-list-item link class="mt-1" rounded="lg">
<template #prepend>
<IconPassphrase />
</template>
<v-list-item-title class="text-body-2 ml-3">
Manage Passphrase
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<template #prepend>
<IconProject />
</template>
<v-list-item-title link class="text-body-2 ml-3">
Project
</v-list-item-title>
<v-list-item-subtitle class="ml-3">
{{ selectedProject.name }}
</v-list-item-subtitle>
<template #append>
<img src="@poc/assets/icon-right.svg" class="ml-3" alt="Project" width="10">
</template>
</v-list-item>
<v-divider class="my-2" />
<v-list-item link router-link :to="`/projects/${selectedProject.id}/dashboard`" class="my-1 py-3" rounded="lg" @click="() => registerLinkClick('/dashboard')">
<template #prepend>
<IconDashboard />
</template>
<v-list-item-title class="text-body-2 ml-3">
Overview
</v-list-item-title>
</v-list-item>
<v-list-item link router-link :to="`/projects/${selectedProject.id}/buckets`" class="my-1" rounded="lg" @click="() => registerLinkClick('/buckets')">
<template #prepend>
<IconBucket />
</template>
<v-list-item-title class="text-body-2 ml-3">
Buckets
</v-list-item-title>
</v-list-item>
<v-list-item link router-link :to="`/projects/${selectedProject.id}/access`" class="my-1" rounded="lg" @click="() => registerLinkClick('/access')">
<template #prepend>
<IconAccess />
</template>
<v-list-item-title class="text-body-2 ml-3">
Access
</v-list-item-title>
</v-list-item>
<v-list-item link router-link :to="`/projects/${selectedProject.id}/team`" class="my-1" rounded="lg" @click="() => registerLinkClick('/team')">
<template #prepend>
<IconTeam />
</template>
<v-list-item-title class="text-body-2 ml-3">
Team
</v-list-item-title>
</v-list-item>
<v-divider class="my-2" />
<!-- Resources Menu -->
<v-list-item link class="rounded-lg">
<v-menu activator="parent" location="end" transition="scale-transition">
<v-list class="pa-2">
<v-list-item
class="py-3"
rounded="lg"
href="https://docs.storj.io/"
target="_blank"
rel="noopener noreferrer"
>
<template #prepend>
<!-- <img src="@poc/assets/icon-docs.svg" alt="Docs"> -->
<IconDocs />
</template>
<v-list-item-title class="text-body-2 mx-3">
Documentation
</v-list-item-title>
<v-list-item-subtitle class="mx-3">
<small>Go to the Storj docs.</small>
</v-list-item-subtitle>
</v-list-item>
<v-list-item
class="py-3"
rounded="lg"
href="https://forum.storj.io/"
target="_blank"
rel="noopener noreferrer"
>
<template #prepend>
<IconForum />
</template>
<v-list-item-title class="text-body-2 mx-3">
Community Forum
</v-list-item-title>
<v-list-item-subtitle class="mx-3">
<small>Join our global community.</small>
</v-list-item-subtitle>
</v-list-item>
<v-list-item
class="py-3"
rounded="lg"
href="https://supportdcs.storj.io/hc/en-us"
target="_blank"
rel="noopener noreferrer"
>
<template #prepend>
<IconSupport />
</template>
<v-list-item-title class="text-body-2 mx-3">
Storj Support
</v-list-item-title>
<v-list-item-subtitle class="mx-3">
<small>Need help? Get support.</small>
</v-list-item-subtitle>
</v-list-item>
</v-list>
</v-menu>
<template #prepend>
<IconResources />
</template>
<v-list-item-title class="text-body-2 ml-3">
Resources
</v-list-item-title>
<template #append>
<img src="@poc/assets/icon-right.svg" alt="Resources" width="10">
</template>
</v-list-item>
<v-divider class="my-2" />
<!-- <v-list-item link class="my-1" router-link to="/design-library" rounded="lg">
<template v-slot:prepend>
<img src="@poc/assets/icon-bookmark.svg" alt="Design Library" class="mr-3">
</template>
<v-list-item-title class="text-body-2">
Design Library
</v-list-item-title>
</v-list-item> -->
</v-list>
</v-sheet>
</v-navigation-drawer>
<create-project-dialog v-model="isCreateProjectDialogShown" />
</template>
<script setup lang="ts">
import { computed, onBeforeMount, ref } from 'vue';
import {
VNavigationDrawer,
VSheet,
VList,
VListItem,
VListItemTitle,
VListItemSubtitle,
VMenu,
VChip,
VDivider,
} from 'vuetify/components';
import { useDisplay } from 'vuetify';
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';
import IconAllProjects from '@poc/components/icons/IconAllProjects.vue';
import IconNew from '@poc/components/icons/IconNew.vue';
import IconPassphrase from '@poc/components/icons/IconPassphrase.vue';
import IconDashboard from '@poc/components/icons/IconDashboard.vue';
import IconBucket from '@poc/components/icons/IconBucket.vue';
import IconAccess from '@poc/components/icons/IconAccess.vue';
import IconTeam from '@poc/components/icons/IconTeam.vue';
import IconDocs from '@poc/components/icons/IconDocs.vue';
import IconForum from '@poc/components/icons/IconForum.vue';
import IconSupport from '@poc/components/icons/IconSupport.vue';
import IconResources from '@poc/components/icons/IconResources.vue';
import CreateProjectDialog from '@poc/components/dialogs/CreateProjectDialog.vue';
const analyticsStore = useAnalyticsStore();
const projectsStore = useProjectsStore();
const appStore = useAppStore();
const usersStore = useUsersStore();
const { mdAndDown } = useDisplay();
const model = computed<boolean>({
get: () => appStore.state.isNavigationDrawerShown,
set: value => appStore.toggleNavigationDrawer(value),
});
const isCreateProjectDialogShown = ref<boolean>(false);
/**
* Returns the selected project from the store.
*/
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.
*/
function registerLinkClick(page: string): void {
if (mdAndDown.value) {
model.value = false;
}
trackPageVisitEvent(page);
}
/**
* Sends "Page Visit" event to segment and opens link.
*/
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;
}
});
</script>