2022-04-11 20:08:28 +00:00
|
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
import type { RouteLocation } from 'vue-router'
|
2021-12-21 08:02:03 +00:00
|
|
|
import {saveLastVisited} from '@/helpers/saveLastVisited'
|
2018-09-06 17:46:09 +00:00
|
|
|
|
2022-11-13 21:04:57 +00:00
|
|
|
import {saveProjectView, getProjectView} from '@/helpers/saveProjectView'
|
2022-02-06 19:11:13 +00:00
|
|
|
import {parseDateOrString} from '@/helpers/time/parseDateOrString'
|
|
|
|
import {getNextWeekDate} from '@/helpers/time/getNextWeekDate'
|
2022-09-21 16:21:25 +00:00
|
|
|
import {setTitle} from '@/helpers/setTitle'
|
|
|
|
|
2022-11-13 21:04:57 +00:00
|
|
|
import {useProjectStore} from '@/stores/projects'
|
2022-09-21 01:37:39 +00:00
|
|
|
import {useAuthStore} from '@/stores/auth'
|
2022-10-23 14:12:38 +00:00
|
|
|
import {useBaseStore} from '@/stores/base'
|
2021-11-14 20:33:53 +00:00
|
|
|
|
2022-11-13 21:52:28 +00:00
|
|
|
import HomeComponent from '@/views/Home.vue'
|
|
|
|
import NotFoundComponent from '@/views/404.vue'
|
|
|
|
const About = () => import('@/views/About.vue')
|
2018-09-08 20:27:13 +00:00
|
|
|
// User Handling
|
2022-11-13 21:52:28 +00:00
|
|
|
import LoginComponent from '@/views/user/Login.vue'
|
|
|
|
import RegisterComponent from '@/views/user/Register.vue'
|
|
|
|
import OpenIdAuth from '@/views/user/OpenIdAuth.vue'
|
|
|
|
const DataExportDownload = () => import('@/views/user/DataExportDownload.vue')
|
2020-09-05 20:35:52 +00:00
|
|
|
// Tasks
|
2022-11-13 21:04:57 +00:00
|
|
|
import UpcomingTasksComponent from '../views/tasks/ShowTasks.vue'
|
|
|
|
import LinkShareAuthComponent from '../views/sharing/LinkSharingAuth.vue'
|
|
|
|
import ListNamespaces from '../views/namespaces/ListNamespaces.vue'
|
2023-01-18 15:03:22 +00:00
|
|
|
const TaskDetailView = () => import('@/views/tasks/TaskDetailView.vue')
|
2022-10-01 15:02:35 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
// Team Handling
|
2022-11-13 21:52:28 +00:00
|
|
|
const ListTeamsComponent = () => import('@/views/teams/ListTeams.vue')
|
2020-09-05 20:35:52 +00:00
|
|
|
// Label Handling
|
2022-11-13 21:52:28 +00:00
|
|
|
const ListLabelsComponent = () => import('@/views/labels/ListLabels.vue')
|
|
|
|
const NewLabelComponent = () => import('@/views/labels/NewLabel.vue')
|
2020-09-05 20:35:52 +00:00
|
|
|
// Migration
|
2022-11-03 14:19:42 +00:00
|
|
|
const MigrationComponent = () => import('@/views/migrate/Migration.vue')
|
|
|
|
const MigrationHandlerComponent = () => import('@/views/migrate/MigrationHandler.vue')
|
2022-11-13 21:04:57 +00:00
|
|
|
// Project Views
|
2023-01-18 15:03:22 +00:00
|
|
|
import ProjectList from '@/views/project/ProjectList.vue'
|
|
|
|
const ProjectGantt = () => import('@/views/project/ProjectGantt.vue')
|
|
|
|
import ProjectTable from '@/views/project/ProjectTable.vue'
|
|
|
|
import ProjectKanban from '@/views/project/ProjectKanban.vue'
|
|
|
|
const ProjectInfo = () => import('@/views/project/ProjectInfo.vue')
|
2021-11-01 17:19:59 +00:00
|
|
|
|
2022-11-13 21:04:57 +00:00
|
|
|
// Project Settings
|
|
|
|
import ProjectSettingEdit from '../views/project/settings/edit.vue'
|
|
|
|
import ProjectSettingBackground from '../views/project/settings/background.vue'
|
|
|
|
import ProjectSettingDuplicate from '../views/project/settings/duplicate.vue'
|
|
|
|
import ProjectSettingShare from '../views/project/settings/share.vue'
|
|
|
|
import ProjectSettingDelete from '../views/project/settings/delete.vue'
|
|
|
|
import ProjectSettingArchive from '../views/project/settings/archive.vue'
|
2021-11-14 15:56:52 +00:00
|
|
|
|
2021-01-30 16:17:04 +00:00
|
|
|
// Namespace Settings
|
2022-11-13 21:52:28 +00:00
|
|
|
const NamespaceSettingEdit = () => import('@/views/namespaces/settings/edit.vue')
|
|
|
|
const NamespaceSettingShare = () => import('@/views/namespaces/settings/share.vue')
|
|
|
|
const NamespaceSettingArchive = () => import('@/views/namespaces/settings/archive.vue')
|
|
|
|
const NamespaceSettingDelete = () => import('@/views/namespaces/settings/delete.vue')
|
2021-11-14 15:56:52 +00:00
|
|
|
|
2020-09-26 21:02:37 +00:00
|
|
|
// Saved Filters
|
2022-11-13 21:52:28 +00:00
|
|
|
const FilterNew = () => import('@/views/filters/FilterNew.vue')
|
|
|
|
const FilterEdit = () => import('@/views/filters/FilterEdit.vue')
|
|
|
|
const FilterDelete = () => import('@/views/filters/FilterDelete.vue')
|
2020-07-27 17:53:19 +00:00
|
|
|
|
2022-11-13 21:52:28 +00:00
|
|
|
const PasswordResetComponent = () => import('@/views/user/PasswordReset.vue')
|
|
|
|
const GetPasswordResetComponent = () => import('@/views/user/RequestPasswordReset.vue')
|
|
|
|
const UserSettingsComponent = () => import('@/views/user/Settings.vue')
|
|
|
|
const UserSettingsAvatarComponent = () => import('@/views/user/settings/Avatar.vue')
|
|
|
|
const UserSettingsCaldavComponent = () => import('@/views/user/settings/Caldav.vue')
|
|
|
|
const UserSettingsDataExportComponent = () => import('@/views/user/settings/DataExport.vue')
|
|
|
|
const UserSettingsDeletionComponent = () => import('@/views/user/settings/Deletion.vue')
|
|
|
|
const UserSettingsEmailUpdateComponent = () => import('@/views/user/settings/EmailUpdate.vue')
|
|
|
|
const UserSettingsGeneralComponent = () => import('@/views/user/settings/General.vue')
|
|
|
|
const UserSettingsPasswordUpdateComponent = () => import('@/views/user/settings/PasswordUpdate.vue')
|
|
|
|
const UserSettingsTOTPComponent = () => import('@/views/user/settings/TOTP.vue')
|
2021-08-23 19:15:04 +00:00
|
|
|
|
2022-11-13 21:04:57 +00:00
|
|
|
// Project Handling
|
|
|
|
const NewProjectComponent = () => import('@/views/project/NewProject.vue')
|
2021-08-23 19:15:04 +00:00
|
|
|
|
2018-09-11 17:20:07 +00:00
|
|
|
// Namespace Handling
|
2022-11-13 21:52:28 +00:00
|
|
|
const NewNamespaceComponent = () => import('@/views/namespaces/NewNamespace.vue')
|
2020-07-27 17:53:19 +00:00
|
|
|
|
2022-11-13 21:52:28 +00:00
|
|
|
const EditTeamComponent = () => import('@/views/teams/EditTeam.vue')
|
|
|
|
const NewTeamComponent = () => import('@/views/teams/NewTeam.vue')
|
2018-09-06 17:46:09 +00:00
|
|
|
|
2021-08-20 13:17:19 +00:00
|
|
|
const router = createRouter({
|
|
|
|
history: createWebHistory(),
|
2020-04-25 23:11:34 +00:00
|
|
|
scrollBehavior(to, from, savedPosition) {
|
2019-10-20 19:40:44 +00:00
|
|
|
// If the user is using their forward/backward keys to navigate, we want to restore the scroll view
|
2020-04-25 23:11:34 +00:00
|
|
|
if (savedPosition) {
|
2019-10-20 19:40:44 +00:00
|
|
|
return savedPosition
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scroll to anchor should still work
|
2020-04-25 23:11:34 +00:00
|
|
|
if (to.hash) {
|
2022-01-30 15:48:02 +00:00
|
|
|
return {el: to.hash}
|
2019-10-20 19:40:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise just scroll to the top
|
2021-08-20 13:17:19 +00:00
|
|
|
return {left: 0, top: 0}
|
2019-10-20 19:40:44 +00:00
|
|
|
},
|
2019-03-07 19:48:40 +00:00
|
|
|
routes: [
|
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
name: 'home',
|
2020-09-05 20:35:52 +00:00
|
|
|
component: HomeComponent,
|
2019-03-07 19:48:40 +00:00
|
|
|
},
|
2020-03-02 19:30:49 +00:00
|
|
|
{
|
2021-08-20 13:17:19 +00:00
|
|
|
path: '/:pathMatch(.*)*',
|
|
|
|
name: 'not-found',
|
|
|
|
component: NotFoundComponent,
|
|
|
|
},
|
|
|
|
// if you omit the last `*`, the `/` character in params will be encoded when resolving or pushing
|
|
|
|
{
|
|
|
|
path: '/:pathMatch(.*)',
|
|
|
|
name: 'bad-not-found',
|
2020-03-02 19:30:49 +00:00
|
|
|
component: NotFoundComponent,
|
|
|
|
},
|
2019-03-07 19:48:40 +00:00
|
|
|
{
|
|
|
|
path: '/login',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'user.login',
|
2020-09-05 20:35:52 +00:00
|
|
|
component: LoginComponent,
|
2021-12-12 16:40:13 +00:00
|
|
|
meta: {
|
|
|
|
title: 'user.auth.login',
|
|
|
|
},
|
2019-03-07 19:48:40 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/get-password-reset',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'user.password-reset.request',
|
2020-09-05 20:35:52 +00:00
|
|
|
component: GetPasswordResetComponent,
|
2021-12-12 16:40:13 +00:00
|
|
|
meta: {
|
|
|
|
title: 'user.auth.resetPassword',
|
|
|
|
},
|
2019-03-07 19:48:40 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/password-reset',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'user.password-reset.reset',
|
2020-09-05 20:35:52 +00:00
|
|
|
component: PasswordResetComponent,
|
2021-12-12 16:40:13 +00:00
|
|
|
meta: {
|
|
|
|
title: 'user.auth.resetPassword',
|
|
|
|
},
|
2019-03-07 19:48:40 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/register',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'user.register',
|
2020-09-05 20:35:52 +00:00
|
|
|
component: RegisterComponent,
|
2021-12-12 16:40:13 +00:00
|
|
|
meta: {
|
2021-11-28 15:35:59 +00:00
|
|
|
title: 'user.auth.createAccount',
|
2021-12-12 16:40:13 +00:00
|
|
|
},
|
2019-03-07 19:48:40 +00:00
|
|
|
},
|
2020-06-17 20:24:37 +00:00
|
|
|
{
|
|
|
|
path: '/user/settings',
|
|
|
|
name: 'user.settings',
|
|
|
|
component: UserSettingsComponent,
|
2021-11-14 21:12:18 +00:00
|
|
|
redirect: {name: 'user.settings.general'},
|
2021-10-26 20:58:02 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: '/user/settings/avatar',
|
|
|
|
name: 'user.settings.avatar',
|
|
|
|
component: UserSettingsAvatarComponent,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/user/settings/caldav',
|
|
|
|
name: 'user.settings.caldav',
|
|
|
|
component: UserSettingsCaldavComponent,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/user/settings/data-export',
|
|
|
|
name: 'user.settings.data-export',
|
|
|
|
component: UserSettingsDataExportComponent,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/user/settings/deletion',
|
|
|
|
name: 'user.settings.deletion',
|
|
|
|
component: UserSettingsDeletionComponent,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/user/settings/email-update',
|
|
|
|
name: 'user.settings.email-update',
|
|
|
|
component: UserSettingsEmailUpdateComponent,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/user/settings/general',
|
|
|
|
name: 'user.settings.general',
|
|
|
|
component: UserSettingsGeneralComponent,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/user/settings/password-update',
|
|
|
|
name: 'user.settings.password-update',
|
|
|
|
component: UserSettingsPasswordUpdateComponent,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/user/settings/totp',
|
|
|
|
name: 'user.settings.totp',
|
|
|
|
component: UserSettingsTOTPComponent,
|
|
|
|
},
|
|
|
|
],
|
2020-06-17 20:24:37 +00:00
|
|
|
},
|
2021-09-04 19:26:38 +00:00
|
|
|
{
|
|
|
|
path: '/user/export/download',
|
|
|
|
name: 'user.export.download',
|
|
|
|
component: DataExportDownload,
|
|
|
|
},
|
2020-06-17 20:24:37 +00:00
|
|
|
{
|
|
|
|
path: '/share/:share/auth',
|
|
|
|
name: 'link-share.auth',
|
2020-09-05 20:35:52 +00:00
|
|
|
component: LinkShareAuthComponent,
|
2020-06-17 20:24:37 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/namespaces',
|
|
|
|
name: 'namespaces.index',
|
2022-11-13 22:06:43 +00:00
|
|
|
component: ListNamespaces,
|
2020-06-17 20:24:37 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/namespaces/new',
|
|
|
|
name: 'namespace.create',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: NewNamespaceComponent,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-07-17 21:21:46 +00:00
|
|
|
},
|
2020-06-17 20:24:37 +00:00
|
|
|
},
|
2019-03-07 19:48:40 +00:00
|
|
|
{
|
2021-01-30 16:17:04 +00:00
|
|
|
path: '/namespaces/:id/settings/edit',
|
|
|
|
name: 'namespace.settings.edit',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: NamespaceSettingEdit,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2022-09-15 10:52:38 +00:00
|
|
|
props: route => ({ namespaceId: Number(route.params.id as string) }),
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
{
|
2021-11-30 15:58:15 +00:00
|
|
|
path: '/namespaces/:namespaceId/settings/share',
|
2021-01-30 16:17:04 +00:00
|
|
|
name: 'namespace.settings.share',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: NamespaceSettingShare,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/namespaces/:id/settings/archive',
|
|
|
|
name: 'namespace.settings.archive',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: NamespaceSettingArchive,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2022-09-13 15:33:56 +00:00
|
|
|
props: route => ({ namespaceId: parseInt(route.params.id as string) }),
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/namespaces/:id/settings/delete',
|
|
|
|
name: 'namespace.settings.delete',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: NamespaceSettingDelete,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2022-09-21 18:21:47 +00:00
|
|
|
props: route => ({ namespaceId: Number(route.params.id as string) }),
|
2019-03-07 19:48:40 +00:00
|
|
|
},
|
2020-05-09 17:19:06 +00:00
|
|
|
{
|
|
|
|
path: '/tasks/:id',
|
|
|
|
name: 'task.detail',
|
|
|
|
component: TaskDetailView,
|
2022-09-15 10:52:38 +00:00
|
|
|
props: route => ({ taskId: Number(route.params.id as string) }),
|
2020-05-09 17:19:06 +00:00
|
|
|
},
|
2020-06-17 20:24:37 +00:00
|
|
|
{
|
2020-11-22 17:05:25 +00:00
|
|
|
path: '/tasks/by/upcoming',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'tasks.range',
|
2022-02-05 20:14:40 +00:00
|
|
|
component: UpcomingTasksComponent,
|
2022-02-06 19:11:13 +00:00
|
|
|
props: route => ({
|
2022-02-09 16:52:27 +00:00
|
|
|
dateFrom: parseDateOrString(route.query.from as string, new Date()),
|
|
|
|
dateTo: parseDateOrString(route.query.to as string, getNextWeekDate()),
|
2022-02-06 19:11:13 +00:00
|
|
|
showNulls: route.query.showNulls === 'true',
|
|
|
|
showOverdue: route.query.showOverdue === 'true',
|
2022-02-06 19:32:21 +00:00
|
|
|
}),
|
2020-06-17 20:24:37 +00:00
|
|
|
},
|
2021-11-01 17:19:59 +00:00
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/new/:namespaceId/',
|
|
|
|
name: 'project.create',
|
|
|
|
component: NewProjectComponent,
|
2021-11-01 17:19:59 +00:00
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
|
|
|
},
|
|
|
|
},
|
2021-01-30 16:17:04 +00:00
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/settings/edit',
|
|
|
|
name: 'project.settings.edit',
|
|
|
|
component: ProjectSettingEdit,
|
|
|
|
props: route => ({ projectId: Number(route.params.projectId as string) }),
|
2021-11-01 17:19:59 +00:00
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/settings/background',
|
|
|
|
name: 'project.settings.background',
|
|
|
|
component: ProjectSettingBackground,
|
2021-11-01 17:19:59 +00:00
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/settings/duplicate',
|
|
|
|
name: 'project.settings.duplicate',
|
|
|
|
component: ProjectSettingDuplicate,
|
2021-11-01 17:19:59 +00:00
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/settings/share',
|
|
|
|
name: 'project.settings.share',
|
|
|
|
component: ProjectSettingShare,
|
2021-11-01 17:19:59 +00:00
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/settings/delete',
|
|
|
|
name: 'project.settings.delete',
|
|
|
|
component: ProjectSettingDelete,
|
2021-11-01 17:19:59 +00:00
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/settings/archive',
|
|
|
|
name: 'project.settings.archive',
|
|
|
|
component: ProjectSettingArchive,
|
2021-11-01 17:19:59 +00:00
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/settings/edit',
|
2021-01-30 16:17:04 +00:00
|
|
|
name: 'filter.settings.edit',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: FilterEdit,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2022-11-13 21:04:57 +00:00
|
|
|
props: route => ({ projectId: Number(route.params.projectId as string) }),
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/settings/delete',
|
2021-01-30 16:17:04 +00:00
|
|
|
name: 'filter.settings.delete',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: FilterDelete,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2022-11-13 21:04:57 +00:00
|
|
|
props: route => ({ projectId: Number(route.params.projectId as string) }),
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2022-09-15 12:36:43 +00:00
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/info',
|
|
|
|
name: 'project.info',
|
|
|
|
component: ProjectInfo,
|
2022-09-15 12:36:43 +00:00
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
|
|
|
},
|
2022-11-13 21:04:57 +00:00
|
|
|
props: route => ({ projectId: Number(route.params.projectId as string) }),
|
2022-09-15 12:36:43 +00:00
|
|
|
},
|
2019-04-29 21:41:39 +00:00
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId',
|
|
|
|
name: 'project.index',
|
2021-12-10 17:04:07 +00:00
|
|
|
redirect(to) {
|
2023-01-18 15:03:27 +00:00
|
|
|
// Redirect the user to list view by default
|
2021-11-14 20:33:53 +00:00
|
|
|
|
2022-11-13 21:04:57 +00:00
|
|
|
const savedProjectView = getProjectView(to.params.projectId)
|
2023-01-18 15:52:09 +00:00
|
|
|
console.debug('Replaced list view with', savedProjectView)
|
2021-11-14 20:33:53 +00:00
|
|
|
|
|
|
|
return {
|
2022-11-13 21:04:57 +00:00
|
|
|
name: router.hasRoute(savedProjectView)
|
|
|
|
? savedProjectView
|
2022-11-13 21:44:01 +00:00
|
|
|
: 'project.list',
|
2022-11-13 21:04:57 +00:00
|
|
|
params: {projectId: to.params.projectId},
|
2021-11-14 20:33:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:44:01 +00:00
|
|
|
path: '/projects/:projectId/list',
|
|
|
|
name: 'project.list',
|
2022-11-13 21:04:57 +00:00
|
|
|
component: ProjectList,
|
|
|
|
beforeEnter: (to) => saveProjectView(to.params.projectId, to.name),
|
|
|
|
props: route => ({ projectId: Number(route.params.projectId as string) }),
|
2021-11-14 20:33:53 +00:00
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/gantt',
|
|
|
|
name: 'project.gantt',
|
|
|
|
component: ProjectGantt,
|
|
|
|
beforeEnter: (to) => saveProjectView(to.params.projectId, to.name),
|
2022-10-24 13:41:05 +00:00
|
|
|
// FIXME: test if `useRoute` would be the same. If it would use it instead.
|
|
|
|
props: route => ({route}),
|
2021-11-14 20:33:53 +00:00
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
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) }),
|
2021-11-14 20:33:53 +00:00
|
|
|
},
|
|
|
|
{
|
2022-11-13 21:04:57 +00:00
|
|
|
path: '/projects/:projectId/kanban',
|
|
|
|
name: 'project.kanban',
|
|
|
|
component: ProjectKanban,
|
2022-05-08 09:58:37 +00:00
|
|
|
beforeEnter: (to) => {
|
2022-11-13 21:04:57 +00:00
|
|
|
saveProjectView(to.params.projectId, to.name)
|
2022-05-08 09:58:37 +00:00
|
|
|
// Properly set the page title when a task popup is closed
|
2022-11-13 21:04:57 +00:00
|
|
|
const projectStore = useProjectStore()
|
|
|
|
const projectFromStore = projectStore.getProjectById(Number(to.params.projectId))
|
|
|
|
if(projectFromStore) {
|
|
|
|
setTitle(projectFromStore.title)
|
2022-05-08 09:58:37 +00:00
|
|
|
}
|
|
|
|
},
|
2022-11-13 21:04:57 +00:00
|
|
|
props: route => ({ projectId: Number(route.params.projectId as string) }),
|
2019-04-29 21:41:39 +00:00
|
|
|
},
|
2019-03-07 19:48:40 +00:00
|
|
|
{
|
|
|
|
path: '/teams',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'teams.index',
|
2022-11-13 22:06:43 +00:00
|
|
|
component: ListTeamsComponent,
|
2019-03-07 19:48:40 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/teams/new',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'teams.create',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: NewTeamComponent,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-21 22:33:16 +00:00
|
|
|
},
|
2019-03-07 19:48:40 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/teams/:id/edit',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'teams.edit',
|
2020-09-05 20:35:52 +00:00
|
|
|
component: EditTeamComponent,
|
2019-03-07 19:48:40 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/labels',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'labels.index',
|
2022-11-13 22:06:43 +00:00
|
|
|
component: ListLabelsComponent,
|
2019-09-09 17:55:43 +00:00
|
|
|
},
|
2020-12-30 17:55:54 +00:00
|
|
|
{
|
|
|
|
path: '/labels/new',
|
|
|
|
name: 'labels.create',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: NewLabelComponent,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-21 22:33:16 +00:00
|
|
|
},
|
2020-12-30 17:55:54 +00:00
|
|
|
},
|
2020-01-19 19:23:06 +00:00
|
|
|
{
|
|
|
|
path: '/migrate',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'migrate.start',
|
2020-01-19 19:23:06 +00:00
|
|
|
component: MigrationComponent,
|
|
|
|
},
|
|
|
|
{
|
2020-05-24 13:31:27 +00:00
|
|
|
path: '/migrate/:service',
|
2020-06-17 20:24:37 +00:00
|
|
|
name: 'migrate.service',
|
2022-11-03 14:19:42 +00:00
|
|
|
component: MigrationHandlerComponent,
|
|
|
|
props: route => ({
|
|
|
|
service: route.params.service as string,
|
2022-12-18 19:38:38 +00:00
|
|
|
code: route.query.code as string,
|
2022-11-03 14:19:42 +00:00
|
|
|
}),
|
2020-01-19 19:23:06 +00:00
|
|
|
},
|
2020-09-26 21:02:37 +00:00
|
|
|
{
|
|
|
|
path: '/filters/new',
|
|
|
|
name: 'filters.create',
|
2021-11-01 17:19:59 +00:00
|
|
|
component: FilterNew,
|
|
|
|
meta: {
|
|
|
|
showAsModal: true,
|
2021-01-21 22:33:16 +00:00
|
|
|
},
|
2020-09-26 21:02:37 +00:00
|
|
|
},
|
2020-11-21 16:38:40 +00:00
|
|
|
{
|
|
|
|
path: '/auth/openid/:provider',
|
|
|
|
name: 'openid.auth',
|
|
|
|
component: OpenIdAuth,
|
|
|
|
},
|
2021-07-06 15:05:35 +00:00
|
|
|
{
|
|
|
|
path: '/about',
|
|
|
|
name: 'about',
|
|
|
|
component: About,
|
|
|
|
},
|
2020-09-05 20:35:52 +00:00
|
|
|
],
|
2021-08-20 13:17:19 +00:00
|
|
|
})
|
|
|
|
|
2022-10-23 14:12:38 +00:00
|
|
|
export async function getAuthForRoute(route: RouteLocation) {
|
2022-09-21 01:37:39 +00:00
|
|
|
const authStore = useAuthStore()
|
|
|
|
if (authStore.authUser || authStore.authLinkShare) {
|
2021-12-21 08:02:03 +00:00
|
|
|
return
|
|
|
|
}
|
2022-10-23 14:12:38 +00:00
|
|
|
|
|
|
|
const baseStore = useBaseStore()
|
|
|
|
// When trying this before the current user was fully loaded we might get a flash of the login screen
|
|
|
|
// in the user shell. To make shure this does not happen we check if everything is ready before trying.
|
|
|
|
if (!baseStore.ready) {
|
|
|
|
return
|
|
|
|
}
|
2021-08-20 13:17:19 +00:00
|
|
|
|
2021-12-21 08:02:03 +00:00
|
|
|
// Check if the user is already logged in and redirect them to the home page if not
|
|
|
|
if (
|
|
|
|
![
|
|
|
|
'user.login',
|
|
|
|
'user.password-reset.request',
|
|
|
|
'user.password-reset.reset',
|
|
|
|
'user.register',
|
|
|
|
'link-share.auth',
|
|
|
|
'openid.auth',
|
|
|
|
].includes(route.name as string) &&
|
|
|
|
localStorage.getItem('passwordResetToken') === null &&
|
2022-10-20 14:15:58 +00:00
|
|
|
localStorage.getItem('emailConfirmToken') === null &&
|
2022-10-20 14:19:19 +00:00
|
|
|
!(route.name === 'home' && (typeof route.query.userPasswordReset !== 'undefined' || typeof route.query.userEmailConfirm !== 'undefined'))
|
2021-12-21 08:02:03 +00:00
|
|
|
) {
|
2022-10-23 11:12:04 +00:00
|
|
|
saveLastVisited(route.name as string, route.params, route.query)
|
2021-12-21 08:02:03 +00:00
|
|
|
return {name: 'user.login'}
|
|
|
|
}
|
2022-10-20 14:15:58 +00:00
|
|
|
|
|
|
|
if(localStorage.getItem('passwordResetToken') !== null && route.name !== 'user.password-reset.reset') {
|
|
|
|
return {name: 'user.password-reset.reset'}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(localStorage.getItem('emailConfirmToken') !== null && route.name !== 'user.login') {
|
|
|
|
return {name: 'user.login'}
|
|
|
|
}
|
2021-12-21 08:02:03 +00:00
|
|
|
}
|
2021-08-20 13:17:19 +00:00
|
|
|
|
2022-10-23 14:12:38 +00:00
|
|
|
router.beforeEach(async (to) => {
|
2022-10-05 14:51:35 +00:00
|
|
|
return getAuthForRoute(to)
|
|
|
|
})
|
|
|
|
|
2021-08-20 13:17:19 +00:00
|
|
|
export default router
|