From 2d5dfcb9a2535012d9adf0222f7da1554a03fdfd Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 21 Jul 2022 11:43:50 +0100 Subject: [PATCH] stop matching on prodId in some cases --- .../src/pages/builder/apps/index.svelte | 4 +-- .../portal/manage/groups/[groupId].svelte | 4 +-- .../builder/portal/manage/groups/index.svelte | 2 +- .../overview/_components/AccessTab.svelte | 27 +++++++------- packages/server/yarn.lock | 35 +++++++++++-------- packages/worker/yarn.lock | 35 +++++++++++-------- 6 files changed, 59 insertions(+), 48 deletions(-) diff --git a/packages/builder/src/pages/builder/apps/index.svelte b/packages/builder/src/pages/builder/apps/index.svelte index ab7a688e94..6c18e229b5 100644 --- a/packages/builder/src/pages/builder/apps/index.svelte +++ b/packages/builder/src/pages/builder/apps/index.svelte @@ -50,14 +50,14 @@ ? publishedApps : publishedApps.filter(app => { return userGroups.find(group => { - return Object.keys(group.roles).includes(app.prodId) + return Object.keys(group.roles).includes(app.appId) }) }) } else { userApps = $auth.user?.builder?.global ? publishedApps : publishedApps.filter(app => - Object.keys($auth.user?.roles).includes(app.prodId) + Object.keys($auth.user?.roles).includes(app.appId) ) } } diff --git a/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte b/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte index 75936f5bf6..bbb7e1491d 100644 --- a/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte +++ b/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte @@ -176,10 +176,10 @@ >
- {group.roles[app.prodId]} + {group.roles[app.appId]}
diff --git a/packages/builder/src/pages/builder/portal/manage/groups/index.svelte b/packages/builder/src/pages/builder/portal/manage/groups/index.svelte index e334fe4307..131906529d 100644 --- a/packages/builder/src/pages/builder/portal/manage/groups/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/groups/index.svelte @@ -93,7 +93,7 @@ {/if} - {#if hasGroupsLicense} + {#if hasGroupsLicense && $groups.length}
{#each $groups as group}
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 66515ba323..4181574e6d 100644 --- a/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte +++ b/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte @@ -21,6 +21,7 @@ import { roles } from "stores/backend" export let app + $: console.log(app._id) let assignmentModal let appGroups = [] let appUsers = [] @@ -38,7 +39,7 @@ $: appUsers = $users.data?.filter(x => { return Object.keys(x.roles).find(y => { - return y === app.prodId + return y === app.appId }) }) || [] @@ -57,7 +58,7 @@ return group._id === data.id }) matchedGroup.apps.push(app) - matchedGroup.roles[app.prodId] = data.role + matchedGroup.roles[app.appId] = data.role groups.actions.save(matchedGroup) } else if (data.id.startsWith(us_prefix)) { @@ -67,27 +68,27 @@ let newUser = { ...matchedUser, - roles: { [app.prodId]: data.role, ...matchedUser.roles }, + roles: { [app.appId]: data.role, ...matchedUser.roles }, } await users.save(newUser) } }) await groups.actions.init() - await users.search({ page, appId: app.prodId }) + await users.search({ page, appId: app.appId }) } async function removeUser(user) { // Remove the user role const filteredRoles = { ...user.roles } - delete filteredRoles[app?.prodId] + delete filteredRoles[app?.appId] await users.save({ ...user, roles: { ...filteredRoles, }, }) - await users.search({ page, appId: app.prodId }) + await users.search({ page, appId: app.appId }) } async function removeGroup(group) { @@ -95,7 +96,7 @@ let filteredApps = group.apps.filter(x => x.appId !== app.appId) const filteredRoles = { ...group.roles } - delete filteredRoles[app?.prodId] + delete filteredRoles[app?.appId] await groups.actions.save({ ...group, @@ -103,16 +104,16 @@ roles: { ...filteredRoles }, }) - await users.search({ page, appId: app.prodId }) + await users.search({ page, appId: app.appId }) } async function updateUserRole(role, user) { - user.roles[app.prodId] = role + user.roles[app.appId] = role users.save(user) } async function updateGroupRole(role, group) { - group.roles[app.prodId] = role + group.roles[app.appId] = role groups.actions.save(group) } @@ -128,7 +129,7 @@ prevSearch = search try { pageInfo.loading() - await users.search({ page, appId: app.prodId }) + await users.search({ page, appId: app.appId }) pageInfo.fetched($users.hasNextPage, $users.nextPage) } catch (error) { notifications.error("Error getting user list") @@ -173,7 +174,7 @@ autoWidth quiet value={group.roles[ - Object.keys(group.roles).find(x => x === app.prodId) + Object.keys(group.roles).find(x => x === app.appId) ]} /> x === app.prodId) + Object.keys(user.roles).find(x => x === app.appId) ]} />