Skip to content

Commit

Permalink
[issue_466][taier-ui]fix folderTree (#487)
Browse files Browse the repository at this point in the history
* [issue_466][taier-ui]fix save tab didn't change status of tab in dataSync

* [issue_466][taier-ui]add catalogueService and breadcrumbService
  • Loading branch information
mortalYoung committed May 20, 2022
1 parent 627ef64 commit b283afc
Show file tree
Hide file tree
Showing 14 changed files with 490 additions and 439 deletions.
11 changes: 10 additions & 1 deletion taier-ui/src/components/dataSync/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,16 @@ function DataSync({ current }: molecule.model.IEditor) {
};

const handleSaveTab = () => {
saveTask();
saveTask()
.then((res) => res?.data?.id)
.then((id) => {
if (id !== undefined) {
molecule.editor.updateTab({
id: current!.tab!.id,
status: undefined,
});
}
});
};

// 获取当前任务的数据
Expand Down
9 changes: 6 additions & 3 deletions taier-ui/src/components/folderPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import molecule from '@dtinsight/molecule';
import resourceManagerTree from '@/services/resourceManagerService';
import functionManagerService from '@/services/functionManagerService';
import type { TreeSelectProps } from 'antd/lib/tree-select';
import { loadTreeNode } from '@/utils/extensions';
import { catalogueService } from '@/services';

interface FolderPickerProps extends CustomTreeSelectProps {
dataType: CATELOGUE_TYPE;
Expand All @@ -35,9 +35,12 @@ interface FolderPickerProps extends CustomTreeSelectProps {
export default function FolderPicker(props: FolderPickerProps) {
const [flag, rerender] = useState(false);
const loadDataAsync: TreeSelectProps['loadData'] = async (treeNode) => {
const currentData = treeNode.props.dataRef.data;
const currentData = treeNode.props.dataRef;
if (!currentData.children?.length) {
await loadTreeNode(currentData, props.dataType);
await catalogueService.loadTreeNode(
{ id: currentData?.data?.id, catalogueType: currentData?.data?.catalogueType },
props.dataType,
);
rerender((f) => !f);
}
};
Expand Down
3 changes: 2 additions & 1 deletion taier-ui/src/components/task/editFolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ export default connect(
rules={[
{
max: 64,
message: '任务名称不得超过20个字符!',
message: '目录名称不得超过64个字符!',
},
{
required: true,
message: '文件夹名称不能为空',
},
]}
>
Expand Down
4 changes: 4 additions & 0 deletions taier-ui/src/constant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import type { ISubMenuProps } from '@dtinsight/molecule/esm/components';
* ID 集合
*/
export enum ID_COLLECTIONS {
/**
* 创建任务
*/
TASK_CREATE_ID = 'task.create',
/**
* 任务运行按钮
*/
Expand Down
63 changes: 2 additions & 61 deletions taier-ui/src/extensions/catalogue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,68 +16,9 @@
* limitations under the License.
*/

import { CATELOGUE_TYPE } from '@/constant';
import functionManagerService from '@/services/functionManagerService';
import resourceManagerService from '@/services/resourceManagerService';
import { transformCatalogueToTree, loadTreeNode, getCatalogueViaNode } from '@/utils/extensions';
import molecule from '@dtinsight/molecule';
import type { UniqueId } from '@dtinsight/molecule/esm/common/types';
import type { IExtension } from '@dtinsight/molecule/esm/model';
import { getRootFolderViaSource } from '@/utils';

/**
* 获取根目录
*/
export function getCatalogueTree() {
getCatalogueViaNode({ id: 0 }).then(async (res) => {
if (!res) return;
const { children } = res;
if (!children) return;

const taskData = getRootFolderViaSource(children, CATELOGUE_TYPE.TASK);
const resourceData = getRootFolderViaSource(children, CATELOGUE_TYPE.RESOURCE);
const funcData = getRootFolderViaSource(children, CATELOGUE_TYPE.FUNCTION);

// 资源根目录
if (resourceData) {
const resourceRoot = resourceData;
const resourceNode = transformCatalogueToTree(
resourceRoot,
CATELOGUE_TYPE.RESOURCE,
true,
)!;
resourceManagerService.add(resourceNode);
}

// 函数根目录
if (funcData) {
const funcRoot = funcData;
const functionNode = transformCatalogueToTree(funcRoot, CATELOGUE_TYPE.FUNCTION, true)!;
functionManagerService.add(functionNode);

// sql 节点必存在 catalogueType,对所有的节点都求一遍子树
const SqlNodes = funcRoot?.children?.filter((child: any) => child.catalogueType) || [];
SqlNodes.forEach((sqlNode) => {
loadTreeNode(sqlNode, CATELOGUE_TYPE.FUNCTION);
});
}

// 任务开发根目录
if (taskData) {
const taskRootFolder = taskData?.children?.[0];
if (taskRootFolder) {
const taskNode = transformCatalogueToTree(
taskRootFolder,
CATELOGUE_TYPE.TASK,
true,
)!;

molecule.folderTree.add(taskNode);
loadTreeNode(taskRootFolder, CATELOGUE_TYPE.TASK);
}
}
});
}
import { catalogueService } from '@/services';

/**
* This is for getting the root catalogues including the resouces and tasks and functions
Expand All @@ -86,7 +27,7 @@ export default class CatalogueExtension implements IExtension {
id: UniqueId = 'Catalogue';
name: string = 'Catalogue';
activate(): void {
getCatalogueTree();
catalogueService.loadRootFolder();
}
dispose(): void {
throw new Error('Method not implemented.');
Expand Down
Loading

0 comments on commit b283afc

Please sign in to comment.