Amy0104 commented on code in PR #12048:
URL: 
https://github.com/apache/dolphinscheduler/pull/12048#discussion_r1005243614


##########
dolphinscheduler-ui/src/views/security/user-manage/components/use-authorize.ts:
##########
@@ -217,10 +279,7 @@ export function useAuthorize() {
     if (state.saving) return false
     state.saving = true
     if (type === 'authorize_project') {
-      await grantProject({
-        userId,
-        projectIds: state.authorizedProjects.join(',')
-      })

Review Comment:
   This if statement seems to be useless.



##########
dolphinscheduler-ui/src/views/security/user-manage/components/authorize-modal.tsx:
##########
@@ -59,6 +65,21 @@ export const AuthorizeModal = defineComponent({
       if (result) onCancel()
     }
 
+    let projectIds!: string
+    const onRevokeProject = async () => {
+      await revokeProjectByIdRequest(props.userId, projectIds)

Review Comment:
   It seems to not need a async function here.



##########
dolphinscheduler-ui/src/views/security/user-manage/components/use-authorize.ts:
##########
@@ -56,29 +60,77 @@ export function useAuthorize() {
     authorizedNamespaces: [] as number[],
     unauthorizedNamespaces: [] as IOption[],
     resourceType: 'file',
+    authorizationType: 'read',
     fileResources: [] as IResourceOption[],
     udfResources: [] as IResourceOption[],
     authorizedFileResources: [] as number[],
-    authorizedUdfResources: [] as number[]
+    authorizedUdfResources: [] as number[],
+    authorizedFileResourcesWithReadPerm: [] as number[],
+    authorizedUdfResourcesWithReadPerm: [] as number[],
+    pagination: {
+      pageSize: 5,
+      page: 1,
+      totalPage: 0
+    },
+    searchVal: '',
+    userId: 0
   })
 
+  const onOperationClick = ( ) => { }

Review Comment:
   Is this function unused? If unused, plz remove it.



##########
dolphinscheduler-ui/src/views/security/user-manage/components/authorize-modal.tsx:
##########
@@ -149,6 +228,30 @@ export const AuthorizeModal = defineComponent({
               options={this.udfResources}
               v-model:value={this.authorizedUdfResources}
             />
+            <NTreeSelect
+              v-show={this.resourceType === 'file' && this.authorizationType 
=== "read"}
+              filterable
+              multiple
+              cascade
+              checkable
+              checkStrategy='child'
+              key-field='id'
+              label-field='fullName'
+              options={this.fileResources}
+              v-model:value={this.authorizedFileResourcesWithReadPerm}
+            />
+            <NTreeSelect
+              v-show={this.resourceType === 'udf'  && this.authorizationType 
=== "read"}
+              filterable
+              multiple
+              cascade
+              checkable
+              checkStrategy='child'
+              key-field='id'
+              label-field='fullName'
+              options={this.udfResources}
+              v-model:value={this.authorizedUdfResourcesWithReadPerm}
+            />

Review Comment:
   It is better to control the availability of permission by data.



##########
dolphinscheduler-ui/src/views/security/user-manage/components/use-authorize.ts:
##########
@@ -265,10 +324,42 @@ export function useAuthorize() {
         })
       })
 
+      let fullPathFileIdWithReadPerm = []
+      const pathFileIdWithReadPerm: Array<string> = []
+      state.authorizedFileResourcesWithReadPerm.forEach((v: number) => {
+        state.fileResources.forEach((v1: any) => {
+          const arr = []
+          arr[0] = v1
+          if (getParent(arr, v).length > 0) {
+            fullPathFileIdWithReadPerm = getParent(arr, v).map((v2: any) => {
+              return v2.id
+            })
+            pathFileIdWithReadPerm.push(fullPathFileIdWithReadPerm.join('-'))
+          }
+        })
+      })
+
+      let fullPathUdfIdWithReadPerm = []
+      const pathUdfIdWithReadPerm: Array<string> = []
+      state.authorizedUdfResourcesWithReadPerm.forEach((v: number) => {
+        state.udfResources.forEach((v1: any) => {
+          const arr = []
+          arr[0] = v1
+          if (getParent(arr, v).length > 0) {
+            fullPathUdfIdWithReadPerm = getParent(arr, v).map((v2: any) => {
+              return v2.id
+            })
+            pathUdfIdWithReadPerm.push(fullPathUdfIdWithReadPerm.join('-'))
+          }
+        })
+      })

Review Comment:
   This block is similar to the previous one. It's better to do this by a 
function.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to