Updating group types to accurately reflect the state of the documents, as well as centralising the logic for getting the app IDs in a group.
This commit is contained in:
parent
6247f686e8
commit
25b8f0ca3b
|
@ -52,7 +52,8 @@
|
||||||
? publishedApps
|
? publishedApps
|
||||||
: publishedApps.filter(app => {
|
: publishedApps.filter(app => {
|
||||||
return userGroups.find(group => {
|
return userGroups.find(group => {
|
||||||
return Object.keys(group.roles)
|
return groups.actions
|
||||||
|
.getGroupApps(group)
|
||||||
.map(role => apps.extractAppId(role))
|
.map(role => apps.extractAppId(role))
|
||||||
.includes(app.appId)
|
.includes(app.appId)
|
||||||
})
|
})
|
||||||
|
|
|
@ -41,7 +41,9 @@
|
||||||
$: fetchUsers(page, searchTerm)
|
$: fetchUsers(page, searchTerm)
|
||||||
$: group = $groups.find(x => x._id === groupId)
|
$: group = $groups.find(x => x._id === groupId)
|
||||||
$: filtered = $users.data
|
$: filtered = $users.data
|
||||||
$: groupApps = $apps.filter(app => group?.roles?.includes(app.appId))
|
$: groupApps = $apps.filter(app =>
|
||||||
|
groups.actions.getGroupApps(group).includes(app.appId)
|
||||||
|
)
|
||||||
$: {
|
$: {
|
||||||
if (loaded && !group?._id) {
|
if (loaded && !group?._id) {
|
||||||
$goto("./")
|
$goto("./")
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
if (!group.roles) {
|
if (!group.roles) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return Object.keys(group.roles).includes(fixedAppId)
|
return groups.actions.getGroupApps(group).includes(fixedAppId)
|
||||||
})
|
})
|
||||||
|
|
||||||
async function removeUser(user) {
|
async function removeUser(user) {
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
autoWidth
|
autoWidth
|
||||||
quiet
|
quiet
|
||||||
value={group.roles[
|
value={group.roles[
|
||||||
Object.keys(group.roles).find(x => x === fixedAppId)
|
groups.actions.getGroupApps(group).find(x => x === fixedAppId)
|
||||||
]}
|
]}
|
||||||
allowPublic={false}
|
allowPublic={false}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
search = search?.toLowerCase()
|
search = search?.toLowerCase()
|
||||||
return (allGroups || []).filter(group => {
|
return (allGroups || []).filter(group => {
|
||||||
// Filter out assigned groups
|
// Filter out assigned groups
|
||||||
const appIds = Object.keys(group.roles || {})
|
const appIds = groups.actions.getGroupApps(group)
|
||||||
if (appIds.includes(appId)) {
|
if (appIds.includes(appId)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,10 @@ export function createGroupsStore() {
|
||||||
// refresh the group roles
|
// refresh the group roles
|
||||||
await getGroup(groupId)
|
await getGroup(groupId)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getGroupApps: group => {
|
||||||
|
return Object.keys(group?.roles || {})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -4,9 +4,8 @@ export interface UserGroup extends Document {
|
||||||
name: string
|
name: string
|
||||||
icon: string
|
icon: string
|
||||||
color: string
|
color: string
|
||||||
users: GroupUser[]
|
users?: GroupUser[]
|
||||||
apps: string[]
|
roles?: UserGroupRoles
|
||||||
roles: UserGroupRoles
|
|
||||||
createdAt?: number
|
createdAt?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue