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/08/25 02:54:51 UTC

[GitHub] [dolphinscheduler] Amy0104 commented on a diff in pull request #11203: [Feature-11195][UI] Add re-upload feature for resource files

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


##########
dolphinscheduler-ui/src/router/modules/resources.ts:
##########
@@ -55,7 +55,7 @@ export default {
     {
       path: '/resource/file/edit/:id',
       name: 'resource-file-edit',
-      component: components['resource-file-edit'],
+      component: components['resource-components-resource-edit'],

Review Comment:
   Same as above.



##########
dolphinscheduler-ui/src/router/modules/resources.ts:
##########
@@ -43,7 +43,7 @@ export default {
     {
       path: '/resource/file/create',
       name: 'resource-file-create',
-      component: components['resource-file-create'],
+      component: components['resource-components-resource-create'],

Review Comment:
   It's better to create a page to wrap the component.



##########
dolphinscheduler-ui/src/router/modules/resources.ts:
##########
@@ -91,7 +91,7 @@ export default {
     {
       path: '/resource/file/create/:id',
       name: 'resource-subfile-create',
-      component: components['resource-file-create'],
+      component: components['resource-components-resource-create'],

Review Comment:
   Same as above.



##########
dolphinscheduler-ui/src/locales/zh_CN/resource.ts:
##########
@@ -54,31 +56,8 @@ export default {
   },
   udf: {
     udf_resources: 'UDF资源',
-    create_folder: '创建文件夹',
     upload_udf_resources: '上传UDF资源',
-    udf_source_name: 'UDF资源名称',
-    user_name: '所属用户',
-    whether_directory: '是否文件夹',
-    file_name: '文件名称',
-    file_size: '文件大小',
-    description: '描述',
-    create_time: '创建时间',
-    update_time: '更新时间',
-    operation: '操作',
-    yes: '是',
-    no: '否',
-    edit: '编辑',
-    download: '下载',
-    delete: '删除',
-    success: '成功',
-    folder_name: '文件夹名称',
-    upload: '上传',
-    upload_files: '上传文件',
-    file_upload: '文件上传',
-    delete_confirm: '确定删除吗?',
-    enter_keyword_tips: '请输入关键词',
-    enter_name_tips: '请输入名称',
-    enter_description_tips: '请输入描述'

Review Comment:
   The keys should also be removed in the en_US file too.



##########
dolphinscheduler-ui/src/router/modules/resources.ts:
##########
@@ -79,7 +79,7 @@ export default {
     {
       path: '/resource/file/list/:id',
       name: 'resource-file-list',
-      component: components['resource-file-edit'],
+      component: components['resource-components-resource-edit'],

Review Comment:
   Same as above.



##########
dolphinscheduler-ui/src/views/resource/components/resource/table/use-table.ts:
##########
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { h, reactive, ref } from 'vue'
+import { useI18n } from 'vue-i18n'
+import type { Router } from 'vue-router'
+import { useRouter } from 'vue-router'
+import { bytesToSize } from '@/common/common'
+import { useFileStore } from '@/store/file/file'
+import TableAction from './table-action'
+import { IUpdateResouseInfo, ResourceType } from '../types'
+import ButtonLink from '@/components/button-link'
+import { NEllipsis } from 'naive-ui'
+import { calculateTableWidth, COLUMN_WIDTH_CONFIG, DefaultTableWidth } from '@/common/column-width-config'
+import type { TableColumns } from 'naive-ui/es/data-table/src/interface'
+import { useFileState } from "@/views/resource/components/resource/use-file";
+
+
+const goSubFolder = (router: Router, item: any) => {
+  const fileStore = useFileStore()
+  fileStore.setFileInfo(`${item.alias}|${item.size}`)
+
+  if (item.directory) {
+    fileStore.setCurrentDir(`${item.fullName}`)
+    router.push({
+      name: item.type === 'UDF' ? 'resource-sub-manage' : 'resource-file-subdirectory',
+      params: { id: item.id }
+    })
+  } else if (item.type === 'FILE') {
+    router.push({ name: 'resource-file-list', params: { id: item.id } })
+  }
+}
+
+
+export function useTable() {
+  const { t } = useI18n()
+  const router: Router = useRouter()
+
+  const fileId = ref(Number(router.currentRoute.value.params.id) || -1)
+  const resourceTypeRef = ref<ResourceType>()
+  const resourceListRef = ref()
+  const folderShowRef = ref(false)
+  const uploadShowRef = ref(false)
+  const isReuploadRef = ref(false)
+  const renameShowRef = ref(false)
+  const searchRef = ref()
+  const breadListRef = ref<Array<string>>(
+    [resourceTypeRef.value === 'UDF'
+      ? t('resource.udf.udf_resources')
+      : t('resource.file.file_manage')]
+  )

Review Comment:
   It's better to use a reactive instead of so many refs.



##########
dolphinscheduler-ui/src/views/resource/components/resource/folder/use-form.ts:
##########
@@ -18,10 +18,11 @@
 import { reactive, ref, unref } from 'vue'
 import { useI18n } from 'vue-i18n'
 import type { FormRules } from 'naive-ui'
+import { ResourceType } from "@/views/resource/components/resource/types";
 
 const defaultValue = () => ({
   pid: -1,
-  type: 'FILE',
+  type: undefined as unknown as ResourceType,
   name: '',
   description: '',
   currentDir: '/'

Review Comment:
   It is better to define an interface for the defaultValue.



##########
dolphinscheduler-ui/src/views/resource/components/resource/upload/index.tsx:
##########
@@ -59,6 +80,20 @@ export default defineComponent({
 
     const trim = getCurrentInstance()?.appContext.config.globalProperties.trim
 
+
+    watch(
+      () => props.show,
+      () => {
+        state.uploadForm.type = props.resourceType!
+        state.uploadForm.isReupload = props.isReupload
+        if (props.isReupload && props.show) {
+          state.uploadForm.id = props.id
+          state.uploadForm.name = props.name
+          state.uploadForm.description = props.description
+        }
+      }

Review Comment:
   It seems that these logics are only handled when show is true.



##########
dolphinscheduler-ui/src/locales/zh_CN/resource.ts:
##########
@@ -54,31 +56,8 @@ export default {
   },
   udf: {
     udf_resources: 'UDF资源',
-    create_folder: '创建文件夹',
     upload_udf_resources: '上传UDF资源',
-    udf_source_name: 'UDF资源名称',
-    user_name: '所属用户',
-    whether_directory: '是否文件夹',
-    file_name: '文件名称',
-    file_size: '文件大小',
-    description: '描述',
-    create_time: '创建时间',
-    update_time: '更新时间',
-    operation: '操作',
-    yes: '是',
-    no: '否',
-    edit: '编辑',
-    download: '下载',
-    delete: '删除',
-    success: '成功',

Review Comment:
   This item seems to have been used.



##########
dolphinscheduler-ui/src/views/resource/file/index.tsx:
##########
@@ -15,343 +15,16 @@
  * limitations under the License.
  */
 
-import { useRouter } from 'vue-router'
-import { defineComponent, onMounted, ref, reactive, Ref, getCurrentInstance } from 'vue'
-import {
-  NIcon,
-  NSpace,
-  NDataTable,
-  NButtonGroup,
-  NButton,
-  NPagination,
-  NInput,
-  NBreadcrumb,
-  NBreadcrumbItem
-} from 'naive-ui'
-import { useI18n } from 'vue-i18n'
-import { SearchOutlined } from '@vicons/antd'
-import { useTable } from './table/use-table'
-import { useFileState } from './use-file'
-import { BreadcrumbItem, IRenameFile } from './types'
-import { useFileStore } from '@/store/file/file'
-import {
-  queryCurrentResourceById,
-  queryResourceById
-} from '@/service/modules/resources'
-import Card from '@/components/card'
-import ResourceFolderModal from './folder'
-import ResourceUploadModal from './upload'
-import ResourceRenameModal from './rename'
-import styles from './index.module.scss'
-import type { ResourceFile } from '@/service/modules/resources/types'
-import type { Router } from 'vue-router'
+import { defineComponent } from 'vue'
+import ResourceListModal from '../components/resource'
 
 export default defineComponent({
-  name: 'File',
+  name: 'FILE',

Review Comment:
   It seems that File is better than FILE for name.



##########
dolphinscheduler-ui/src/views/resource/components/resource/upload/use-form.ts:
##########
@@ -18,13 +18,17 @@
 import { reactive, ref, unref } from 'vue'
 import { useI18n } from 'vue-i18n'
 import type { FormRules } from 'naive-ui'
+import { ResourceType } from "@/views/resource/components/resource/types";
 
 const defaultValue = () => ({
+  id: -1,
   name: '',
   file: '',
   description: '',
+  type: undefined as unknown as ResourceType,
   pid: -1,
-  currentDir: '/'
+  currentDir: '/',
+  isReupload: false
 })

Review Comment:
   It is better to define an interface for the defaultValue.



-- 
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