Commit 5c696e96 authored by wenmo's avatar wenmo

[Fix-542][web] Fix the name of tab can't be modified when modify task name

parent a44b08df
......@@ -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);
......@@ -245,7 +246,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
isLeaf: false,
parentId: node?.id,
});
getTreeData();
} else {
message.error('只能在目录上创建目录');
}
......@@ -258,7 +258,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
isLeaf: false,
parentId: 0,
});
getTreeData();
};
const toSubmit = (node: TreeDataNode | undefined) => {
......@@ -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) => {
......@@ -312,7 +311,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
setTaskFormValues({
parentId: node?.id,
});
//getTreeData();
} else {
message.error('只能在目录上创建作业');
}
......@@ -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={() => {
......
......@@ -191,6 +191,7 @@ export type ModelType = {
saveChart: Reducer<StateType>;
changeTaskStep: Reducer<StateType>;
changeTaskJobInstance: Reducer<StateType>;
renameTab: Reducer<StateType>;
};
};
......@@ -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,
};
},
},
};
......
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