-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: About permission #4228
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
feat: About permission #4228
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| label=_('Update License') | ||
| ) | ||
| SWITCH_LANGUAGE = Permission(group=Group.OTHER, operate=Operate.EDIT, | ||
| role_list=[RoleConstants.ADMIN, RoleConstants.USER], |
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 looks mostly correct, but there are some suggestions to improve it:
-
Remove Redundant
READEnum Member:
TheREADmember is repeated in bothOperateandPermissionConstants. This redundancy can remove the need for duplicate values.class Operate(Enum): AUTH = "READ+AUTH" # 资源授权 TAG = "READ+TAG" # 标签设置 REPLACE = "READ+REPLACE" # 标签设置 UPDATE = "READ+UPDATE"
2. **Optimize Documentation Strings**:
Ensure that documentation strings are concise and descriptive, and keep consistent spacing around them.
```python
class AboutReadPermission(Permission):
group = Group.OTHER
operation = Operate.READ
role_list = [RoleConstants.ADMIN, RoleConstants.USER]
parent_groups = [SystemGroup.OTHER, WorkspaceGroup.OTHER, UserGroup.OTHER]
label = _('About')
class AboutUpdatePermission(Permission):
group = Group.OTHER
operation = Operate.UPDATE
role_list = [RoleConstants.ADMIN]
parent_groups = [SystemGroup.OTHER]
label = _('Update License')
-
Separate Permissions into Classes (Optional):
If your application requires more complex permission checks or organization, consider separating permissions into separate classes.class BasePermission(Permission): def __init__(self, operation, role_list=[], parent_groups=[]): super().__init__(group=Group.OTHER, operate=operation, role_list=role_list, parent_group=parent_groups) class AboutReadPermission(BasePermission): label = _('About') class AboutUpdatePermission(BasePermission): label = _('Update License')
By making these adjustments, the code will be cleaner, more readable, and potentially easier to maintain.
| import { PermissionConst, RoleConst } from '@/utils/permission/data' | ||
| const {user, theme} = useStore() | ||
| const isDefaultTheme = computed(() => { | ||
| return theme.isDefaultTheme() |
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 appears to be an issue with line 49 of the provided code snippet. The v-hasPermission directive seems to have been replaced by v-if, which may cause unexpected behavior if you intend to use permission-based logic for displaying certain components.
Additionally, lines 68-73 should be moved outside of the <template> block as they don't belong there. They appear to define utility functions and store variables, which are typically handled within the setup function in Vue.js.
For optimization, remove the unnecessary import statements for the roles like 'USER' before importing from @/utils/permission/data. Here's the revised version:
<template>
<!-- Your template content here -->
</template>
<script lang="ts">
import {defineComponent} from "vue";
// import {RoleConst, PermissionConst} from "@/utils/permission/data"; // Remove this line
import userStore from "@/stores/userStore";
export default defineComponent({
data() {
return {};
},
computed: {
isDefaultTheme() {
return this.user.theme.isDefaultTheme();
}
}
});
</script>
This approach keeps the scope clean while ensuring all necessary imports are included where needed. Make sure each component has the appropriate role checks based on your application's security requirements.
| ABOUT_UPDATE: new Permission('OTHER:READ+UPDATE'), | ||
| SWITCH_LANGUAGE: new Permission('OTHER:READ+EDIT'), | ||
| CHANGE_PASSWORD: new Permission('OTHER:READ+CREATE'), | ||
| SYSTEM_API_KEY_EDIT: new Permission('OTHER:READ+DELETE'), |
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 provided code snippet for PermissionConst looks mostly correct with minor formatting and comment changes. Here's a concise review:
-
Comments: Ensure each permission is well-commented to describe its purpose clearly.
-
Order of Operations: Permissions related to specific actions (e.g., updating, reading) should be mentioned first. It makes sense to group those at the beginning.
-
Syntax Consistency: The syntax seems consistent, but ensure there are no typos or extra characters that might cause issues.
-
Documentation: Consider adding comments describing what each permission string means if it's not clear from context.
Overall, the existing permissions seem logically organized and don't contain known issues. If there are additional requirements or security concerns, consider consulting them further.
feat: About permission