|
|
|
@ -2,10 +2,12 @@ |
|
|
|
import { getContext, setContext } from "svelte" |
|
|
|
import { writable } from "svelte/store" |
|
|
|
import { Heading, Icon } from "@budibase/bbui" |
|
|
|
import { FieldTypes } from "../../constants" |
|
|
|
import { FieldTypes } from "constants" |
|
|
|
import active from "svelte-spa-router/active" |
|
|
|
import { RoleUtils } from "@budibase/frontend-core" |
|
|
|
|
|
|
|
const { routeStore, styleable, linkable, builderStore } = getContext("sdk") |
|
|
|
const sdk = getContext("sdk") |
|
|
|
const { routeStore, styleable, linkable, builderStore, currentRole } = sdk |
|
|
|
const component = getContext("component") |
|
|
|
const context = getContext("context") |
|
|
|
|
|
|
|
@ -50,7 +52,7 @@ |
|
|
|
}) |
|
|
|
setContext("layout", store) |
|
|
|
|
|
|
|
$: validLinks = links?.filter(link => link.text && link.url) || [] |
|
|
|
$: validLinks = getValidLinks(links, $currentRole) |
|
|
|
$: typeClass = NavigationClasses[navigation] || NavigationClasses.None |
|
|
|
$: navWidthClass = WidthClasses[navWidth || width] || WidthClasses.Large |
|
|
|
$: pageWidthClass = WidthClasses[pageWidth || width] || WidthClasses.Large |
|
|
|
@ -79,6 +81,17 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const getValidLinks = (allLinks, role) => { |
|
|
|
// Strip links missing required info |
|
|
|
let validLinks = (allLinks || []).filter(link => link.text && link.url) |
|
|
|
|
|
|
|
// Filter to only links allowed by the current role |
|
|
|
const priority = RoleUtils.getRolePriority(role) |
|
|
|
return validLinks.filter(link => { |
|
|
|
return !link.roleId || RoleUtils.getRolePriority(link.roleId) <= priority |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const isInternal = url => { |
|
|
|
return url.startsWith("/") |
|
|
|
} |
|
|
|
|