From 59ced554cdf98a87f5fd304b7332cf2f8d067863 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 16 Mar 2024 13:09:53 +0100 Subject: [PATCH] chore(views): remove old view routes --- frontend/src/components/home/contentAuth.vue | 2 +- .../misc/keyboard-shortcuts/shortcuts.ts | 2 +- frontend/src/router/index.ts | 49 +------------------ frontend/src/views/project/ProjectView.vue | 3 +- .../views/project/helpers/useGanttFilters.ts | 11 +++-- 5 files changed, 13 insertions(+), 54 deletions(-) diff --git a/frontend/src/components/home/contentAuth.vue b/frontend/src/components/home/contentAuth.vue index 8cda2911c..c2c814b4b 100644 --- a/frontend/src/components/home/contentAuth.vue +++ b/frontend/src/components/home/contentAuth.vue @@ -37,7 +37,7 @@ v-slot="{ Component }" :route="routeWithModal" > - + diff --git a/frontend/src/components/misc/keyboard-shortcuts/shortcuts.ts b/frontend/src/components/misc/keyboard-shortcuts/shortcuts.ts index e1550bafc..58a0d980f 100644 --- a/frontend/src/components/misc/keyboard-shortcuts/shortcuts.ts +++ b/frontend/src/components/misc/keyboard-shortcuts/shortcuts.ts @@ -62,7 +62,7 @@ export const KEYBOARD_SHORTCUTS : ShortcutGroup[] = [ }, { title: 'project.kanban.title', - available: (route) => route.name === 'project.kanban', + available: (route) => route.name === 'project.view', shortcuts: [ { title: 'keyboardShortcuts.task.done', diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index c2b994392..91454b22b 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -5,10 +5,8 @@ import {saveLastVisited} from '@/helpers/saveLastVisited' import {saveProjectView, getProjectView} from '@/helpers/projectView' import {parseDateOrString} from '@/helpers/time/parseDateOrString' import {getNextWeekDate} from '@/helpers/time/getNextWeekDate' -import {setTitle} from '@/helpers/setTitle' import {LINK_SHARE_HASH_PREFIX} from '@/constants/linkShareHash' -import {useProjectStore} from '@/stores/projects' import {useAuthStore} from '@/stores/auth' import {useBaseStore} from '@/stores/base' @@ -33,16 +31,8 @@ const NewLabelComponent = () => import('@/views/labels/NewLabel.vue') // Migration const MigrationComponent = () => import('@/views/migrate/Migration.vue') const MigrationHandlerComponent = () => import('@/views/migrate/MigrationHandler.vue') -// Project Views -const ProjectList = () => import('@/views/project/ProjectList.vue') -const ProjectGantt = () => import('@/views/project/ProjectGantt.vue') -const ProjectTable = () => import('@/views/project/ProjectTable.vue') +// Project View const ProjectView = () => import('@/views/project/ProjectView.vue') -// If we load the component async, using it as a backdrop view will not work. Instead, everything explodes -// with an error from the core saying "Cannot read properties of undefined (reading 'parentNode')" -// Of course, with no clear indicator of where the problem comes from. -// const ProjectKanban = () => import('@/views/project/ProjectKanban.vue') -import ProjectKanban from '@/views/project/ProjectKanban.vue' const ProjectInfo = () => import('@/views/project/ProjectInfo.vue') // Project Settings @@ -372,43 +362,6 @@ const router = createRouter({ viewId: route.params.viewId ? parseInt(route.params.viewId as string): undefined, }), }, - { - path: '/projects/:projectId/list', - name: 'project.list', - component: ProjectList, - beforeEnter: (to) => saveProjectView(to.params.projectId, to.name), - props: route => ({ projectId: Number(route.params.projectId as string) }), - }, - { - path: '/projects/:projectId/gantt', - name: 'project.gantt', - component: ProjectGantt, - beforeEnter: (to) => saveProjectView(to.params.projectId, to.name), - // FIXME: test if `useRoute` would be the same. If it would use it instead. - props: route => ({route}), - }, - { - path: '/projects/:projectId/table', - name: 'project.table', - component: ProjectTable, - beforeEnter: (to) => saveProjectView(to.params.projectId, to.name), - props: route => ({ projectId: Number(route.params.projectId as string) }), - }, - { - path: '/projects/:projectId/kanban', - name: 'project.kanban', - component: ProjectKanban, - beforeEnter: (to) => { - saveProjectView(to.params.projectId, to.name) - // Properly set the page title when a task popup is closed - const projectStore = useProjectStore() - const projectFromStore = projectStore.projects[Number(to.params.projectId)] - if(projectFromStore) { - setTitle(projectFromStore.title) - } - }, - props: route => ({ projectId: Number(route.params.projectId as string) }), - }, { path: '/teams', name: 'teams.index', diff --git a/frontend/src/views/project/ProjectView.vue b/frontend/src/views/project/ProjectView.vue index f7918d1ff..df905e98c 100644 --- a/frontend/src/views/project/ProjectView.vue +++ b/frontend/src/views/project/ProjectView.vue @@ -29,7 +29,8 @@ watch( () => viewId, () => { if (viewId === 0) { - // Ideally, we would do that in the router redirect, but we can't access the project store there. + // Ideally, we would do that in the router redirect, but we the projects (and therefore, the views) + // are not always loaded then. const viewId = projectStore.projects[projectId].views[0].id router.replace({ name: 'project.view', diff --git a/frontend/src/views/project/helpers/useGanttFilters.ts b/frontend/src/views/project/helpers/useGanttFilters.ts index caf4df18d..12e54b747 100644 --- a/frontend/src/views/project/helpers/useGanttFilters.ts +++ b/frontend/src/views/project/helpers/useGanttFilters.ts @@ -17,6 +17,7 @@ import type {IProjectView} from '@/modelTypes/IProjectView' // convenient internal filter object export interface GanttFilters { projectId: IProject['id'] + viewId: IProjectView['id'], dateFrom: DateISO dateTo: DateISO showTasksWithoutDates: boolean @@ -42,6 +43,7 @@ function ganttRouteToFilters(route: Partial): GanttFilt const ganttRoute = route return { projectId: Number(ganttRoute.params?.projectId), + viewId: Number(ganttRoute.params?.viewId), dateFrom: parseDateProp(ganttRoute.query?.dateFrom as DateKebab) || getDefaultDateFrom(), dateTo: parseDateProp(ganttRoute.query?.dateTo as DateKebab) || getDefaultDateTo(), showTasksWithoutDates: parseBooleanProp(ganttRoute.query?.showTasksWithoutDates as string) || DEFAULT_SHOW_TASKS_WITHOUT_DATES, @@ -70,8 +72,11 @@ function ganttFiltersToRoute(filters: GanttFilters): RouteLocationRaw { } return { - name: 'project.gantt', - params: {projectId: filters.projectId}, + name: 'project.view', + params: { + projectId: filters.projectId, + viewId: filters.viewId, + }, query, } } @@ -99,7 +104,7 @@ export function useGanttFilters(route: Ref, view: IProj ganttGetDefaultFilters, ganttRouteToFilters, ganttFiltersToRoute, - ['project.gantt'], + ['project.view'], ) const {