From ef7148193183c203c19dbbb41cae225bf3e14f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 31 Oct 2020 19:33:05 +0100 Subject: [PATCH] Fixed Typings --- src/boot/login.ts | 16 ++++--- src/components/navigation/EssentialLink.vue | 28 +++++++++--- src/components/navigation/ShortCutLink.vue | 22 ++++++++- src/layouts/MainLayout.vue | 45 ++++++++----------- src/plugins/balance/pages/MainPage.vue | 12 +---- .../user/components/settings/Sessions.vue | 2 +- src/plugins/user/pages/MainPage.vue | 12 +---- 7 files changed, 74 insertions(+), 63 deletions(-) diff --git a/src/boot/login.ts b/src/boot/login.ts index 9e24f1b..a9c431f 100644 --- a/src/boot/login.ts +++ b/src/boot/login.ts @@ -27,13 +27,15 @@ export default boot>(({ router, store }) => { to.matched.every((record: RouteRecord) => { if (!('meta' in record) || !('permissions' in record.meta)) return true; - const test = record.meta.permissions.every((permission: string) => { - return permissions.includes( - permission - ); - }) - console.log('permissions', test) - return test + if (record.meta) { + if ((<{permissions: FG.Permission[]}>record.meta).permissions) { + return (<{permissions: FG.Permission[]}>record.meta).permissions.every((permission: string) => { + return permissions.includes( + permission + ); + }) + } + } }) ) { next(); diff --git a/src/components/navigation/EssentialLink.vue b/src/components/navigation/EssentialLink.vue index fe44dd0..601a75f 100644 --- a/src/components/navigation/EssentialLink.vue +++ b/src/components/navigation/EssentialLink.vue @@ -1,20 +1,22 @@ diff --git a/src/components/navigation/ShortCutLink.vue b/src/components/navigation/ShortCutLink.vue index 6a0a446..17a4af4 100644 --- a/src/components/navigation/ShortCutLink.vue +++ b/src/components/navigation/ShortCutLink.vue @@ -1,9 +1,11 @@ diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 58214b1..8142d39 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -14,7 +14,7 @@ - + Flaschengeist @@ -28,10 +28,10 @@ :key="'shortcut' + index" :link="shortcut.link" :icon="shortcut.icon" - v-if="hasPermissions(shortcut.permissions)" - /> + :permissions="shortcut.permissions" + /> - + @@ -51,10 +51,10 @@ :title="link.title" :link="link.link" :icon="link.icon" - v-if="hasPermissions(link.permissions)" + :permissions="link.permissions" /> - + @@ -65,7 +65,7 @@ :title="link.title" :link="link.link" :icon="link.icon" - v-if="hasPermissions(link.permissions)" + :permissions="link.permissions" /> @@ -81,7 +81,7 @@ /> - + - + @@ -102,11 +102,11 @@ diff --git a/src/plugins/user/components/settings/Sessions.vue b/src/plugins/user/components/settings/Sessions.vue index f8dc097..707847e 100644 --- a/src/plugins/user/components/settings/Sessions.vue +++ b/src/plugins/user/components/settings/Sessions.vue @@ -66,7 +66,7 @@ export default defineComponent({ ? 'mdi-linux' : platform == 'windows' ? 'mdi-microsoft-windows' - : platform == 'apple' + : platform == 'macos' ? 'mdi-apple' : 'mdi-help'; } diff --git a/src/plugins/user/pages/MainPage.vue b/src/plugins/user/pages/MainPage.vue index 2a9d6ba..1560720 100644 --- a/src/plugins/user/pages/MainPage.vue +++ b/src/plugins/user/pages/MainPage.vue @@ -13,7 +13,7 @@ :title="route.title" :icon="route.icon" :link="route.name" - v-if="hasPermissions(route.permissions)" + :permissions="route.meta.permissions" /> @@ -34,15 +34,7 @@ export default defineComponent({ const checkMain = computed(() => { return root.$route.matched.length == 2; }); - function hasPermissions(permissions: FG.Permission[] | undefined) { - if (permissions) { - return permissions.every(permission => { - return root.$store.getters['user/permissions'].includes(permission) - }) - } - return true - } - return { checkMain, mainRoutes, hasPermissions}; + return { checkMain, mainRoutes}; } });