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 @@
import {
buildProjectTree,
generateList,
generateList, getLeafKeyList,
getParentKey
} from '@/pages/DataStudio/LeftContainer/Project/function';
import { StateType } from '@/pages/DataStudio/model';
......@@ -80,10 +80,11 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
const onExpand = (expandedKeys: Key[]) => {
setExpandedKeys(expandedKeys);
};
const expandAll = () => {
const map = data.filter((x: { isLeaf: any }) => !x.isLeaf).map((x: { key: any }) => x.key);
setExpandedKeys(map);
setExpandedKeys(getLeafKeyList(projectData));
};
const btn = BtnRoute['menu.datastudio.project'];
btn[1].onClick = expandAll;
......
import { getTabIcon } from '@/pages/DataStudio/MiddleContainer/function';
import { Catalogue } from '@/types/Studio/data.d';
import { searchTreeNode } from '@/utils/function';
import {getTabIcon} from '@/pages/DataStudio/MiddleContainer/function';
import {Catalogue} from '@/types/Studio/data.d';
import {searchTreeNode} from '@/utils/function';
export const generateList = (data: any, list: any[]) => {
for (const element of data) {
const node = element;
const { name, id, parentId, level } = node;
list.push({ name, id, key: id, title: name, parentId, level });
const {name, id, parentId, level} = node;
list.push({name, id, key: id, title: name, parentId, level});
if (node.children) {
generateList(node.children, list);
}
}
return list;
};
export const getParentKey = (key: number | string, tree: any): any => {
let parentKey;
for (const element of tree) {
......@@ -28,6 +29,19 @@ export const getParentKey = (key: number | string, tree: any): any => {
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
* @param {Catalogue[]} data
......@@ -43,29 +57,30 @@ export const buildProjectTree = (
): any =>
data
? data.map((item: Catalogue) => {
const currentPath = path ? [...path, item.name] : [item.name];
return {
// isLeaf: (item.type && item.children.length === 0) ,
isLeaf: item.isLeaf,
name: item.name,
parentId: item.parentId,
label: searchTreeNode(item.name, searchValue),
icon: item.type && item.children.length === 0 && getTabIcon(item.type, 20),
value: item.id,
path: currentPath,
type: item.type,
title: <>{searchTreeNode(item.name, searchValue)}</>,
fullInfo: item,
key: item.id,
id: item.id,
taskId: item.taskId,
children: buildProjectTree(item.children, searchValue, currentPath)
};
})
const currentPath = path ? [...path, item.name] : [item.name];
return {
// isLeaf: (item.type && item.children.length === 0) ,
isLeaf: item.isLeaf,
name: item.name,
parentId: item.parentId,
label: searchTreeNode(item.name, searchValue),
icon: item.type && item.children.length === 0 && getTabIcon(item.type, 20),
value: item.id,
path: currentPath,
type: item.type,
title: <>{searchTreeNode(item.name, searchValue)}</>,
fullInfo: item,
key: item.id,
id: item.id,
taskId: item.taskId,
children: buildProjectTree(item.children, searchValue, currentPath)
};
})
: [];
export const isUDF = (jobType: string) => {
return jobType === 'Scala' || jobType === 'Python' || jobType === 'Java';
};
export const buildUDFTree = (data: []) => {};
export const buildUDFTree = (data: []) => {
};
......@@ -165,7 +165,7 @@ const DataStudio = (props: any) => {
const info = res as { [key: string]: any };
const changed = Object.keys(params.taskData).some((key) => {
// ignore this property
if (['updateTime', 'createTime', 'jobInstanceId'].includes(key)) {
if (['updateTime', 'createTime', 'jobInstanceId', 'useResult', 'maxRowNum', 'useChangeLog', 'useAutoCancel'].includes(key)) {
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