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%;
}
.auth-entity .user-email, .group-name {
.auth-entity .user-email,
.group-name {
flex: 1 1 0;
min-width: 0;
overflow: hidden;

View File

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

View File

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

View File

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