stop matching on prodId in some cases

This commit is contained in:
Peter Clement 2022-07-21 11:43:50 +01:00
parent ea061e6ab1
commit 2d5dfcb9a2
6 changed files with 59 additions and 48 deletions

View File

@ -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)
)
}
}

View File

@ -176,10 +176,10 @@
>
<div class="title ">
<StatusLight
color={RoleUtils.getRoleColour(group.roles[app.prodId])}
color={RoleUtils.getRoleColour(group.roles[app.appId])}
/>
<div style="margin-left: var(--spacing-s);">
<Body size="XS">{group.roles[app.prodId]}</Body>
<Body size="XS">{group.roles[app.appId]}</Body>
</div>
</div>
</ListItem>

View File

@ -93,7 +93,7 @@
{/if}
</div>
{#if hasGroupsLicense}
{#if hasGroupsLicense && $groups.length}
<div class="groupTable">
{#each $groups as group}
<div>

View File

@ -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)
]}
/>
<Icon
@ -195,7 +196,7 @@
autoWidth
quiet
value={user.roles[
Object.keys(user.roles).find(x => x === app.prodId)
Object.keys(user.roles).find(x => x === app.appId)
]}
/>
<Icon

View File

@ -1096,12 +1096,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.1.17":
version "1.1.17"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.17.tgz#5102a6b457823735e4da71eb9bca8218a667f57b"
integrity sha512-SQQA3IvlD+ARMIXnAErFzOAzC67e9hM72qgZvOc3cqfBpvObSg1VnmNAuuG4GB0y3dm21ldLpCBQFzPH2Ylkkg==
"@budibase/backend-core@1.1.18-alpha.0":
version "1.1.18-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.18-alpha.0.tgz#1b946ceccb798f3641fa35f11b2dda3ae0239d7a"
integrity sha512-dpRmrcjs63tmljlfKZABhjV9E9GqmFaiCa7+wyobgB90TPfs3RVJD1lxk4R15jjTEUn/G518cK05+xZhTVi7TQ==
dependencies:
"@budibase/types" "^1.1.17"
"@budibase/types" "^1.1.18-alpha.0"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -1179,13 +1179,13 @@
svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0"
"@budibase/pro@1.1.17":
version "1.1.17"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.17.tgz#6d6493b4df1c796469c0925c9d7b83e5f12b7b92"
integrity sha512-k0tfmeTf1Hh6m9U17wpUqfC0U2XvwhIf1Bbh7cbk8c41esm8blO0LxRpQGCS49lM85bfMFJvAGDr3+BHkiN7HA==
"@budibase/pro@1.1.18-alpha.0":
version "1.1.18-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.18-alpha.0.tgz#b0e6c2bec10139373e3c02be7ed239adc34e53a9"
integrity sha512-zHdI1RjNqSAE4h4tSH3WCCtGSGc1QZuQ7zUf6MvhduhCSm06dLMUdgbXB5iMbUcorokeIONXvKFHfPZ2JsctSw==
dependencies:
"@budibase/backend-core" "1.1.17"
"@budibase/types" "1.1.17"
"@budibase/backend-core" "1.1.18-alpha.0"
"@budibase/types" "1.1.18-alpha.0"
node-fetch "^2.6.1"
"@budibase/standard-components@^0.9.139":
@ -1206,10 +1206,15 @@
svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0"
"@budibase/types@1.1.17", "@budibase/types@^1.1.17":
version "1.1.17"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.17.tgz#fa58e86f3858c04a8b79094193ff87ac57a499fe"
integrity sha512-3sTH3tjPd+NEk5CIN23bgwyGXXNYq/hwaxKMbYLKGr45K6m9WDZs6saWxJ2JwguNtKGB9RggzCVR/DFJH2zI1A==
"@budibase/types@1.1.18-alpha.0":
version "1.1.18-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.18-alpha.0.tgz#73fb24d304ea18e04605e22aafea41094ebeb10c"
integrity sha512-B/4PgNu/yxsUcrLZMafU5dxPrJ3G2N2ajUDOtOv2fIwNATZRMXEacYe8cpndKxKriIOE4A8zGKwpKO7rIPqHvA==
"@budibase/types@^1.1.18-alpha.0":
version "1.1.19"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.19.tgz#770b83f971e3e949a43b7d3564cbaed4462dd834"
integrity sha512-rFGe/RvcpV40CJ6Ng3RZSqj07GFAlzDyo116o/jQIskOew/SfBrIPaENEqk0wFPVL2pcZMpySXHNa86asqmUiw==
"@bull-board/api@3.7.0":
version "3.7.0"

