diff --git a/src/components/sharing/linkSharing.vue b/src/components/sharing/linkSharing.vue index a86d7b4a..2143b15b 100644 --- a/src/components/sharing/linkSharing.vue +++ b/src/components/sharing/linkSharing.vue @@ -201,13 +201,16 @@ import {useStore} from '@/store' import {useI18n} from 'vue-i18n' import {RIGHTS} from '@/constants/rights' -import LinkShareModel, {type ILinkShare} from '@/models/linkShare' +import LinkShareModel from '@/models/linkShare' +import type {ILinkShare} from '@/modelTypes/ILinkShare' import LinkShareService from '@/services/linkShare' import {useCopyToClipboard} from '@/composables/useCopyToClipboard' import {success} from '@/message' -import type {IList} from '@/models/list' +import type {IList} from '@/modelTypes/IList' +import type {ListView} from '@/types/ListView' +import {LIST_VIEWS} from '@/types/ListView' const props = defineProps({ listId: { @@ -227,9 +230,7 @@ const showDeleteModal = ref(false) const linkIdToDelete = ref(0) const showNewForm = ref(false) -interface SelectedViewMapper { - [listId: number]: string, -} +type SelectedViewMapper = Record const selectedView = ref({}) @@ -285,7 +286,7 @@ async function remove(listId: IList['id']) { } } -function getShareLink(hash: string, view: string = 'list') { +function getShareLink(hash: string, view: ListView = LIST_VIEWS.LIST) { return frontendUrl.value + 'share/' + hash + '/auth?view=' + view } diff --git a/src/types/ListView.ts b/src/types/ListView.ts new file mode 100644 index 00000000..bf8aa355 --- /dev/null +++ b/src/types/ListView.ts @@ -0,0 +1,8 @@ +export const LIST_VIEWS = { + LIST: 'list', + GANTT: 'gantt', + TABLE: 'table', + KANBAN: 'kanban', +} as const + +export type ListView = typeof LIST_VIEWS[keyof typeof LIST_VIEWS] diff --git a/src/views/sharing/LinkSharingAuth.vue b/src/views/sharing/LinkSharingAuth.vue index 5d758ef1..0962e8b9 100644 --- a/src/views/sharing/LinkSharingAuth.vue +++ b/src/views/sharing/LinkSharingAuth.vue @@ -41,6 +41,7 @@ import {useTitle} from '@vueuse/core' import Message from '@/components/misc/message.vue' import {LOGO_VISIBLE} from '@/store/mutation-types' +import {LIST_VIEWS, type ListView} from '@/types/ListView' const {t} = useI18n({useScope: 'global'}) useTitle(t('sharing.authenticating')) @@ -80,13 +81,10 @@ function useAuth() { : true store.commit(LOGO_VISIBLE, logoVisible) - let view = 'list' - if (route.query.view && - (route.query.view === 'gantt' || - route.query.view === 'kanban' || - route.query.view === 'table')) { - view = route.query.view - } + const view = route.query.view && Object.values(LIST_VIEWS).includes(route.query.view as ListView) + ? route.query.view + : 'list' + router.push({name: `list.${view}`, params: {listId}}) } catch (e: any) { if (e.response?.data?.code === 13001) {