From afd0936fd79367ee21315e63187fbfeb0ae938fa Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 24 May 2021 12:44:59 +0100 Subject: [PATCH] Remove admin only pages from non-admin menu --- .../src/pages/builder/portal/_layout.svelte | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/_layout.svelte b/packages/builder/src/pages/builder/portal/_layout.svelte index fb488c58d7..9dc4e19b6a 100644 --- a/packages/builder/src/pages/builder/portal/_layout.svelte +++ b/packages/builder/src/pages/builder/portal/_layout.svelte @@ -20,18 +20,40 @@ let userInfoModal let changePasswordModal - const menu = [ - { title: "Apps", href: "/builder/portal/apps" }, - { title: "Users", href: "/builder/portal/manage/users", heading: "Manage" }, - { title: "Auth", href: "/builder/portal/manage/auth" }, - { title: "Email", href: "/builder/portal/manage/email" }, - { - title: "Organisation", - href: "/builder/portal/settings/organisation", - heading: "Settings", - }, - { title: "Theming", href: "/builder/portal/settings/theming" }, - ] + $: menu = buildMenu($auth.isAdmin) + + const buildMenu = admin => { + let menu = [{ title: "Apps", href: "/builder/portal/apps" }] + if (admin) { + menu = menu.concat([ + { + title: "Users", + href: "/builder/portal/manage/users", + heading: "Manage", + }, + { title: "Auth", href: "/builder/portal/manage/auth" }, + { title: "Email", href: "/builder/portal/manage/email" }, + { + title: "Organisation", + href: "/builder/portal/settings/organisation", + heading: "Settings", + }, + { + title: "Theming", + href: "/builder/portal/settings/theming", + }, + ]) + } else { + menu = menu.concat([ + { + title: "Theming", + href: "/builder/portal/settings/theming", + heading: "Settings", + }, + ]) + } + return menu + } onMount(async () => { // Prevent non-builders from accessing the portal