Adding groups to user app list.

This commit is contained in:
mike12345567 2025-02-27 17:12:20 +00:00
parent 33b8751d78
commit 4f697b7731
4 changed files with 32 additions and 16 deletions

View File

@ -971,7 +971,8 @@
width: 100%; width: 100%;
} }
.auth-entity .user-email, .group-name { .auth-entity .user-email,
.group-name {
flex: 1 1 0; flex: 1 1 0;
min-width: 0; min-width: 0;
overflow: hidden; overflow: hidden;

View File

@ -98,7 +98,9 @@
$: privileged = sdk.users.isAdminOrGlobalBuilder(user) $: privileged = sdk.users.isAdminOrGlobalBuilder(user)
$: nameLabel = getNameLabel(user) $: nameLabel = getNameLabel(user)
$: filteredGroups = getFilteredGroups(internalGroups, searchTerm) $: filteredGroups = getFilteredGroups(internalGroups, searchTerm)
$: availableApps = getAvailableApps($appsStore.apps, privileged, user?.roles) $: availableApps = user
? getApps(user, sdk.users.userAppAccessList(user, $groups || []))
: []
$: userGroups = $groups.filter(x => { $: userGroups = $groups.filter(x => {
return x.users?.find(y => { return x.users?.find(y => {
return y._id === userId return y._id === userId
@ -107,23 +109,19 @@
$: globalRole = users.getUserRole(user) $: globalRole = users.getUserRole(user)
$: isTenantOwner = tenantOwner?.email && tenantOwner.email === user?.email $: isTenantOwner = tenantOwner?.email && tenantOwner.email === user?.email
const getAvailableApps = (appList, privileged, roles) => { const getApps = (user, appIds) => {
let availableApps = appList.slice() let availableApps = $appsStore.apps
if (!privileged) { .slice()
availableApps = availableApps.filter(x => { .filter(app =>
let roleKeys = Object.keys(roles || {}) appIds.find(id => id === appsStore.getProdAppID(app.devId))
return roleKeys.concat(user?.builder?.apps).find(y => { )
return x.appId === appsStore.extractAppId(y)
})
})
}
return availableApps.map(app => { return availableApps.map(app => {
const prodAppId = appsStore.getProdAppID(app.devId) const prodAppId = appsStore.getProdAppID(app.devId)
return { return {
name: app.name, name: app.name,
devId: app.devId, devId: app.devId,
icon: app.icon, icon: app.icon,
role: getRole(prodAppId, roles), role: getRole(prodAppId, user),
} }
}) })
} }
@ -136,7 +134,7 @@
return groups.filter(group => group.name?.toLowerCase().includes(search)) return groups.filter(group => group.name?.toLowerCase().includes(search))
} }
const getRole = (prodAppId, roles) => { const getRole = (prodAppId, user) => {
if (privileged) { if (privileged) {
return Constants.Roles.ADMIN return Constants.Roles.ADMIN
} }
@ -145,7 +143,21 @@
return Constants.Roles.CREATOR return Constants.Roles.CREATOR
} }
return roles[prodAppId] if (user?.roles[prodAppId]) {
return user.roles[prodAppId]
}
// check if access via group for creator
const foundGroup = $groups?.find(
group => group.roles[prodAppId] || group.builder?.apps[prodAppId]
)
if (foundGroup.builder?.apps[prodAppId]) {
return Constants.Roles.CREATOR
}
// can't tell how groups will control role
if (foundGroup.roles[prodAppId]) {
return Constants.Roles.GROUP
}
} }
const getNameLabel = user => { const getNameLabel = user => {

View File

@ -15,7 +15,9 @@
} }
</script> </script>
{#if value === Constants.Roles.CREATOR} {#if value === Constants.Roles.GROUP}
Controlled by group
{:else if value === Constants.Roles.CREATOR}
Can edit Can edit
{:else} {:else}
<StatusLight <StatusLight

View File

@ -106,6 +106,7 @@ export const Roles = {
PUBLIC: "PUBLIC", PUBLIC: "PUBLIC",
BUILDER: "BUILDER", BUILDER: "BUILDER",
CREATOR: "CREATOR", CREATOR: "CREATOR",
GROUP: "GROUP",
} }
export const EventPublishType = { export const EventPublishType = {