Skip to content

Commit

Permalink
Maintenance: Desktop - Add support for navigation menu guards.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvuckovic committed Apr 23, 2024
1 parent c394b6f commit edf42ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Expand Up @@ -27,9 +27,15 @@ const permittedEntries = computed(() => {
props.entries,
(memo, entries, category) => {
memo[category] = entries.filter((entry) => {
if (!entry.route.meta?.requiredPermission) return true
if (
entry.route.meta?.requiredPermission &&
!session.hasPermission(entry.route.meta.requiredPermission)
)
return false
return session.hasPermission(entry.route.meta.requiredPermission)
if (typeof entry.show === 'function') return entry.show()
return true
})
},
{} as Record<string, NavigationMenuEntry[]>,
Expand Down
Expand Up @@ -15,4 +15,5 @@ export type NavigationMenuEntry = {
icon?: string
keywords?: string
route: RouteRecordRaw & { name: string }
show?: () => boolean
}
Expand Up @@ -10,4 +10,5 @@ export interface PersonalSettingPlugin {
route: RouteRecordRaw & { name: string }
order: number
keywords: string
show?: () => boolean
}

0 comments on commit edf42ad

Please sign in to comment.