Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable interactions with sld in drawing mode #2169

Merged
merged 15 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/diagrams/diagram-pane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,6 @@ export function DiagramPane({
},
[currentNode]
);

return (
<AutoSizer>
{({ width, height }) => (
Expand Down
14 changes: 11 additions & 3 deletions src/components/map-viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
PARAM_LINE_FULL_PATH,
PARAM_LINE_PARALLEL_PATH,
} from '../utils/config-params.js';
import { setStudyDisplayMode } from '../redux/actions.js';
import { setMapDrawingMode, setStudyDisplayMode } from '../redux/actions.js';
import { DRAW_EVENT, DRAW_MODES } from '@powsybl/diagram-viewer';
import { DiagramType } from './diagrams/diagram-common.js';
import { ReactFlowProvider } from 'react-flow-renderer';
Expand Down Expand Up @@ -95,6 +95,8 @@ const MapViewer = ({
const lineParallelPath = useSelector(
(state) => state[PARAM_LINE_PARALLEL_PATH]
);
const disableSldInteraction = useSelector((state) => state.isDrawingMode);

const [
shouldOpenSelectionCreationPanel,
setShouldOpenSelectionCreationPanel,
Expand Down Expand Up @@ -122,9 +124,12 @@ const MapViewer = ({

const openVoltageLevel = useCallback(
(vlId) => {
openDiagramView(vlId, DiagramType.VOLTAGE_LEVEL);
// don't open the sld if the drawing mode is activated
if (!disableSldInteraction) {
openDiagramView(vlId, DiagramType.VOLTAGE_LEVEL);
}
},
[openDiagramView]
[openDiagramView, disableSldInteraction]
);

function showInSpreadsheet(equipment) {
Expand Down Expand Up @@ -160,6 +165,7 @@ const MapViewer = ({
setShouldOpenSelectionCreationPanel(false);
if (isInDrawingMode) {
dispatch(setStudyDisplayMode(previousStudyDisplayMode.current));
dispatch(setMapDrawingMode(false));
previousStudyDisplayMode.current = undefined;
}
}, [dispatch, isInDrawingMode]);
Expand Down Expand Up @@ -189,6 +195,7 @@ const MapViewer = ({
if (!isInDrawingMode) {
previousStudyDisplayMode.current = studyDisplayMode;
}
dispatch(setMapDrawingMode(true));
//go to map full screen mode
dispatch(setStudyDisplayMode(StudyDisplayMode.MAP));
}
Expand All @@ -202,6 +209,7 @@ const MapViewer = ({
?.length > 1
) {
setShouldOpenSelectionCreationPanel(false);
dispatch(setMapDrawingMode(true));
const idFirstPolygon = networkMapref.current
.getMapDrawer()
.getAll().features[0].id;
Expand Down
9 changes: 9 additions & 0 deletions src/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,3 +753,12 @@ export function setSpreadsheetFilter(filterTab, spreadsheetFilter) {
spreadsheetFilter: spreadsheetFilter,
};
}

export const SET_DRAWING_MODE = 'SET_DRAWING_MODE';

export function setMapDrawingMode(isDrawingMode) {
return {
type: SET_DRAWING_MODE,
isDrawingMode: isDrawingMode,
};
}
6 changes: 6 additions & 0 deletions src/redux/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import {
UPDATE_EQUIPMENTS,
RESET_EQUIPMENTS_BY_TYPES,
DELETE_EQUIPMENTS,
SET_DRAWING_MODE,
} from './actions';
import {
getLocalStorageComputedLanguage,
Expand Down Expand Up @@ -271,6 +272,7 @@ const initialState = {
notificationIdList: [],
isModificationsInProgress: false,
studyDisplayMode: StudyDisplayMode.HYBRID,
isDrawingMode: false,
diagramStates: [],
reloadMap: true,
isMapEquipmentsInitialized: false,
Expand Down Expand Up @@ -1204,6 +1206,10 @@ export const reducer = createReducer(initialState, (builder) => {
state[SPREADSHEET_STORE_FIELD][action.filterTab] =
action[SPREADSHEET_STORE_FIELD];
});

builder.addCase(SET_DRAWING_MODE, (state, action) => {
state.isDrawingMode = action.isDrawingMode;
});
});

function updateSubstationAfterVLDeletion(currentSubstations, VLToDeleteId) {
Expand Down
Loading