From 44c8d615a41a851a3547d34ff9332a97ee6d5997 Mon Sep 17 00:00:00 2001 From: calvin Date: Thu, 17 Mar 2022 17:52:04 +0800 Subject: [PATCH] [Fix-8834][UI Next][V1.0.0-Alpha] Rectify this issue about missing the path in the page of file management. (#8963) * fix this issue * merge from dev --- .../src/components/card/index.tsx | 20 ++- .../src/views/resource/file/index.module.scss | 10 ++ .../src/views/resource/file/index.tsx | 145 ++++++++++++++---- .../src/views/resource/file/types.ts | 5 + 4 files changed, 144 insertions(+), 36 deletions(-) diff --git a/dolphinscheduler-ui-next/src/components/card/index.tsx b/dolphinscheduler-ui-next/src/components/card/index.tsx index 5d152ae960..5f4d1c9e40 100644 --- a/dolphinscheduler-ui-next/src/components/card/index.tsx +++ b/dolphinscheduler-ui-next/src/components/card/index.tsx @@ -15,7 +15,7 @@ * limitations under the License. */ -import { defineComponent, PropType } from 'vue' +import {CSSProperties, defineComponent, PropType} from 'vue' import { NCard } from 'naive-ui' const headerStyle = { @@ -26,9 +26,22 @@ const contentStyle = { padding: '8px 10px' } +const headerExtraStyle = { + +} + const props = { title: { type: String as PropType + }, + headerStyle: { + type: String as PropType + }, + headerExtraStyle: { + type: String as PropType + }, + contentStyle: { + type: String as PropType } } @@ -41,8 +54,9 @@ const Card = defineComponent({ {$slots} diff --git a/dolphinscheduler-ui-next/src/views/resource/file/index.module.scss b/dolphinscheduler-ui-next/src/views/resource/file/index.module.scss index 2f0d90eb3f..c878dbece5 100644 --- a/dolphinscheduler-ui-next/src/views/resource/file/index.module.scss +++ b/dolphinscheduler-ui-next/src/views/resource/file/index.module.scss @@ -71,6 +71,16 @@ } } +.table-card { + > div div { + flex: none !important; + } +} + +.breadcrumb { + padding-left: 10px; +} + .conditions-model { display: flex; justify-content: space-between; diff --git a/dolphinscheduler-ui-next/src/views/resource/file/index.tsx b/dolphinscheduler-ui-next/src/views/resource/file/index.tsx index 3b758bfe5a..6d3deb06e0 100644 --- a/dolphinscheduler-ui-next/src/views/resource/file/index.tsx +++ b/dolphinscheduler-ui-next/src/views/resource/file/index.tsx @@ -32,7 +32,9 @@ import { NButtonGroup, NButton, NPagination, - NInput + NInput, + NBreadcrumb, + NBreadcrumbItem } from 'naive-ui' import { useI18n } from 'vue-i18n' import { SearchOutlined } from '@vicons/antd' @@ -42,11 +44,14 @@ import { useFileState } from './use-file' import ResourceFolderModal from './folder' import ResourceUploadModal from './upload' import ResourceRenameModal from './rename' -import { IRenameFile } from './types' +import {BreadcrumbItem, IRenameFile} from './types' import type { Router } from 'vue-router' import styles from './index.module.scss' import { useFileStore } from '@/store/file/file' -import { queryCurrentResourceById } from '@/service/modules/resources' +import { + queryCurrentResourceById, + queryResourceById +} from '@/service/modules/resources' import { ResourceFile } from '@/service/modules/resources/types' export default defineComponent({ @@ -151,6 +156,23 @@ export default defineComponent({ resourceListRef.value = getResourceListState(fileId.value) }) + const breadcrumbItemsRef: Ref | undefined> = ref( + [ + { + id: 1, + fullName: 'l1' + }, + { + id: 2, + fullName: 'l2' + }, + { + id: 4, + fullName: 'l3' + } + ] + ) + watch( () => router.currentRoute.value.params.id, // @ts-ignore @@ -170,6 +192,44 @@ export default defineComponent({ } ) + const initBreadcrumb = async (dirs: string[]) => { + let index = 0 + for (let dir of dirs) { + const newDir = dirs.slice(0, index + 1).join('/') + if (newDir) { + const id = 0 + let resource = await queryResourceById( + { + id, + type: 'FILE', + fullName: newDir + }, + id + ) + breadcrumbItemsRef.value?.push({id: resource.id, fullName: dir}) + } else { + breadcrumbItemsRef.value?.push({id: 0, fullName: 'Root'}) + } + index = index + 1 + } + } + + onMounted( + () => { + breadcrumbItemsRef.value = [] + if (fileId.value != -1) { + queryCurrentResourceById(fileId.value).then((res: ResourceFile) => { + if (res.fullName) { + const dirs = res.fullName.split('/') + if (dirs && dirs.length > 1) { + initBreadcrumb(dirs) + } + } + }) + } + } + ) + return { fileId, serachRef, @@ -187,7 +247,8 @@ export default defineComponent({ handleUpdatePage, handleUpdatePageSize, pagination: paginationReactive, - renameInfo + renameInfo, + breadcrumbItemsRef, } }, render() { @@ -199,6 +260,7 @@ export default defineComponent({ handleCreateFile, handleUploadFile } = this + return (
@@ -238,44 +300,61 @@ export default defineComponent({
- - -
- -
- + {{ + 'header-extra': () => ( + + { + this.breadcrumbItemsRef?.map((item: BreadcrumbItem) => { + return ( + {item.fullName} + ) + }) + } + + ), + default: () => ( +
+ +
+ +
+
+ ) + }} +
+ - + - + - + /> ) } diff --git a/dolphinscheduler-ui-next/src/views/resource/file/types.ts b/dolphinscheduler-ui-next/src/views/resource/file/types.ts index 8bd5e52a14..1926fb9713 100644 --- a/dolphinscheduler-ui-next/src/views/resource/file/types.ts +++ b/dolphinscheduler-ui-next/src/views/resource/file/types.ts @@ -64,3 +64,8 @@ export interface PaginationProps { export interface ISetPagination { (itemCount: number): void } + +export interface BreadcrumbItem { + id: number, + fullName: string +}