Skip to content

Commit cff86be

Browse files
author
Slimane AMAR
committed
Merge branch 'main'
1 parent db87e86 commit cff86be

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

src/components/grid-layout/cards/diagrams/diagram.type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type NetworkAreaDiagramParams = DiagramBaseParams & {
3333
nadConfigUuid: UUID | undefined;
3434
initializationNadConfigUuid?: UUID; // used for initialization, not saved
3535
filterUuid: UUID | undefined;
36+
currentFilterUuid?: UUID; // used for initialization, not saved
3637
voltageLevelIds: string[];
3738
voltageLevelToExpandIds: string[];
3839
voltageLevelToOmitIds: string[];
@@ -59,6 +60,7 @@ export type NetworkAreaDiagram = DiagramBase & {
5960
type: DiagramType.NETWORK_AREA_DIAGRAM;
6061
nadConfigUuid: UUID | undefined;
6162
filterUuid: UUID | undefined;
63+
currentFilterUuid: UUID | undefined;
6264
voltageLevelIds: string[];
6365
voltageLevelToExpandIds: string[];
6466
voltageLevelToOmitIds: string[];

src/components/grid-layout/cards/diagrams/networkAreaDiagram/network-area-diagram-content.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ type NetworkAreaDiagramContentProps = {
6565
readonly svgScalingFactor?: number;
6666
readonly svgVoltageLevels?: string[];
6767
readonly loadingState: boolean;
68+
readonly isNadCreationFromFilter: boolean;
6869
readonly visible: boolean;
6970
readonly onVoltageLevelClick: (diagramParams: VoltageLevelDiagramParams) => void;
7071
readonly onUpdateVoltageLevels: (params: {
7172
voltageLevelIds: string[];
7273
voltageLevelToExpandIds: string[];
7374
voltageLevelToOmitIds: string[];
7475
}) => void;
76+
readonly onUpdateVoltageLevelsFromFilter: (filterUuid: UUID) => void;
7577
readonly onUpdatePositions: (positions: DiagramConfigPosition[]) => void;
7678
readonly onReplaceNad: (name: string, nadConfigUuid?: UUID, filterUuid?: UUID) => void;
7779
readonly onSaveNad?: () => void;
@@ -86,13 +88,15 @@ function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
8688
positions,
8789
onVoltageLevelClick,
8890
onUpdateVoltageLevels,
91+
onUpdateVoltageLevelsFromFilter,
8992
onUpdatePositions,
9093
onReplaceNad,
9194
svg,
9295
svgMetadata,
9396
svgScalingFactor,
9497
svgVoltageLevels,
9598
loadingState,
99+
isNadCreationFromFilter,
96100
showInSpreadsheet,
97101
onSaveNad,
98102
} = props;
@@ -317,6 +321,13 @@ function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
317321
[voltageLevelIds, voltageLevelToExpandIds, voltageLevelToOmitIds, onUpdateVoltageLevels]
318322
);
319323

324+
const handleAddVoltageLevelsFromFilter = useCallback(
325+
(filterUuid: UUID) => {
326+
onUpdateVoltageLevelsFromFilter(filterUuid);
327+
},
328+
[onUpdateVoltageLevelsFromFilter]
329+
);
330+
320331
const handleExpandVoltageLevelId = useCallback(
321332
(voltageLevelIdToExpand: string) => {
322333
onUpdateVoltageLevels({
@@ -516,9 +527,11 @@ function NetworkAreaDiagramContent(props: NetworkAreaDiagramContentProps) {
516527
onToggleEditNadMode={handleSetIsEditNadMode}
517528
onExpandAllVoltageLevels={handleExpandAllVoltageLevels}
518529
onAddVoltageLevel={handleAddVoltageLevel}
530+
onAddVoltageLevelsFromFilter={handleAddVoltageLevelsFromFilter}
519531
onToggleShowLabels={handleToggleShowLabels}
520532
isShowLabels={showLabels}
521533
isDiagramLoading={loadingState}
534+
isNadCreationFromFilter={isNadCreationFromFilter}
522535
svgVoltageLevels={svgVoltageLevels}
523536
onFocusVoltageLevel={handleFocusVoltageLevel}
524537
/>

src/components/workspace/diagrams/nad/use-nad-diagram.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const useNadDiagram = ({
4646
svg: null,
4747
nadConfigUuid: diagramMetadata.nadConfigUuid,
4848
filterUuid: diagramMetadata.filterUuid,
49+
currentFilterUuid: diagramMetadata.currentFilterUuid,
4950
voltageLevelIds: diagramMetadata.initialVoltageLevelIds || [],
5051
positions: [],
5152
voltageLevelToExpandIds: [],
@@ -197,7 +198,7 @@ export const useNadDiagram = ({
197198
nadConfigUuid: useSavedConfig
198199
? diagramMetadata.savedWorkspaceConfigUuid
199200
: currentDiagram.nadConfigUuid,
200-
filterUuid: currentDiagram.filterUuid,
201+
filterUuid: currentDiagram.currentFilterUuid ?? currentDiagram.filterUuid,
201202
...(useSavedConfig
202203
? {}
203204
: {
@@ -262,6 +263,7 @@ export const useNadDiagram = ({
262263
type: DiagramType.NETWORK_AREA_DIAGRAM,
263264
nadConfigUuid: diagramMetadata.nadConfigUuid,
264265
filterUuid: diagramMetadata.filterUuid,
266+
currentFilterUuid: diagramMetadata.currentFilterUuid,
265267
voltageLevelIds: diagramMetadata.initialVoltageLevelIds || [],
266268
positions: [],
267269
voltageLevelToExpandIds: [],
@@ -278,6 +280,7 @@ export const useNadDiagram = ({
278280
currentRootNetworkUuid,
279281
diagramMetadata.nadConfigUuid,
280282
diagramMetadata.filterUuid,
283+
diagramMetadata.currentFilterUuid,
281284
]);
282285

283286
// Listen for notifications and refetch

src/components/workspace/panel-contents/diagrams/nad/nad-panel-content.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ export const NadPanelContent = ({
5656
[updateDiagram]
5757
);
5858

59+
// Update voltage levels from a filter in local state only - no Redux dispatch
60+
const handleUpdateVoltageLevelsFromFilter = useCallback(
61+
(filterUuid?: UUID) => {
62+
dispatch(
63+
updatePanelMetadata({
64+
panelId,
65+
metadata: {
66+
currentFilterUuid: filterUuid,
67+
},
68+
})
69+
);
70+
},
71+
[dispatch, panelId]
72+
);
73+
5974
// Update positions in local state only - no Redux dispatch, no fetch
6075
const handleUpdatePositions = useCallback(
6176
(positions: DiagramConfigPosition[]) => {
@@ -103,9 +118,11 @@ export const NadPanelContent = ({
103118
}
104119
svgVoltageLevels={diagram.voltageLevelIds}
105120
loadingState={loading}
121+
isNadCreationFromFilter={!!diagram.filterUuid}
106122
visible
107123
onVoltageLevelClick={handleOpenDiagram}
108124
onUpdateVoltageLevels={handleUpdateVoltageLevels}
125+
onUpdateVoltageLevelsFromFilter={handleUpdateVoltageLevelsFromFilter}
109126
onUpdatePositions={handleUpdatePositions}
110127
onReplaceNad={handleReplaceNad}
111128
onSaveNad={handleSaveNad}

src/components/workspace/types/workspace.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface SLDPanelMetadata {
2727
export interface NADPanelMetadata {
2828
nadConfigUuid?: UUID;
2929
filterUuid?: UUID;
30+
currentFilterUuid?: UUID;
3031
savedWorkspaceConfigUuid?: UUID;
3132
initialVoltageLevelIds?: string[];
3233
}

0 commit comments

Comments
 (0)