Skip to content

Commit cad4e56

Browse files
authored
display current root network name on root node (#3081)
* display current root network name on root node --------- Signed-off-by: SOUISSI Maissa (Externe) <[email protected]>
1 parent 366d737 commit cad4e56

File tree

8 files changed

+14
-46
lines changed

8 files changed

+14
-46
lines changed

src/components/graph/network-modification-tree-model.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,4 @@ export default class NetworkModificationTreeModel {
274274
this.isAnyNodeBuilding =
275275
this.treeNodes.find((node) => node?.data?.globalBuildStatus === BUILD_STATUS.BUILDING) !== undefined;
276276
}
277-
278-
setCaseName(newCaseName: string) {
279-
if (this.treeNodes.length > 0 && this.treeNodes[0].data && newCaseName) {
280-
const nodeWithOldName = this.treeNodes[0];
281-
//check if the node we are modifying is a ROOT node
282-
if (isReactFlowRootNodeData(nodeWithOldName)) {
283-
this.treeNodes[0] = {
284-
...nodeWithOldName,
285-
data: {
286-
...nodeWithOldName.data,
287-
caseName: newCaseName,
288-
},
289-
};
290-
}
291-
}
292-
}
293277
}

src/components/graph/nodes/root-node.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ const styles = {
4242

4343
const RootNode = (props: NodeProps<RootNodeType>) => {
4444
const currentNode = useSelector((state: AppState) => state.currentTreeNode);
45+
const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetworkUuid);
46+
const rootNetworks = useSelector((state: AppState) => state.rootNetworks);
47+
48+
const currentRootNetwork = rootNetworks.find(
49+
(rootNetwork) => rootNetwork.rootNetworkUuid === currentRootNetworkUuid
50+
);
51+
4552
const isSelectedNode = () => {
4653
return props.id === currentNode?.id;
4754
};
@@ -57,7 +64,7 @@ const RootNode = (props: NodeProps<RootNodeType>) => {
5764
}}
5865
isConnectable={false}
5966
/>
60-
<Tooltip title={props.data.caseName} placement="top" disableHoverListener={!props.data.caseName}>
67+
<Tooltip title={currentRootNetwork?.name} placement="top" disableHoverListener={!currentRootNetwork?.name}>
6168
<IconButton sx={isSelectedNode() ? styles.rootSelected : styles.root}>
6269
{(props.data.globalBuildStatus === BUILD_STATUS.BUILDING && <CircularProgress size={24} />) || (
6370
<PhotoIcon />

src/components/graph/tree-node.type.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export type NetworkModificationNodeData = AbstractNode & {
6565
nodeType?: NetworkModificationNodeType;
6666
};
6767

68-
type NodeCommonData = {
68+
export type NodeCommonData = {
6969
label: string;
7070
globalBuildStatus?: BUILD_STATUS;
7171
description?: string;
@@ -78,8 +78,7 @@ export type ModificationNode = Node<ReactFlowModificationNodeData, NodeType.NETW
7878
id: UUID;
7979
};
8080

81-
export type ReactFlowRootNodeData = NodeCommonData & { caseName?: string };
82-
export type RootNode = Node<ReactFlowRootNodeData, NodeType.ROOT> & { id: UUID };
81+
export type RootNode = Node<NodeCommonData, NodeType.ROOT> & { id: UUID };
8382

8483
export type CurrentTreeNode = ModificationNode | RootNode;
8584

src/components/graph/util/model-functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import type NetworkModificationTreeModel from '../network-modification-tree-mode
1111
import {
1212
CurrentTreeNode,
1313
NetworkModificationNodeData,
14+
NodeCommonData,
1415
NodeType,
1516
ReactFlowModificationNodeData,
16-
ReactFlowRootNodeData,
1717
RootNodeData,
1818
} from '../tree-node.type';
1919

@@ -35,7 +35,7 @@ export function isRootNode(node: NetworkModificationNodeData | RootNodeData): no
3535
return node.type === NodeType.ROOT;
3636
}
3737

38-
function convertRootNodeToReactFlowModelNode(node: NetworkModificationNodeData | RootNodeData): ReactFlowRootNodeData {
38+
function convertRootNodeToReactFlowModelNode(node: NetworkModificationNodeData | RootNodeData): NodeCommonData {
3939
return {
4040
label: node.name,
4141
description: node.description ?? undefined,

src/components/study-container.jsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import NetworkModificationTreeModel from './graph/network-modification-tree-mode
3232
import { getFirstNodeOfType, isNodeBuilt, isNodeRenamed, isSameNode } from './graph/util/model-functions';
3333
import { BUILD_STATUS } from './network/constants';
3434
import { useAllComputingStatus } from './computing-status/use-all-computing-status';
35-
import { fetchCaseName } from '../services/study/index';
3635
import { fetchNetworkModificationTree } from '../services/study/tree-subtree';
3736
import { fetchNetworkExistence, fetchRootNetworkIndexationStatus } from '../services/study/network';
3837
import { fetchStudy, recreateStudyNetwork, reindexAllRootNetwork } from 'services/study/study';
@@ -293,19 +292,8 @@ export function StudyContainer({ view, onChangeTab }) {
293292
.then((tree) => {
294293
const networkModificationTreeModel = new NetworkModificationTreeModel();
295294
networkModificationTreeModel.setTreeElements(tree);
295+
dispatch(loadNetworkModificationTreeSuccess(networkModificationTreeModel));
296296

297-
fetchCaseName(studyUuid, currentRootNetworkUuid)
298-
.then((res) => {
299-
if (res) {
300-
networkModificationTreeModel.setCaseName(res);
301-
dispatch(loadNetworkModificationTreeSuccess(networkModificationTreeModel));
302-
}
303-
})
304-
.catch((err) => {
305-
snackWarning({
306-
headerId: 'CaseNameLoadError',
307-
});
308-
});
309297
// If a current node is already defined then override it cause it could have diferent status in different root networks
310298
if (currentNodeRef.current) {
311299
// Find the updated current node in the tree model
@@ -348,7 +336,7 @@ export function StudyContainer({ view, onChangeTab }) {
348336
.finally(() => console.debug('Network modification tree loading finished'));
349337
// Note: studyUuid and dispatch don't change
350338
},
351-
[studyUuid, currentRootNetworkUuid, dispatch, snackError, snackWarning]
339+
[studyUuid, currentRootNetworkUuid, dispatch, snackError]
352340
);
353341

354342
const checkRootNetworkIndexation = useCallback(() => {

src/services/study/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,6 @@ export function buildNode(studyUuid: UUID, currentNodeUuid: UUID, currentRootNet
295295
return backendFetchText(url, { method: 'post' });
296296
}
297297

298-
export function fetchCaseName(studyUuid: UUID, rootNetworkUuid: UUID) {
299-
console.info('Fetching case name');
300-
const url = getStudyUrl(studyUuid) + '/root-networks/' + encodeURIComponent(rootNetworkUuid) + '/case/name';
301-
console.debug(url);
302-
303-
return backendFetchText(url);
304-
}
305-
306298
export function isNodeExists(studyUuid: UUID, nodeName: string) {
307299
const existsNodeUrl =
308300
getStudyUrl(studyUuid) +

src/translations/en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@
515515
"exportCaseOnNode": "Export case",
516516
"NetworkModificationTreeLoadError": "An error occurred while loading network modification tree",
517517
"MapEquipmentsLoadError": "An error occurred while loading network map",
518-
"CaseNameLoadError": "An error occurred while loading case name",
519518
"StudyUnrecoverableStateRecreate": "Your study had a problem and has been recreated from initial data",
520519
"StudyUnrecoverableState": "Your study had a problem and can not be recreated",
521520
"NodeCreateError": "An error occurred while creating node",

src/translations/fr.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@
515515
"exportCaseOnNode": "Exporter la situation",
516516
"NetworkModificationTreeLoadError": "Une erreur est survenue lors du chargement de l'arbre de modifications de réseau",
517517
"MapEquipmentsLoadError": "Une erreur est survenue lors du chargement des données de l'image réseau",
518-
"CaseNameLoadError": "Une erreur est survenue lors de la récupération du nom de la situation",
519518
"StudyUnrecoverableStateRecreate": "Votre étude a rencontré un problème et a été recréée à partir des données initiales",
520519
"StudyUnrecoverableState": "Impossible de récupérer le réseau de l'étude. Veuillez sélectionner une nouvelle situation initiale",
521520
"NodeCreateError": "Une erreur est survenue lors de la création du nœud",

0 commit comments

Comments
 (0)