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) => { ...@@ -75,6 +75,7 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
const [isCreate, setIsCreate] = useState<boolean>(true); const [isCreate, setIsCreate] = useState<boolean>(true);
const [catalogueFormValues, setCatalogueFormValues] = useState({}); const [catalogueFormValues, setCatalogueFormValues] = useState({});
const [taskFormValues, setTaskFormValues] = useState({}); const [taskFormValues, setTaskFormValues] = useState({});
const [activeNode, setActiveNode] = useState({});
const [rightClickNode, setRightClickNode] = useState<TreeDataNode>(); const [rightClickNode, setRightClickNode] = useState<TreeDataNode>();
const [available, setAvailable] = useState<boolean>(true); const [available, setAvailable] = useState<boolean>(true);
const [isUploadModalVisible, setIsUploadModalVisible] = useState(false); const [isUploadModalVisible, setIsUploadModalVisible] = useState(false);
...@@ -245,7 +246,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -245,7 +246,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
isLeaf: false, isLeaf: false,
parentId: node?.id, parentId: node?.id,
}); });
getTreeData();
} else { } else {
message.error('只能在目录上创建目录'); message.error('只能在目录上创建目录');
} }
...@@ -258,7 +258,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -258,7 +258,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
isLeaf: false, isLeaf: false,
parentId: 0, parentId: 0,
}); });
getTreeData();
}; };
const toSubmit = (node: TreeDataNode | undefined) => { const toSubmit = (node: TreeDataNode | undefined) => {
...@@ -279,14 +278,14 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -279,14 +278,14 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
}); });
}; };
const toRename = (node: TreeDataNode | undefined) => { const toRename = (node: TreeDataNode) => {
handleUpdateCatalogueModalVisible(true); handleUpdateCatalogueModalVisible(true);
setIsCreate(false); setIsCreate(false);
setActiveNode(node);
setCatalogueFormValues({ setCatalogueFormValues({
id: node?.id, id: node?.id,
name: node?.name, name: node?.name,
}); });
getTreeData();
}; };
const toCut = (node: TreeDataNode | undefined) => { const toCut = (node: TreeDataNode | undefined) => {
...@@ -312,7 +311,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -312,7 +311,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
setTaskFormValues({ setTaskFormValues({
parentId: node?.id, parentId: node?.id,
}); });
//getTreeData();
} else { } else {
message.error('只能在目录上创建作业'); message.error('只能在目录上创建作业');
} }
...@@ -523,7 +521,14 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => { ...@@ -523,7 +521,14 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
if (success) { if (success) {
handleUpdateCatalogueModalVisible(false); handleUpdateCatalogueModalVisible(false);
setCatalogueFormValues({}); setCatalogueFormValues({});
getTreeData() getTreeData();
dispatch({
type: "Studio/renameTab",
payload: {
key: value.id,
name: <>{activeNode.icon} {value.name}</>
},
});
} }
}} }}
onCancel={() => { onCancel={() => {
......
...@@ -191,6 +191,7 @@ export type ModelType = { ...@@ -191,6 +191,7 @@ export type ModelType = {
saveChart: Reducer<StateType>; saveChart: Reducer<StateType>;
changeTaskStep: Reducer<StateType>; changeTaskStep: Reducer<StateType>;
changeTaskJobInstance: Reducer<StateType>; changeTaskJobInstance: Reducer<StateType>;
renameTab: Reducer<StateType>;
}; };
}; };
...@@ -534,6 +535,36 @@ const Model: ModelType = { ...@@ -534,6 +535,36 @@ const Model: ModelType = {
tabs: {...newTabs}, 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