From 72f8492d7c81856d9df626679115a7775bfdf16c Mon Sep 17 00:00:00 2001 From: "marcel.kocisek" Date: Wed, 20 Dec 2023 15:10:57 +0100 Subject: [PATCH] Added: - alpha version of breadcrumps with configuration in router --- web-app/packages/app/src/App.vue | 4 +- web-app/packages/app/src/router.ts | 73 +++++++++++++------ .../packages/app/src/shims-vue-router.d.ts | 2 +- .../lib/src/common/components/AppSection.vue | 2 +- .../layout/components/AppBreadcrumbs.vue | 39 +++++++--- .../modules/layout/components/SideBarItem.vue | 8 +- .../layout/components/SideBarTemplate.vue | 10 +-- .../views/ProjectVersionsViewTemplate.vue | 34 ++++++++- .../views/ProjectsListViewTemplate.vue | 12 ++- .../packages/lib/src/shims-vue-router.d.ts | 2 +- 10 files changed, 133 insertions(+), 53 deletions(-) diff --git a/web-app/packages/app/src/App.vue b/web-app/packages/app/src/App.vue index 7db90208..11058bb7 100644 --- a/web-app/packages/app/src/App.vue +++ b/web-app/packages/app/src/App.vue @@ -134,6 +134,7 @@ export default defineComponent({ }) }, async created() { + this.init() await this.fetchConfig() if (this.loggedUser) { // here is loaded current workspace on startup (and reloaded in watcher when user has changed) @@ -161,7 +162,8 @@ export default defineComponent({ ...mapActions(useAppStore, ['setServerError']), ...mapActions(useInstanceStore, ['fetchPing', 'fetchConfig', 'initApp']), ...mapActions(useNotificationStore, { notificationError: 'error' }), - ...mapActions(useUserStore, ['checkCurrentWorkspace', 'updateLoggedUser']) + ...mapActions(useUserStore, ['checkCurrentWorkspace', 'updateLoggedUser']), + ...mapActions(useLayoutStore, ['init']) } }) diff --git a/web-app/packages/app/src/router.ts b/web-app/packages/app/src/router.ts index fb4670ce..a2286929 100644 --- a/web-app/packages/app/src/router.ts +++ b/web-app/packages/app/src/router.ts @@ -83,7 +83,7 @@ export const createRouter = (pinia: Pinia) => { sidebar: SideBar }, meta: { - title: 'Dashboard' + breadcrump: [{ title: 'Dashboard', path: '/dashboard' }] }, props: { default: true @@ -111,7 +111,11 @@ export const createRouter = (pinia: Pinia) => { props: { default: true }, - meta: { public: true, title: 'Projects' }, + meta: { + public: true, + title: 'Projects', + breadcrump: [{ title: 'Projects', path: '/projects' }] + }, children: [ { path: 'explore', @@ -154,9 +158,7 @@ export const createRouter = (pinia: Pinia) => { meta: { public: true }, beforeEnter: (to, from, next) => { next({ - path: `/projects/${to.params.namespace}/${ - to.params.projectName - }/history`, + path: `/projects/${to.params.namespace}/${to.params.projectName}/history`, query: { version_id: to.params.version_id } }) return @@ -174,7 +176,7 @@ export const createRouter = (pinia: Pinia) => { default: true }, meta: { - title: 'Projects' + breadcrump: [{ title: 'Projects', path: '/projects' }] }, redirect: { name: 'project-tree' }, @@ -203,25 +205,50 @@ export const createRouter = (pinia: Pinia) => { name: 'file-version-detail', component: FileVersionDetailView, props: true, - meta: { public: true } - } - ].map((child) => ({ - ...child, - beforeEnter: (to, from, next) => { - // added project name to matched route - to.matched = to.matched.map((route) => ({ - ...route, - meta: { - ...route.meta, - title: - route.name === to.name - ? (to.params.projectName as string) - : route.meta.title + meta: { public: true }, + // TODO: refactor to function in utils + beforeEnter(to, from, next) { + to.meta = { + ...to.meta, + breadcrump: [ + { + title: String(to.params.projectName), + path: '/projects/history' + }, + { + title: String(to.params.version_id), + path: `/projects/${to.params.namespace}/${to.params.projectName}/history/${to.params.version_id}` + }, + { + title: String(to.params.path), + path: to.fullPath + } + ] } - })) - next() + next() + } } - })) + ] + // Not apply for project version detail , which have own breadcrump + .map((child) => + child.name === 'file-version-detail' + ? child + : { + ...child, + beforeEnter: (to, from, next) => { + to.meta = { + ...to.meta, + breadcrump: [ + { + title: String(to.params.projectName), + path: to.fullPath + } + ] + } + next() + } + } + ) }, { path: '/:pathMatch(.*)*', diff --git a/web-app/packages/app/src/shims-vue-router.d.ts b/web-app/packages/app/src/shims-vue-router.d.ts index 0395864a..9cbc6fc4 100644 --- a/web-app/packages/app/src/shims-vue-router.d.ts +++ b/web-app/packages/app/src/shims-vue-router.d.ts @@ -4,6 +4,6 @@ declare module 'vue-router' { interface RouteMeta { public?: boolean allowedForNoWorkspace?: boolean - title?: string + breadcrump?: { title: string; path: string }[] } } diff --git a/web-app/packages/lib/src/common/components/AppSection.vue b/web-app/packages/lib/src/common/components/AppSection.vue index f15d06a5..6d146fec 100644 --- a/web-app/packages/lib/src/common/components/AppSection.vue +++ b/web-app/packages/lib/src/common/components/AppSection.vue @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial :class="[ ground ? 'surface-ground' - : 'surface-section border-round-2xl overflow-hidden' + : 'surface-section border-round-xl overflow-hidden' ]" >