You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/10/15 05:49:45 UTC

[GitHub] [dolphinscheduler] Amy0104 commented on a diff in pull request #12076: [Feature-10495][Resource Center] Resource Center Refactor

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


##########
dolphinscheduler-ui/src/views/resource/file/create/use-create.ts:
##########
@@ -27,7 +27,7 @@ export function useCreate(state: any) {
   const fileStore = useFileStore()
 
   const handleCreateFile = () => {
-    const pid = router.currentRoute.value.params.id || -1
+    const pid = -1

Review Comment:
   It seems to need to remove `pid`.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/types.ts:
##########
@@ -91,7 +91,9 @@ interface ISwitchResult {
 }
 
 interface ISourceItem {
-  id: number
+  id?: number,
+  resourceName: string,
+  res?: string

Review Comment:
   what's the meaning of `res`? Would it be better to use a full word?



##########
dolphinscheduler-ui/src/views/resource/udf/resource/use-table.ts:
##########
@@ -242,13 +240,26 @@ export function useTable() {
     variables.loadingRef = true
     const { state } = useAsyncState(
       queryResourceListPaging({ ...params, type: 'UDF' }).then((res: any) => {
-        const breadList =
-          variables.id === -1
-            ? []
-            : (fileStore.getCurrentDir.split('/') as Array<never>)
-        breadList.shift()
-
-        variables.breadList = breadList
+        if (variables.fileId != ""){

Review Comment:
   It better to use strict inequality here.



##########
dolphinscheduler-ui/src/views/resource/file/edit/index.tsx:
##########
@@ -32,21 +32,22 @@ export default defineComponent({
     const router = useRouter()
 
     const componentName = route.name
-    const fileId = Number(route.params.id)
+    const fileId = String(router.currentRoute.value.query.prefix || "")

Review Comment:
   Here `fullName` seems to be better than `fileId`.



##########
dolphinscheduler-ui/src/views/resource/file/edit/use-edit.ts:
##########
@@ -28,25 +28,29 @@ export function useEdit(state: any) {
   const { t } = useI18n()
   const router: Router = useRouter()
 
-  const getResourceView = (id: number) => {
+  const getResourceView = (fullName: string, tenantCode: string, id: number) => {
     const params = {
       skipLineNum: 0,
-      limit: 3000
+      limit: 3000,
+      fullName: fullName,
+      tenantCode: tenantCode
     }
     return useAsyncState(viewResource(params, id), {
       alias: '',
       content: ''
     })
   }
 
-  const handleUpdateContent = (id: number) => {
+  const handleUpdateContent = (id: string, fullName: string, tenantCode: string) => {

Review Comment:
   `id` needs to be removed, it seems to be unused.



##########
dolphinscheduler-ui/src/views/resource/udf/resource/use-table.ts:
##########
@@ -242,13 +240,26 @@ export function useTable() {
     variables.loadingRef = true
     const { state } = useAsyncState(
       queryResourceListPaging({ ...params, type: 'UDF' }).then((res: any) => {
-        const breadList =
-          variables.id === -1
-            ? []
-            : (fileStore.getCurrentDir.split('/') as Array<never>)
-        breadList.shift()
-
-        variables.breadList = breadList
+        if (variables.fileId != ""){
+            const id = -1
+            queryCurrentResourceById(
+              {
+                id,
+                type: 'UDF',
+                fullName: variables.fileId,
+                tenantCode: variables.tenantCode,
+              },
+              id
+            ).then((res: ResourceFile) => {
+                if (res.fileName) {
+                  const breadList = res.fileName.split('/') as Array<never>

Review Comment:
   The  type of `breadList` can not to be `Array<never>`.



##########
dolphinscheduler-ui/src/views/resource/file/index.tsx:
##########
@@ -57,8 +57,8 @@ export default defineComponent({
   name: 'File',
   setup() {
     const router: Router = useRouter()
-    const fileId = ref(Number(router.currentRoute.value.params.id) || -1)
-
+    const fileId = ref(String(router.currentRoute.value.query.prefix || ""))

Review Comment:
   Same as above.



##########
dolphinscheduler-ui/src/views/resource/udf/resource/use-table.ts:
##########
@@ -285,18 +298,19 @@ export function useTable() {
     router.push({ name: 'resource-manage' })
   }
 
-  const goBread = (fullName: string) => {
-    const { id } = variables
+  const goBread = (fileName: string) => {
+    const id = -1

Review Comment:
   If `id` is useless, it is better to remove it.



##########
dolphinscheduler-ui/src/views/resource/file/upload/use-upload.ts:
##########
@@ -37,7 +34,7 @@ export function useUpload(state: any) {
     if (state.saving) return
     state.saving = true
     try {
-      const pid = router.currentRoute.value.params.id || -1
+      const pid = -1

Review Comment:
   It's better to remove the `pid`, if it is useless.



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org