View File

@ -291,12 +291,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.1.17":
version "1.1.17"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.17.tgz#5102a6b457823735e4da71eb9bca8218a667f57b"
integrity sha512-SQQA3IvlD+ARMIXnAErFzOAzC67e9hM72qgZvOc3cqfBpvObSg1VnmNAuuG4GB0y3dm21ldLpCBQFzPH2Ylkkg==
"@budibase/backend-core@1.1.18-alpha.0":
version "1.1.18-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.18-alpha.0.tgz#1b946ceccb798f3641fa35f11b2dda3ae0239d7a"
integrity sha512-dpRmrcjs63tmljlfKZABhjV9E9GqmFaiCa7+wyobgB90TPfs3RVJD1lxk4R15jjTEUn/G518cK05+xZhTVi7TQ==
dependencies:
"@budibase/types" "^1.1.17"
"@budibase/types" "^1.1.18-alpha.0"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -324,19 +324,24 @@
uuid "8.3.2"
zlib "1.0.5"
"@budibase/pro@1.1.17":
version "1.1.17"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.17.tgz#6d6493b4df1c796469c0925c9d7b83e5f12b7b92"
integrity sha512-k0tfmeTf1Hh6m9U17wpUqfC0U2XvwhIf1Bbh7cbk8c41esm8blO0LxRpQGCS49lM85bfMFJvAGDr3+BHkiN7HA==
"@budibase/pro@1.1.18-alpha.0":
version "1.1.18-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.18-alpha.0.tgz#b0e6c2bec10139373e3c02be7ed239adc34e53a9"
integrity sha512-zHdI1RjNqSAE4h4tSH3WCCtGSGc1QZuQ7zUf6MvhduhCSm06dLMUdgbXB5iMbUcorokeIONXvKFHfPZ2JsctSw==
dependencies:
"@budibase/backend-core" "1.1.17"
"@budibase/types" "1.1.17"
"@budibase/backend-core" "1.1.18-alpha.0"
"@budibase/types" "1.1.18-alpha.0"
node-fetch "^2.6.1"
"@budibase/types@1.1.17", "@budibase/types@^1.1.17":
version "1.1.17"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.17.tgz#fa58e86f3858c04a8b79094193ff87ac57a499fe"
integrity sha512-3sTH3tjPd+NEk5CIN23bgwyGXXNYq/hwaxKMbYLKGr45K6m9WDZs6saWxJ2JwguNtKGB9RggzCVR/DFJH2zI1A==
"@budibase/types@1.1.18-alpha.0":
version "1.1.18-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.18-alpha.0.tgz#73fb24d304ea18e04605e22aafea41094ebeb10c"
integrity sha512-B/4PgNu/yxsUcrLZMafU5dxPrJ3G2N2ajUDOtOv2fIwNATZRMXEacYe8cpndKxKriIOE4A8zGKwpKO7rIPqHvA==
"@budibase/types@^1.1.18-alpha.0":
version "1.1.19"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.19.tgz#770b83f971e3e949a43b7d3564cbaed4462dd834"
integrity sha512-rFGe/RvcpV40CJ6Ng3RZSqj07GFAlzDyo116o/jQIskOew/SfBrIPaENEqk0wFPVL2pcZMpySXHNa86asqmUiw==
"@cspotcode/source-map-consumer@0.8.0":
version "0.8.0"