-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: The role-based authorization option is temporarily hidden #3927
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 |
|---|---|---|
|
|
@@ -2,9 +2,8 @@ import { AuthorizationEnum } from '@/enums/system' | |
| import { t } from '@/locales' | ||
| import { hasPermission } from '@/utils/permission' | ||
| import { EditionConst } from '@/utils/permission/data' | ||
|
|
||
| const notCommunity = hasPermission([EditionConst.IS_EE,EditionConst.IS_PE],'OR') | ||
|
|
||
|
|
||
|
|
||
| const permissionOptions = [ | ||
| { | ||
| label: t('views.system.resourceAuthorization.setting.notAuthorized'), | ||
|
|
@@ -23,14 +22,16 @@ const permissionOptions = [ | |
| }, | ||
| ] | ||
|
|
||
| if (notCommunity) { | ||
| permissionOptions.push( | ||
| { | ||
|
|
||
| const getPermissionOptions=()=>{ | ||
| if (hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')) { | ||
| return [...permissionOptions,{ | ||
| label: t('views.system.resourceAuthorization.setting.role'), | ||
| value: AuthorizationEnum.ROLE, | ||
| desc: t('views.system.resourceAuthorization.setting.roleDesc'), | ||
| }, | ||
| ) | ||
| },] | ||
| } | ||
| return permissionOptions; | ||
| } | ||
|
|
||
| export {permissionOptions} | ||
| export {getPermissionOptions} | ||
|
||
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 does not contain significant irregularities or critical issues. However, here are some optimizations and suggestions:
Refactor Computed Property: The
permissionOptionscomputed property could be more efficient if it directly calls the asynchronous function without wrapping it in acomputed. This allows you to callgetPermissionOptions()only when necessary.Type Assertion: Ensure that the type of
user.roleNameis explicitly defined or correctly inferred. For example, usingas RoleConst.Admincan help improve TypeScript's understanding of the expected input.Documentation Comments: Add comments explaining where relevant variables and functions are used or returned to enhance readability and maintainability.
Here's an improved version based on these suggestions:
By making these changes, the code becomes more robust and easier to understand. Make sure to adjust any specific type assumptions based on your actual application logic and data structure.