Skip to content

Commit

Permalink
Merge branch 'DataLinkDC:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 authored Oct 30, 2023
2 parents 4bd12b3 + 86473a3 commit c28b157
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ const JobModal: React.FC<JobModalProps> = (props) => {
formData.configJson.udfConfig.templateId = selectKeys[selectKeys.length - 1];
}
onSubmit({ ...values, ...formData } as Catalogue);

};

const renderForm = () => {
return (
<>
<ProFormSelect
{!values.id && <ProFormSelect
name={'type'}
label={l('catalog.type')}
tooltip={l('catalog.type.tip')}
Expand All @@ -114,7 +115,7 @@ const JobModal: React.FC<JobModalProps> = (props) => {
disabled={!!values.id}
placeholder={l('catalog.type.placeholder')}
rules={[{ required: true, message: l('catalog.type.placeholder') }]}
/>
/>}
<ProFormText
name='name'
label={l('catalog.name')}
Expand Down
41 changes: 32 additions & 9 deletions dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import FolderModal from '@/pages/DataStudio/LeftContainer/Project/FolderModal';
import JobModal from '@/pages/DataStudio/LeftContainer/Project/JobModal';
import JobTree from '@/pages/DataStudio/LeftContainer/Project/JobTree';
import { StateType, STUDIO_MODEL, STUDIO_MODEL_ASYNC } from '@/pages/DataStudio/model';
import {DataStudioParams, StateType, STUDIO_MODEL, STUDIO_MODEL_ASYNC} from '@/pages/DataStudio/model';
import {
handleAddOrUpdate,
handleOption,
Expand All @@ -41,11 +41,15 @@ import { Modal, Typography } from 'antd';
import { MenuInfo } from 'rc-menu/es/interface';
import React, { Key, useEffect, useState } from 'react';
import { connect } from 'umi';
import {getCurrentTab, getTabByTaskId, mapDispatchToProps} from "@/pages/DataStudio/function";

const { Text } = Typography;

const Project: React.FC = (props: connect) => {
const { dispatch } = props;
const {
dispatch,
tabs: { panes, activeKey }
} = props;

const [projectState, setProjectState] = useState<ProjectState>(InitProjectState);

Expand Down Expand Up @@ -161,13 +165,13 @@ const Project: React.FC = (props: connect) => {
options.parentId = projectState.isCreateTask
? projectState.value.id
: projectState.isEdit
? projectState.value.parentId
: options.parentId;
? projectState.value.parentId
: options.parentId;
} else {
options.url = API_CONSTANTS.SAVE_OR_UPDATE_CATALOGUE_URL;
}

const result = await handleAddOrUpdate(
handleAddOrUpdate(
options.url,
{
...values,
Expand All @@ -176,6 +180,29 @@ const Project: React.FC = (props: connect) => {
},
() => {},
() => {
setProjectState((prevState) => ({
...prevState
}));
dispatch({ type: STUDIO_MODEL_ASYNC.queryProject });
if (projectState.isEdit) {
const {id} = values;
const currentTabs = getTabByTaskId(panes, id)
if(currentTabs){
currentTabs.label = values.name;
// currentTabs.params.taskData.name = values.name;
const {params} = currentTabs;
const {taskData} = params;
if(taskData){
taskData.name = values.name;
}
}
dispatch({ type: STUDIO_MODEL.saveTabs, payload: { ...props.tabs }});
// update active breadcrumb title
if(activeKey === currentTabs?.key){
dispatch({ type: STUDIO_MODEL.updateTabsActiveKey, payload: activeKey});
}
}
// close job modal by project state
setProjectState((prevState) => ({
...prevState,
isCreateSub: false,
Expand All @@ -184,10 +211,6 @@ const Project: React.FC = (props: connect) => {
isCreateTask: false,
isCut: false
}));
dispatch({ type: STUDIO_MODEL_ASYNC.queryProject });
if (projectState.isRename) {
// todo: 如果是重命名/修改(修改了名字), 则需要 更新 tab 的 label
}
}
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

import { getCurrentData } from '@/pages/DataStudio/function';
import {getCurrentData, getCurrentTab} from '@/pages/DataStudio/function';
import { StateType, TaskDataType } from '@/pages/DataStudio/model';
import { l } from '@/utils/intl';
import { Descriptions } from 'antd';
Expand All @@ -27,16 +27,15 @@ import { connect } from 'umi';

const JobInfo = (props: any) => {
const {
tabs: { panes, activeKey }
tabs: { panes, activeKey, activeBreadcrumbTitle }
} = props;

const [currentInfo, setCurrentInfo] = useState<Partial<TaskDataType>>(
getCurrentData(panes, activeKey) ?? {}
);

useEffect(() => {
setCurrentInfo({ ...currentInfo, ...getCurrentData(panes, activeKey) });
}, [activeKey, panes]);
setCurrentInfo({ ...getCurrentData(panes, activeKey) });
}, [activeKey, activeBreadcrumbTitle]);

return (
<div style={{ paddingInline: 8 }}>
Expand Down
15 changes: 15 additions & 0 deletions dinky-web/src/pages/DataStudio/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ export function getCurrentTab(
}
}

export function getTabByTaskId(
panes: TabsItemType[],
id: number
): DataStudioTabsItemType | MetadataTabsItemType | undefined {
const item = panes.find((item) => item.treeKey === id);
switch (item?.type) {
case 'project':
return item as DataStudioTabsItemType;
case 'metadata':
return item as MetadataTabsItemType;
default:
return undefined;
}
}

export const getCurrentData = (
panes: TabsItemType[],
activeKey: string
Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/pages/DataStudio/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export interface TabsItemType {
type: TabsPageType;
subType?: TabsPageSubType;
key: string;
treeKey: string;
treeKey: number;
value: string;
icon: any;
closable: boolean;
Expand Down

0 comments on commit c28b157

Please sign in to comment.