Make role options reactive
This commit is contained in:
parent
8a84a79651
commit
787d93e317
|
@ -17,6 +17,32 @@
|
||||||
|
|
||||||
const inheritedRoleId = "inherited"
|
const inheritedRoleId = "inherited"
|
||||||
|
|
||||||
|
let dependantsInfoMessage
|
||||||
|
|
||||||
|
$: loadDependantInfo(resourceId)
|
||||||
|
$: computedPermissions = Object.entries(permissions.permissions).reduce(
|
||||||
|
(p, [level, roleInfo]) => {
|
||||||
|
p[level] = {
|
||||||
|
selectedValue:
|
||||||
|
roleInfo.permissionType === PermissionSource.INHERITED
|
||||||
|
? inheritedRoleId
|
||||||
|
: roleInfo.role,
|
||||||
|
options: [...$roles],
|
||||||
|
}
|
||||||
|
if (roleInfo.inheritablePermission) {
|
||||||
|
p[level].inheritOption = roleInfo.inheritablePermission
|
||||||
|
p[level].options.unshift({
|
||||||
|
_id: inheritedRoleId,
|
||||||
|
name: `Inherit (${
|
||||||
|
get(roles).find(x => x._id === roleInfo.inheritablePermission).name
|
||||||
|
})`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
async function changePermission(level, role) {
|
async function changePermission(level, role) {
|
||||||
try {
|
try {
|
||||||
if (role === inheritedRoleId) {
|
if (role === inheritedRoleId) {
|
||||||
|
@ -41,36 +67,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: computedPermissions = Object.entries(permissions.permissions).reduce(
|
async function loadDependantInfo(resourceId) {
|
||||||
(p, [level, roleInfo]) => {
|
|
||||||
p[level] = {
|
|
||||||
selectedValue:
|
|
||||||
roleInfo.permissionType === PermissionSource.INHERITED
|
|
||||||
? inheritedRoleId
|
|
||||||
: roleInfo.role,
|
|
||||||
options: [...get(roles)],
|
|
||||||
}
|
|
||||||
|
|
||||||
if (roleInfo.inheritablePermission) {
|
|
||||||
p[level].inheritOption = roleInfo.inheritablePermission
|
|
||||||
p[level].options.unshift({
|
|
||||||
_id: inheritedRoleId,
|
|
||||||
name: `Inherit (${
|
|
||||||
get(roles).find(x => x._id === roleInfo.inheritablePermission).name
|
|
||||||
})`,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return p
|
|
||||||
},
|
|
||||||
{}
|
|
||||||
)
|
|
||||||
|
|
||||||
let dependantsInfoMessage
|
|
||||||
async function loadDependantInfo() {
|
|
||||||
const dependantsInfo = await permissionsStore.getDependantsInfo(resourceId)
|
const dependantsInfo = await permissionsStore.getDependantsInfo(resourceId)
|
||||||
|
|
||||||
const resourceByType = dependantsInfo?.resourceByType
|
const resourceByType = dependantsInfo?.resourceByType
|
||||||
|
|
||||||
if (resourceByType) {
|
if (resourceByType) {
|
||||||
const total = Object.values(resourceByType).reduce((p, c) => p + c, 0)
|
const total = Object.values(resourceByType).reduce((p, c) => p + c, 0)
|
||||||
let resourceDisplay =
|
let resourceDisplay =
|
||||||
|
@ -85,7 +84,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadDependantInfo()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Body size="S">Specify the minimum access level role for this data.</Body>
|
<Body size="S">Specify the minimum access level role for this data.</Body>
|
||||||
|
@ -122,11 +120,6 @@
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
grid-gap: var(--spacing-s);
|
grid-gap: var(--spacing-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.lock-tag {
|
|
||||||
padding-left: var(--spacing-s);
|
|
||||||
}
|
|
||||||
|
|
||||||
.inheriting-resources {
|
.inheriting-resources {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: var(--spacing-s);
|
gap: var(--spacing-s);
|
||||||
|
|
Loading…
Reference in New Issue