-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Replace source file permission #4227
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 |
|---|---|---|
|
|
@@ -141,6 +141,14 @@ const share = { | |
| ], | ||
| 'OR' | ||
| ), | ||
| doc_replace: () => | ||
| hasPermission ( | ||
| [ | ||
| RoleConst.ADMIN, | ||
| PermissionConst.SHARED_KNOWLEDGE_DOCUMENT_REPLACE | ||
| ], | ||
| 'OR' | ||
| ), | ||
| problem_create: () => | ||
| hasPermission ( | ||
| [ | ||
|
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 const share = {
// Other existing functions...
docReplace() {
return hasPermission([RoleConst.ADMIN, PermissionConst.SHARED_KNOWLEDGE_DOCUMENT_REPLACE], 'OR');
},
};This approach is generally cleaner and more concise. No other potential issues or irregularities were found with the provided code snippet. Regarding future optimizations for handling shared knowledge documents replace permissions, you might consider implementing caching strategies if performance becomes an issue, especially if this method is called frequently throughout your application. Additionally, ensure that all necessary data access controls (like role checking) are properly validated before executing critical operations like document replacement. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -242,6 +242,16 @@ const workspace = { | |
| ], | ||
| 'OR', | ||
| ), | ||
| doc_replace: (source_id:string) => | ||
| hasPermission( | ||
| [ | ||
| new ComplexPermission([RoleConst.USER],[PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(source_id)],[],'AND'), | ||
| RoleConst.WORKSPACE_MANAGE.getWorkspaceRole, | ||
| PermissionConst.KNOWLEDGE_DOCUMENT_REPLACE.getKnowledgeWorkspaceResourcePermission(source_id), | ||
| PermissionConst.KNOWLEDGE_DOCUMENT_REPLACE.getWorkspacePermissionWorkspaceManageRole, | ||
| ], | ||
| 'OR', | ||
| ), | ||
| knowledge_chat_user_read: (source_id:string) => false, | ||
| knowledge_chat_user_edit: (source_id:string) => | ||
| hasPermission( | ||
|
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. There are no specific irregularities or major issues present in the code snippet you provided for doc_replace: (source_id:string) =>
hasPermission([
new ComplexPermission([RoleConst.USER], [PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(source_id)], [], 'AND'),
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole(),
...[
PermissionConst.KNOWLEDGE_DOCUMENT_REPLACE.getKnowledgeWorkspaceResourcePermission(source_id),
PermissionConst.KNOWLEDGE_DOCUMENT_REPLACE.getWorkspacePermissionWorkspaceManageRole(),
].filter(Boolean), // Remove falsy values if needed
], 'OR');This ensures that only truthy permission objects are considered during the |
||
|
|
||
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.
The code seems to be well-structured and contains no obvious inconsistencies or errors. However, there are a few minor improvements that can be made:
Consistent Naming: Ensure consistent naming conventions throughout the codebase. This will help maintain readability and consistency.
Comment Documentation: Add more comments explaining the purpose of each
Operatevalue. While existing descriptions are somewhat helpful, they could benefit from additional details.Code Readability: Break down longer lines into multiple lines if necessary to improve readability.
Here's an adjusted version with these suggestions in mind:
Key Changes:
These changes make the code easier to understand and maintain.