Skip to content

Commit

Permalink
fix-delete-task-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Dec 21, 2023
1 parent e50a3b5 commit 5eac360
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 13 additions & 3 deletions dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
import JobModal from '@/pages/DataStudio/LeftContainer/Project/JobModal';
import JobTree from '@/pages/DataStudio/LeftContainer/Project/JobTree';
import {
DataStudioParams,
DataStudioParams, DataStudioTabsItemType,
StateType,
STUDIO_MODEL,
STUDIO_MODEL_ASYNC
Expand Down Expand Up @@ -61,7 +61,8 @@ const Project: React.FC = (props: connect) => {
const {
dispatch,
project: { expandKeys, selectKey },
tabs: { panes, activeKey }
tabs: { panes, activeKey },
tabs
} = props;

const [projectState, setProjectState] = useState<ProjectState>(InitProjectState);
Expand Down Expand Up @@ -262,7 +263,6 @@ const Project: React.FC = (props: connect) => {
if (!isLeaf) {
await handleRemoveById(API_CONSTANTS.DELETE_CATALOGUE_BY_ID_URL, key, () => {
dispatch({ type: STUDIO_MODEL_ASYNC.queryProject });
// TODO: 如果打开的 tag 中包含了这个 key 则更新 dav 的 tag 数据 删除此项 && 有一个 bug Dinky/src/pages/DataStudio/RightContainer/JobInfo/index.tsx:55 -> Cannot read properties of undefined (reading 'id')
});
return;
}
Expand All @@ -279,7 +279,17 @@ const Project: React.FC = (props: connect) => {
cancelText: l('button.cancel'),
onOk: async () => {
await handleRemoveById(API_CONSTANTS.DELETE_CATALOGUE_BY_ID_URL, key, () => {
const currentTabs = getTabByTaskId(panes, key) as DataStudioTabsItemType;
dispatch({ type: STUDIO_MODEL.removeTag, payload: taskId });
const previousTabs = panes[panes.length> 1 ? panes.length - 1 :0];
const { key: currentKey } = currentTabs;
if (currentKey === activeKey && panes.length >= 1) {
dispatch({ type: STUDIO_MODEL.updateTabsActiveKey, payload: previousTabs?.key });
}
if (panes.length === 0) {
dispatch({ type: STUDIO_MODEL.updateTabsActiveKey, payload: '' });
dispatch({ type: STUDIO_MODEL.updateActiveBreadcrumbTitle, payload: '' });
}
dispatch({ type: STUDIO_MODEL_ASYNC.queryProject });
});
}
Expand Down
10 changes: 10 additions & 0 deletions dinky-web/src/pages/DataStudio/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export type ModelType = {
updateProjectExpandKey: Reducer<StateType>;
updateProjectSelectKey: Reducer<StateType>;
updateTabsActiveKey: Reducer<StateType>;
updateActiveBreadcrumbTitle: Reducer<StateType>;
closeTab: Reducer<StateType>;
removeTag: Reducer<StateType>;
addTab: Reducer<StateType>;
Expand Down Expand Up @@ -711,6 +712,15 @@ const Model: ModelType = {
}
};
},
updateActiveBreadcrumbTitle(state, { payload }) {
return {
...state,
tabs: {
...state.tabs,
activeBreadcrumbTitle: payload
}
};
},

/**
* 添加tab 如果存在则不添加
Expand Down

0 comments on commit 5eac360

Please sign in to comment.