Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ui/src/views/system/resource-authorization/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const permissionOptions = [
]


const getPermissionOptions = (isFodler = false, isRootFolder = false) => {
if (isFodler && isRootFolder) {
const getPermissionOptions = (isFolder = false, isRootFolder = false) => {
if (isFolder && isRootFolder) {
return permissionOptions.filter(
item => item.value === AuthorizationEnum.VIEW || item.value === AuthorizationEnum.MANAGE
)
}
if (isFodler) {
if (isFolder) {
return permissionOptions
}
if (hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code looks generally correct for handling different permission options based on whether an entity is a folder, root folder, or does not have specific permissions. However, there are some minor issues that could be addressed:

  1. Misnaming: Variable naming consistency is important for readability and maintainability. Using isFolder instead of both isFodler would make the function signature more uniform.

  2. Comments: While comments can help clarify the logic, they should be concise and relevant to the code. In this case, the comment could be refined.

Here's the revised version with these suggestions:

const permissionOptions = [
]

const getPermissionOptions = (isFolder = false, isRootFolder = false) => {
  if (isFolder && isRootFolder) {
    return permissionOptions.filter(item => item.value === AuthorizationEnum.VIEW || item.value === AuthorizationEnum.MANAGE)
  }
  if (isFolder) {
    return permissionOptions
  }
  if (hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')) { 
    // Additional checks here
  }
}

These changes ensure better coding practices, making it easier to understand the purpose and usage of the function.

Expand Down
Loading