From dd34282a338e6204f966457e943ea86ed9bb92bc Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Fri, 22 Jul 2022 10:56:16 +0100 Subject: [PATCH] 2nd fix for multi tenancy groups --- .../portal/overview/_components/AccessTab.svelte | 9 ++------- packages/builder/src/stores/portal/apps.js | 12 ++++++++++++ packages/server/src/utilities/global.js | 3 --- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte b/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte index 5ea9f2784e..fe93b087cd 100644 --- a/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte +++ b/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte @@ -35,13 +35,8 @@ Constants.Features.USER_GROUPS ) - $: { - if (!app.tenantId) { - fixedAppId = `app_${app.appId}` - } else { - fixedAppId = `app_${app.tenantId}_${app.appId}` - } - } + $: fixedAppId = apps.getProdAppID(app.devId) + $: appUsers = $users.data?.filter(x => { return Object.keys(x.roles).find(y => { diff --git a/packages/builder/src/stores/portal/apps.js b/packages/builder/src/stores/portal/apps.js index 7d5f299077..6323046eef 100644 --- a/packages/builder/src/stores/portal/apps.js +++ b/packages/builder/src/stores/portal/apps.js @@ -7,6 +7,17 @@ const extractAppId = id => { return split.length ? split[split.length - 1] : null } +const getProdAppID = appId => { + if (!appId || !appId.startsWith("app_dev")) { + return appId + } + // split to take off the app_dev element, then join it together incase any other app_ exist + const split = appId.split("app_dev") + split.shift() + const rest = split.join("app_dev") + return `${"app"}${rest}` +} + export function createAppStore() { const store = writable([]) @@ -79,6 +90,7 @@ export function createAppStore() { load, update, extractAppId, + getProdAppID, } } diff --git a/packages/server/src/utilities/global.js b/packages/server/src/utilities/global.js index 17b1f26eaf..81c64b9cde 100644 --- a/packages/server/src/utilities/global.js +++ b/packages/server/src/utilities/global.js @@ -15,7 +15,6 @@ const { getAppId } = require("@budibase/backend-core/context") const { groups } = require("@budibase/pro") exports.updateAppRole = async (user, { appId } = {}) => { - console.log(appId) appId = appId || getAppId() if (!user || !user.roles) { return user @@ -38,8 +37,6 @@ exports.updateAppRole = async (user, { appId } = {}) => { let roleId = await groups.getGroupRoleId(user, appId) user.roleId = roleId } - console.log(user.roleId) - delete user.roles return user }