-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Knowledge workflow permission #4349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,11 +112,85 @@ const DocumentRouter = { | |
| permission: [ | ||
| () => { | ||
| const to: any = get_next_route() | ||
| if (to.params.type === '4') { | ||
| if (to.params.folderId == 'shared') { | ||
| return RoleConst.ADMIN | ||
| } else if (to.params.folderId == 'resource-management') { | ||
| } else { | ||
| return new ComplexPermission( | ||
| [RoleConst.USER], | ||
| [ | ||
| PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission( | ||
| to ? to.params.id : '', | ||
| ), | ||
| ], | ||
| [], | ||
| 'AND', | ||
| ) | ||
| } | ||
| }, | ||
| ], | ||
| () => { | ||
| const to: any = get_next_route() | ||
| if (to.params.folderId == 'shared') { | ||
| return RoleConst.ADMIN | ||
| } else if (to.params.folderId == 'resource-management') { | ||
| } else { | ||
| return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole() | ||
| } | ||
| }, | ||
| () => { | ||
| const to: any = get_next_route() | ||
| if (to.params.folderId == 'shared') { | ||
| return PermissionConst.SHARED_KNOWLEDGE_WORKFLOW_READ | ||
| } else if (to.params.folderId == 'resource-management') { | ||
| } else { | ||
| return PermissionConst.KNOWLEDGE_WORKFLOW_READ.getKnowledgeWorkspaceResourcePermission( | ||
| to ? to.params.id : '', | ||
| ) | ||
| } | ||
| }, | ||
| () => { | ||
| const to: any = get_next_route() | ||
| if (to.params.folderId == 'shared') { | ||
| return RoleConst.ADMIN | ||
| } else if (to.params.folderId == 'resource-management') { | ||
| } else { | ||
| return PermissionConst.KNOWLEDGE_WORKFLOW_READ.getWorkspacePermissionWorkspaceManageRole() | ||
| } | ||
| }, | ||
| () => { | ||
| const to: any = get_next_route() | ||
| if (to.params.folderId == 'share') { | ||
| return new ComplexPermission( | ||
| [RoleConst.EXTENDS_USER.getWorkspaceRole()], | ||
| [PermissionConst.KNOWLEDGE_WORKFLOW_READ.getWorkspacePermission()], | ||
| [], | ||
| 'AND', | ||
| ) | ||
| } | ||
| }, | ||
| () => { | ||
| const to: any = get_next_route() | ||
| if (to.params.folderId == 'share') { | ||
| return RoleConst.USER.getWorkspaceRole() | ||
| } | ||
| }, | ||
| () => { | ||
| const to: any = get_next_route() | ||
| if (to.params.folderId == 'resource-management') { | ||
| return RoleConst.ADMIN | ||
| } | ||
| }, | ||
| () => { | ||
| const to: any = get_next_route() | ||
| if (to.params.folderId == 'resource-management') { | ||
| return PermissionConst.RESOURCE_KNOWLEDGE_WORKFLOW_READ | ||
| } | ||
| }, | ||
| ].map(p => () => { | ||
| const to: any = get_next_route() | ||
| if (to.params.type !== '4') {return false} | ||
| return p() | ||
| }), | ||
| }, | ||
| redirect: (menu: any) => { | ||
| const from = 'workspace' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some potential issues with the provided React component code:
Optimization suggestions:
Here's an optimized version: const DocumentRouter = {
permission: [
(to) => {
if (to.params.type === '4') {
if (to.params.folderId === 'workspace-management') {
return new ComplexPermission([RoleConst.ADMIN], [], [], 'AND');
} else {
return RoleConst.WORKSPACE_MANAGE.getWorkspaceRole();
}
}
// Handle other types or folderIds appropriately
},
(to) => {
if (to.params.type === '4') {
return PermissionConst.KNOWLEDGE_WORKFLOW_READ.getKnowledgeWorkspaceResourcePermission(to.params.id);
}
<|fim_suffix|>n to.params.type.includes('document') && !to.params.extensionId;
};
DocumentRouter.redirect = ({ type }) => {
if (!['admin', 'editor'].includes(type)) return '/login';
};These improvements enhance readability, reduce redundancy, and handle various scenarios more efficiently. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,9 @@ const PermissionConst = { | |
| KNOWLEDGE_EXPORT: new Permission('KNOWLEDGE:READ+EXPORT'), | ||
| KNOWLEDGE_DELETE: new Permission('KNOWLEDGE:READ+DELETE'), | ||
| KNOWLEDGE_GENERATE: new Permission('KNOWLEDGE:READ+GENERATE'), | ||
|
|
||
| KNOWLEDGE_WORKFLOW_READ: new Permission('KNOWLEDGE_WORKFLOW:READ'), | ||
| KNOWLEDGE_WORKFLOW_EDIT: new Permission('KNOWLEDGE_WORKFLOW:READ+EDIT'), | ||
|
|
||
| KNOWLEDGE_DOCUMENT_READ: new Permission('KNOWLEDGE_DOCUMENT:READ'), | ||
| KNOWLEDGE_DOCUMENT_CREATE: new Permission('KNOWLEDGE_DOCUMENT:READ+CREATE'), | ||
|
|
@@ -190,6 +193,9 @@ const PermissionConst = { | |
| SHARED_KNOWLEDGE_EXPORT: new Permission('SYSTEM_KNOWLEDGE:READ+EXPORT'), | ||
| SHARED_KNOWLEDGE_GENERATE: new Permission('SYSTEM_KNOWLEDGE:READ+GENERATE'), | ||
| SHARED_KNOWLEDGE_DELETE: new Permission('SYSTEM_KNOWLEDGE:READ+DELETE'), | ||
|
|
||
| SHARED_KNOWLEDGE_WORKFLOW_READ: new Permission('SYSTEM_KNOWLEDGE_WORKFLOW:READ'), | ||
| SHARED_KNOWLEDGE_WORKFLOW_EDIT: new Permission('SYSTEM_KNOWLEDGE_WORKFLOW:READ+EDIT'), | ||
|
|
||
| SHARED_KNOWLEDGE_DOCUMENT_READ: new Permission('SYSTEM_KNOWLEDGE_DOCUMENT:READ'), | ||
| SHARED_KNOWLEDGE_DOCUMENT_CREATE: new Permission('SYSTEM_KNOWLEDGE_DOCUMENT:READ+CREATE'), | ||
|
|
@@ -243,6 +249,9 @@ const PermissionConst = { | |
| RESOURCE_KNOWLEDGE_EXPORT: new Permission('SYSTEM_RESOURCE_KNOWLEDGE:READ+EXPORT'), | ||
| RESOURCE_KNOWLEDGE_DELETE: new Permission('SYSTEM_RESOURCE_KNOWLEDGE:READ+DELETE'), | ||
| RESOURCE_KNOWLEDGE_GENERATE: new Permission('SYSTEM_RESOURCE_KNOWLEDGE:READ+GENERATE'), | ||
|
|
||
| RESOURCE_KNOWLEDGE_WORKFLOW_READ: new Permission('SYSTEM_RESOURCE_KNOWLEDGE_WORKFLOW:READ'), | ||
| RESOURCE_KNOWLEDGE_WORKFLOW_EDIT: new Permission('SYSTEM_RESOURCE_KNOWLEDGE_WORKFLOW:READ+EDIT'), | ||
|
|
||
| RESOURCE_KNOWLEDGE_DOCUMENT_READ: new Permission('SYSTEM_RESOURCE_KNOWLEDGE_DOCUMENT:READ'), | ||
| RESOURCE_KNOWLEDGE_DOCUMENT_CREATE: new Permission('SYSTEM_RESOURCE_KNOWLEDGE_DOCUMENT:READ+CREATE'), | ||
|
|
@@ -377,3 +386,4 @@ const EditionConst = { | |
| IS_CE: new Edition('X-PACK-CE'), | ||
| } | ||
| export {PermissionConst, RoleConst, EditionConst} | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current code appears to be adding two new permissions for knowledge workflow access: Here are a few points:
Overall, the addition of these permissions aligns with best practices for implementing robust access control mechanisms tailored to specific functionalities within an application. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no apparent issues with the provided code snippet. It seems to be correctly defining enumerations and permission constants based on different groups and their associated operations, roles, and resource permissions. A few notes:
The new
KNOWLEDGE_WORKFLOWgroup is added along with its respective permissions (READ,EDIT) for both workspace and system-level access.Similar additional entries have been created for workflow-related permissions in system-level knowledge resources and user/shared workspaces.
There might be redundancy in the list of
resource_permission_group_listsince some names like "KNOWLEDGE_MANGE" and "KNOWLEDGE_VIEW" are repeated, but this doesn't affect the functionality unless those specific values need customization.Overall, the structure looks clean and follows good naming conventions. If there's any further modification needed beyond these entries, please specify!