-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Folder authorization frontend #4186
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,7 +112,7 @@ | |
| v-model="row.permission" | ||
| @change="(val: any) => permissionsHandle(val, row)" | ||
| > | ||
| <template v-for="(item, index) in permissionOptions" :key="index"> | ||
| <template v-for="(item, index) in getFolderPermissionOptions()" :key="index"> | ||
| <el-radio :value="item.value" class="mr-16">{{ item.label }}</el-radio> | ||
| </template> | ||
| </el-radio-group> | ||
|
|
@@ -157,6 +157,8 @@ import useStore from '@/stores' | |
| const { user } = useStore() | ||
| const props = defineProps<{ | ||
| type: string | ||
| isFolder?: boolean | ||
| isRootFolder?: boolean | ||
| }>() | ||
|
|
||
| const apiType = computed(() => { | ||
|
|
@@ -166,6 +168,24 @@ const apiType = computed(() => { | |
| return 'workspace' | ||
| } | ||
| }) | ||
|
|
||
| const permissionOptionMap = computed(() => { | ||
| return { | ||
| rootFolder: getPermissionOptions(true, true), | ||
| folder: getPermissionOptions(true, false), | ||
| } | ||
| }) | ||
|
|
||
| const getFolderPermissionOptions = () => { | ||
| if (props.isRootFolder) { | ||
| return permissionOptionMap.value.rootFolder | ||
| } | ||
| if (props.isFolder) { | ||
| return permissionOptionMap.value.folder | ||
| } | ||
| return getPermissionOptions(false, false) | ||
| } | ||
|
|
||
| const permissionOptions = computed(() => { | ||
| return getPermissionOptions() | ||
| }) | ||
|
|
@@ -281,7 +301,12 @@ const getPermissionList = () => { | |
| loading, | ||
| ) | ||
| .then((res: any) => { | ||
| permissionData.value = res.data.records || [] | ||
| permissionData.value = res.data.records.map((item: any) => { | ||
| if (props.isRootFolder && item.permission === 'NOT_AUTH') { | ||
| return {...item, permission: 'VIEW'} | ||
| } | ||
| return item | ||
| }) || [] | ||
| paginationConfig.total = res.data.total || 0 | ||
| }) | ||
| } | ||
|
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. Your code has several improvements and optimizations:
These changes improve readability and efficiency by encapsulating logic related to handling different types of folders into separate methods, reducing redundant repeated code, and providing better control over when certain conditions apply. |
||
|
|
||
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 is clean and well-organized. Here are some minor improvements and suggestions:
Type Annotations: Since
currentNodeis used within template expressions, it should be declared with a type annotation (ref<(...args: any[]) => void>).Arrow Function Shorthand: The arrow function for
openAuthorizationcan be simplified ifthis.is not needed.After these changes, the code looks like this:
Additional Suggestion:
Consider adding more descriptive variable names to help clarify their purpose. For example:
currentFolder: Instead of usingdata, which could be ambiguous due to its use in other contexts.resourceAuthdrawerInstance: Describes the instance being managed by the drawer component.These small adjustments make the code easier to read and maintain.