Merge pull request #11939 from Budibase/fix/client-initialisation
Fix client initialisation and fix navigation links being hidden
This commit is contained in:
commit
b2ea82b8ba
|
@ -3,6 +3,7 @@
|
||||||
import { writable } from "svelte/store"
|
import { writable } from "svelte/store"
|
||||||
import { Heading, Icon, clickOutside } from "@budibase/bbui"
|
import { Heading, Icon, clickOutside } from "@budibase/bbui"
|
||||||
import { FieldTypes } from "constants"
|
import { FieldTypes } from "constants"
|
||||||
|
import { Constants } from "@budibase/frontend-core"
|
||||||
import active from "svelte-spa-router/active"
|
import active from "svelte-spa-router/active"
|
||||||
|
|
||||||
const sdk = getContext("sdk")
|
const sdk = getContext("sdk")
|
||||||
|
@ -103,7 +104,8 @@
|
||||||
let validLinks = (allLinks || []).filter(link => link.text && link.url)
|
let validLinks = (allLinks || []).filter(link => link.text && link.url)
|
||||||
// Filter to only links allowed by the current role
|
// Filter to only links allowed by the current role
|
||||||
return validLinks.filter(link => {
|
return validLinks.filter(link => {
|
||||||
return userRoleHierarchy?.find(roleId => roleId === link.roleId)
|
const role = link.roleId || Constants.Roles.BASIC
|
||||||
|
return userRoleHierarchy?.find(roleId => roleId === role)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
value: roleId,
|
value: roleId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
devToolsStore.actions.changeRole(SELF_ROLE)
|
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { createLocalStorageStore } from "@budibase/frontend-core"
|
||||||
import { initialise } from "./initialise"
|
import { initialise } from "./initialise"
|
||||||
import { authStore } from "./auth"
|
import { authStore } from "./auth"
|
||||||
import { API } from "../api"
|
import { API } from "../api"
|
||||||
|
import { get } from "svelte/store"
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -27,9 +28,15 @@ const createDevToolStore = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeRole = async role => {
|
const changeRole = async role => {
|
||||||
|
if (role === "self") {
|
||||||
|
role = null
|
||||||
|
}
|
||||||
|
if (role === get(store).role) {
|
||||||
|
return
|
||||||
|
}
|
||||||
store.update(state => ({
|
store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
role: role === "self" ? null : role,
|
role,
|
||||||
}))
|
}))
|
||||||
API.invalidateCache()
|
API.invalidateCache()
|
||||||
await authStore.actions.fetchUser()
|
await authStore.actions.fetchUser()
|
||||||
|
|
Loading…
Reference in New Issue