From 986069d7d7b9167c3155b5b2f4bd66b56afefb69 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 2 Oct 2023 08:19:59 +0100 Subject: [PATCH 1/3] Fix issue causing client apps to initialise 3 times --- .../client/src/components/devtools/DevToolsHeader.svelte | 1 - packages/client/src/stores/devTools.js | 9 ++++++++- packages/client/src/stores/initialise.js | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/devtools/DevToolsHeader.svelte b/packages/client/src/components/devtools/DevToolsHeader.svelte index a15e8351a5..55b705e717 100644 --- a/packages/client/src/components/devtools/DevToolsHeader.svelte +++ b/packages/client/src/components/devtools/DevToolsHeader.svelte @@ -25,7 +25,6 @@ value: roleId, }) } - devToolsStore.actions.changeRole(SELF_ROLE) return list } diff --git a/packages/client/src/stores/devTools.js b/packages/client/src/stores/devTools.js index 32f3c8e617..db9b9e10b4 100644 --- a/packages/client/src/stores/devTools.js +++ b/packages/client/src/stores/devTools.js @@ -2,6 +2,7 @@ import { createLocalStorageStore } from "@budibase/frontend-core" import { initialise } from "./initialise" import { authStore } from "./auth" import { API } from "../api" +import { get } from "svelte/store" const initialState = { visible: false, @@ -27,9 +28,15 @@ const createDevToolStore = () => { } const changeRole = async role => { + if (role === "self") { + role = null + } + if (role === get(store).role) { + return + } store.update(state => ({ ...state, - role: role === "self" ? null : role, + role, })) API.invalidateCache() await authStore.actions.fetchUser() diff --git a/packages/client/src/stores/initialise.js b/packages/client/src/stores/initialise.js index f34d775a4e..86c761367c 100644 --- a/packages/client/src/stores/initialise.js +++ b/packages/client/src/stores/initialise.js @@ -3,6 +3,7 @@ import { appStore } from "./app" import { orgStore } from "./org" export async function initialise() { + console.log("initialise!") await routeStore.actions.fetchRoutes() await appStore.actions.fetchAppDefinition() await orgStore.actions.init() From bdd70d8bdbc83e60abf2852d9b752b696fddc6dc Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 2 Oct 2023 08:26:47 +0100 Subject: [PATCH 2/3] Fix regression when considering empty app navigation roles --- packages/client/src/components/app/Layout.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/app/Layout.svelte b/packages/client/src/components/app/Layout.svelte index e482e6b336..bdab0dd9ab 100644 --- a/packages/client/src/components/app/Layout.svelte +++ b/packages/client/src/components/app/Layout.svelte @@ -3,6 +3,7 @@ import { writable } from "svelte/store" import { Heading, Icon, clickOutside } from "@budibase/bbui" import { FieldTypes } from "constants" + import { Constants } from "@budibase/frontend-core" import active from "svelte-spa-router/active" const sdk = getContext("sdk") @@ -103,7 +104,8 @@ let validLinks = (allLinks || []).filter(link => link.text && link.url) // Filter to only links allowed by the current role return validLinks.filter(link => { - return userRoleHierarchy?.find(roleId => roleId === link.roleId) + const role = link.roleId || Constants.Roles.BASIC + return userRoleHierarchy?.find(roleId => roleId === role) }) } From 6b904dd01ad43dad71673b4dc96a10768d3a05f8 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 2 Oct 2023 08:27:28 +0100 Subject: [PATCH 3/3] Remove log --- packages/client/src/stores/initialise.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/client/src/stores/initialise.js b/packages/client/src/stores/initialise.js index 86c761367c..f34d775a4e 100644 --- a/packages/client/src/stores/initialise.js +++ b/packages/client/src/stores/initialise.js @@ -3,7 +3,6 @@ import { appStore } from "./app" import { orgStore } from "./org" export async function initialise() { - console.log("initialise!") await routeStore.actions.fetchRoutes() await appStore.actions.fetchAppDefinition() await orgStore.actions.init()