Unverified Commit b45541fd authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Fix-2320] [web] Fix expanding all but only the root directory (#2321)

parent 6b0c6897
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
import { import {
buildProjectTree, buildProjectTree,
generateList, generateList, getLeafKeyList,
getParentKey getParentKey
} from '@/pages/DataStudio/LeftContainer/Project/function'; } from '@/pages/DataStudio/LeftContainer/Project/function';
import { StateType } from '@/pages/DataStudio/model'; import { StateType } from '@/pages/DataStudio/model';
...@@ -80,10 +80,11 @@ const JobTree: React.FC<TreeProps & connect> = (props) => { ...@@ -80,10 +80,11 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
const onExpand = (expandedKeys: Key[]) => { const onExpand = (expandedKeys: Key[]) => {
setExpandedKeys(expandedKeys); setExpandedKeys(expandedKeys);
}; };
const expandAll = () => { const expandAll = () => {
const map = data.filter((x: { isLeaf: any }) => !x.isLeaf).map((x: { key: any }) => x.key); setExpandedKeys(getLeafKeyList(projectData));
setExpandedKeys(map);
}; };
const btn = BtnRoute['menu.datastudio.project']; const btn = BtnRoute['menu.datastudio.project'];
btn[1].onClick = expandAll; btn[1].onClick = expandAll;
......
import { getTabIcon } from '@/pages/DataStudio/MiddleContainer/function'; import {getTabIcon} from '@/pages/DataStudio/MiddleContainer/function';
import { Catalogue } from '@/types/Studio/data.d'; import {Catalogue} from '@/types/Studio/data.d';
import { searchTreeNode } from '@/utils/function'; import {searchTreeNode} from '@/utils/function';
export const generateList = (data: any, list: any[]) => { export const generateList = (data: any, list: any[]) => {
for (const element of data) { for (const element of data) {
const node = element; const node = element;
const { name, id, parentId, level } = node; const {name, id, parentId, level} = node;
list.push({ name, id, key: id, title: name, parentId, level }); list.push({name, id, key: id, title: name, parentId, level});
if (node.children) { if (node.children) {
generateList(node.children, list); generateList(node.children, list);
} }
} }
return list; return list;
}; };
export const getParentKey = (key: number | string, tree: any): any => { export const getParentKey = (key: number | string, tree: any): any => {
let parentKey; let parentKey;
for (const element of tree) { for (const element of tree) {
...@@ -28,6 +29,19 @@ export const getParentKey = (key: number | string, tree: any): any => { ...@@ -28,6 +29,19 @@ export const getParentKey = (key: number | string, tree: any): any => {
return parentKey; return parentKey;
}; };
export const getLeafKeyList = (tree: any): any => {
let leafKeyList = [];
for (const node of tree) {
if (node.isLeaf) {
leafKeyList.push(node.id);
continue;
}
if (node.children) {
leafKeyList = leafKeyList.concat(getLeafKeyList(node.children))
}
}
return leafKeyList;
};
/** /**
* build Catalogue tree * build Catalogue tree
* @param {Catalogue[]} data * @param {Catalogue[]} data
...@@ -68,4 +82,5 @@ export const isUDF = (jobType: string) => { ...@@ -68,4 +82,5 @@ export const isUDF = (jobType: string) => {
return jobType === 'Scala' || jobType === 'Python' || jobType === 'Java'; return jobType === 'Scala' || jobType === 'Python' || jobType === 'Java';
}; };
export const buildUDFTree = (data: []) => {}; export const buildUDFTree = (data: []) => {
};
...@@ -165,7 +165,7 @@ const DataStudio = (props: any) => { ...@@ -165,7 +165,7 @@ const DataStudio = (props: any) => {
const info = res as { [key: string]: any }; const info = res as { [key: string]: any };
const changed = Object.keys(params.taskData).some((key) => { const changed = Object.keys(params.taskData).some((key) => {
// ignore this property // ignore this property
if (['updateTime', 'createTime', 'jobInstanceId'].includes(key)) { if (['updateTime', 'createTime', 'jobInstanceId', 'useResult', 'maxRowNum', 'useChangeLog', 'useAutoCancel'].includes(key)) {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment