Allow developer users to access users, groups and usage pages

This commit is contained in:
Andrew Kingston 2023-01-13 08:28:54 +00:00
parent 1d9ab4163f
commit e23f7dde47
1 changed files with 29 additions and 46 deletions

View File

@ -4,20 +4,6 @@ import { admin } from "./admin"
import { auth } from "./auth" import { auth } from "./auth"
export const menu = derived([admin, auth], ([$admin, $auth]) => { export const menu = derived([admin, auth], ([$admin, $auth]) => {
// Standard user and developer pages
let menu = [
{
title: "Apps",
href: "/builder/portal/apps",
},
{
title: "Plugins",
href: "/builder/portal/plugins",
},
]
// Admin only pages
if ($auth.isAdmin) {
// Determine user sub pages // Determine user sub pages
let userSubPages = [ let userSubPages = [
{ {
@ -32,7 +18,25 @@ export const menu = derived([admin, auth], ([$admin, $auth]) => {
}) })
} }
// Determine settings sub pages // Pages that all devs and admins can access
let menu = [
{
title: "Apps",
href: "/builder/portal/apps",
},
{
title: "Users",
href: "/builder/portal/users",
subPages: userSubPages,
},
{
title: "Plugins",
href: "/builder/portal/plugins",
},
]
// Add settings page for admins
if ($auth.isAdmin) {
let settingsSubPages = [ let settingsSubPages = [
{ {
title: "Auth", title: "Auth",
@ -53,35 +57,15 @@ export const menu = derived([admin, auth], ([$admin, $auth]) => {
href: "/builder/portal/settings/version", href: "/builder/portal/settings/version",
}) })
} }
menu.push({
menu = [
{
title: "Apps",
href: "/builder/portal/apps",
},
{
title: "Users",
href: "/builder/portal/users",
subPages: userSubPages,
},
{
title: "Plugins",
href: "/builder/portal/plugins",
},
{
title: "Settings", title: "Settings",
href: "/builder/portal/settings", href: "/builder/portal/settings",
subPages: settingsSubPages, subPages: settingsSubPages,
}, })
]
} }
// Check if allowed access to account section // Add account page
if ( if (isEnabled(TENANT_FEATURE_FLAGS.LICENSING)) {
isEnabled(TENANT_FEATURE_FLAGS.LICENSING) &&
($auth?.user?.accountPortalAccess || (!$admin.cloud && $auth.isAdmin))
) {
// Determine account sub pages
let accountSubPages = [ let accountSubPages = [
{ {
title: "Usage", title: "Usage",
@ -93,7 +77,7 @@ export const menu = derived([admin, auth], ([$admin, $auth]) => {
title: "Upgrade", title: "Upgrade",
href: $admin.accountPortalUrl + "/portal/upgrade", href: $admin.accountPortalUrl + "/portal/upgrade",
}) })
} else if (!$admin.cloud && admin) { } else if (!$admin.cloud && $auth.isAdmin) {
accountSubPages.push({ accountSubPages.push({
title: "Upgrade", title: "Upgrade",
href: "/builder/portal/account/upgrade", href: "/builder/portal/account/upgrade",
@ -108,7 +92,6 @@ export const menu = derived([admin, auth], ([$admin, $auth]) => {
href: $admin.accountPortalUrl + "/portal/billing", href: $admin.accountPortalUrl + "/portal/billing",
}) })
} }
menu.push({ menu.push({
title: "Account", title: "Account",
href: "/builder/portal/account", href: "/builder/portal/account",