Skip to content

Commit 536588a

Browse files
committed
fix: Resource authorization Sub-resource authorization Parent directory cascading authorization
1 parent 2ecdb66 commit 536588a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

ui/src/views/system/resource-authorization/component/PermissionTable.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ const select = (val: any[], active: any) => {
319319
selectObj[active.id] = 0
320320
}
321321
if (selectObj[active.id] % 2 == 0) {
322-
console.log(TreeToFlatten([active]))
323322
TreeToFlatten([active])
324323
.filter((item: any) => item.id != active.id)
325324
.forEach((item: any) => {
@@ -371,6 +370,27 @@ function submitPermissions(value: string, row: any) {
371370
permission: value,
372371
},
373372
]
373+
const emitSubmitPermissions = (treeData: any[], ids: Array<string>, result: Array<any>) => {
374+
if (!treeData || treeData.length === 0) return []
375+
for (const node of treeData) {
376+
const isRecursion = node.permission == 'NOT_AUTH' && ids.includes(node.id)
377+
if (node.children && node.children.length > 0 && !isRecursion) {
378+
emitSubmitPermissions(node.children, ids, result)
379+
}
380+
const isMatch = node.permission == 'NOT_AUTH' && ids.includes(node.id)
381+
if (isMatch) {
382+
ids.push(node.folder_id)
383+
result.push({
384+
target_id: node.id,
385+
permission: 'VIEW',
386+
})
387+
}
388+
}
389+
return result
390+
}
391+
if (['VIEW', 'MANAGE', 'ROLE'].includes(value)) {
392+
emitSubmitPermissions(props.data, [row.folder_id], obj)
393+
}
374394
emit('submitPermissions', obj)
375395
}
376396
const provider_list = ref<Array<Provider>>([])

0 commit comments

Comments
 (0)