Skip to content

Commit

Permalink
[Fix-542][web] Fix the name of tab can't be modified when modify task…
Browse files Browse the repository at this point in the history
… name
  • Loading branch information
aiwenmo committed May 27, 2022
1 parent a44b08d commit 5c696e9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
17 changes: 11 additions & 6 deletions dlink-web/src/components/Studio/StudioTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
const [isCreate, setIsCreate] = useState<boolean>(true);
const [catalogueFormValues, setCatalogueFormValues] = useState({});
const [taskFormValues, setTaskFormValues] = useState({});
const [activeNode, setActiveNode] = useState({});
const [rightClickNode, setRightClickNode] = useState<TreeDataNode>();
const [available, setAvailable] = useState<boolean>(true);
const [isUploadModalVisible, setIsUploadModalVisible] = useState(false);
Expand Down Expand Up @@ -245,7 +246,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
isLeaf: false,
parentId: node?.id,
});
getTreeData();
} else {
message.error('只能在目录上创建目录');
}
Expand All @@ -258,7 +258,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
isLeaf: false,
parentId: 0,
});
getTreeData();
};

const toSubmit = (node: TreeDataNode | undefined) => {
Expand All @@ -279,14 +278,14 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
});
};

const toRename = (node: TreeDataNode | undefined) => {
const toRename = (node: TreeDataNode) => {
handleUpdateCatalogueModalVisible(true);
setIsCreate(false);
setActiveNode(node);
setCatalogueFormValues({
id: node?.id,
name: node?.name,
});
getTreeData();
};

const toCut = (node: TreeDataNode | undefined) => {
Expand All @@ -312,7 +311,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
setTaskFormValues({
parentId: node?.id,
});
//getTreeData();
} else {
message.error('只能在目录上创建作业');
}
Expand Down Expand Up @@ -523,7 +521,14 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
if (success) {
handleUpdateCatalogueModalVisible(false);
setCatalogueFormValues({});
getTreeData()
getTreeData();
dispatch({
type: "Studio/renameTab",
payload: {
key: value.id,
name: <>{activeNode.icon} {value.name}</>
},
});
}
}}
onCancel={() => {
Expand Down
31 changes: 31 additions & 0 deletions dlink-web/src/pages/DataStudio/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export type ModelType = {
saveChart: Reducer<StateType>;
changeTaskStep: Reducer<StateType>;
changeTaskJobInstance: Reducer<StateType>;
renameTab: Reducer<StateType>;
};
};

Expand Down Expand Up @@ -534,6 +535,36 @@ const Model: ModelType = {
tabs: {...newTabs},
};
},
renameTab(state, {payload}) {
const newTabs = state.tabs;
let newCurrent = state.current;
for (let i = 0; i < newTabs.panes.length; i++) {
if (newTabs.panes[i].key == payload.key) {
newTabs.panes[i].title = payload.name;
newTabs.panes[i].task.alias = payload.name;
}
if (newTabs.panes[i].key == newCurrent.key) {
newCurrent.title = payload.name;
newCurrent.task.alias = payload.name;
}
}
if(newTabs.panes.length == 0){
return {
...state,
current: undefined,
tabs: newTabs,
currentPath: ['引导页'],
};
}
return {
...state,
current: {
...newCurrent,
},
tabs: {...newTabs},
currentPath: newCurrent.path,
};
},
},
};

Expand Down

0 comments on commit 5c696e9

Please sign in to comment.