Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a3e97aa
add netmod decsription
Mathieu-Deharbe Dec 4, 2025
3511693
add netmod decsription
Mathieu-Deharbe Dec 4, 2025
1d9168f
use commons-ui EditNoteIcon
Mathieu-Deharbe Dec 4, 2025
143d9f3
min size of NODE_EDITOR
Mathieu-Deharbe Dec 4, 2025
416b9e0
window opening and update calls
Mathieu-Deharbe Dec 5, 2025
22cecf2
use commons-ui EditNoteIcon
Mathieu-Deharbe Dec 5, 2025
87cef39
removes duplicate NetworkModificationMetadata
Mathieu-Deharbe Dec 8, 2025
17c5c2a
hidden icon when not hovering it
Mathieu-Deharbe Dec 8, 2025
fa3fd9f
lod descriptionFr + En
Mathieu-Deharbe Dec 8, 2025
ff7700a
empty declaration
Mathieu-Deharbe Dec 10, 2025
0415424
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe Dec 10, 2025
bed8e2a
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe Dec 12, 2025
1dcc6d6
post review
Mathieu-Deharbe Dec 12, 2025
d8cfbbb
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe Dec 15, 2025
cf392a1
setModificationMetadata
Mathieu-Deharbe Dec 15, 2025
b55ac84
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe Dec 16, 2025
adbd106
remove import
Mathieu-Deharbe Dec 16, 2025
98a4363
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe Dec 16, 2025
5b5875f
Upgrade commons-ui v0.146.0
Mathieu-Deharbe Dec 16, 2025
87a888a
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe Dec 16, 2025
fc27ab6
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe Dec 17, 2025
4e52563
corrections post conflict
Mathieu-Deharbe Dec 17, 2025
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
4 changes: 4 additions & 0 deletions src/components/app-wrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import {
commonButtonFr,
componentsFr,
componentsEn,
descriptionFr,
descriptionEn,
dndTableFr,
dndTableEn,
equipmentsEn,
Expand Down Expand Up @@ -403,6 +405,7 @@ const messages = {
...multipleSelectionDialogEn,
...commonButtonEn,
...componentsEn,
...descriptionEn,
...dndTableEn,
...equipmentsEn,
...grid_en,
Expand Down Expand Up @@ -446,6 +449,7 @@ const messages = {
...componentsFr,
...dndTableFr,
...equipmentsFr,
...descriptionFr,
...grid_fr,
...backend_locale_fr,
...dynamic_mapping_models_fr,
Expand Down
2 changes: 1 addition & 1 deletion src/components/dialogs/restore-modification-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
CancelButton,
CheckBoxList,
type MuiStyles,
NetworkModificationMetadata,
snackWithFallback,
useModificationLabelComputer,
useSnackMessage,
Expand All @@ -19,7 +20,6 @@ import { deleteModifications, restoreModifications } from 'services/study/networ
import { CustomDialog } from 'components/utils/custom-dialog';
import { useSelector } from 'react-redux';
import { AppState } from 'redux/reducer';
import { NetworkModificationMetadata } from 'components/graph/menus/network-modifications/network-modification-menu.type';
import { toggleElementFromList } from 'components/utils/utils';

const styles = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { ICellRendererParams } from 'ag-grid-community';
import { DescriptionModificationDialog, EditNoteIcon, NetworkModificationMetadata } from '@gridsuite/commons-ui';

Check failure on line 8 in src/components/graph/menus/network-modifications/DescriptionRenderer.tsx

View workflow job for this annotation

GitHub Actions / build / build

Module '"@gridsuite/commons-ui"' has no exported member 'EditNoteIcon'.
import React, { SetStateAction, useCallback, useState } from 'react';
import { Tooltip } from '@mui/material';
import { useIsAnyNodeBuilding } from '../../../utils/is-any-node-building-hook';
import { useSelector } from 'react-redux';
import { AppState } from '../../../../redux/reducer';
import IconButton from '@mui/material/IconButton';
import type { UUID } from 'node:crypto';
import { setModificationDescription } from '../../../../services/study/network-modifications';

export interface DescriptionRendererProps extends ICellRendererParams<NetworkModificationMetadata> {
setModifications: React.Dispatch<SetStateAction<NetworkModificationMetadata[]>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't import the whole react dependency, but just dispatch like it's done for set state action.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you made me realise that I don't need that prop anymore. Removed : 1dcc6d6

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but you still import React

Copy link
Contributor Author

@Mathieu-Deharbe Mathieu-Deharbe Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry : removed here : adbd106

hoveredRowIndex: number;
}

const DescriptionRenderer = (props: DescriptionRendererProps) => {
const { data, api, node } = props;
const studyUuid = useSelector((state: AppState) => state.studyUuid);
const currentNode = useSelector((state: AppState) => state.currentTreeNode);
const [isLoading, setIsLoading] = useState(false);
const isAnyNodeBuilding = useIsAnyNodeBuilding();
const mapDataLoading = useSelector((state: AppState) => state.mapDataLoading);
const [openDescModificationDialog, setOpenDescModificationDialog] = useState(false);

const modificationUuid = data?.uuid;
const description: string | undefined = data?.description;

Check failure on line 33 in src/components/graph/menus/network-modifications/DescriptionRenderer.tsx

View workflow job for this annotation

GitHub Actions / build / build

Property 'description' does not exist on type 'NetworkModificationMetadata'.
const empty: boolean = !description;

const updateModification = useCallback(
async (uuid: UUID, descriptionRecord: Record<string, string>) => {
setIsLoading(true);

return setModificationDescription(studyUuid, currentNode?.id, uuid, descriptionRecord.description).finally(
() => {
setIsLoading(false);
}
);
},
[studyUuid, currentNode?.id]
);

const handleDescDialogClose = useCallback(() => {
setOpenDescModificationDialog(false);
api.stopEditing();
}, [api]);

const handleModifyDescription = () => {
if (isLoading) {
return;
}
setOpenDescModificationDialog(true);
};

return (
<>
{openDescModificationDialog && modificationUuid && (
<DescriptionModificationDialog
open
description={description ?? ''}
elementUuid={modificationUuid}
onClose={handleDescDialogClose}
updateElement={updateModification}
/>
)}
<Tooltip title={description} arrow>
<IconButton
color="primary"
onClick={handleModifyDescription}
disabled={isLoading || isAnyNodeBuilding || mapDataLoading}
>
<EditNoteIcon empty={empty} hidden={node.rowIndex !== props.hoveredRowIndex} />
</IconButton>
</Tooltip>
</>
);
};

export default DescriptionRenderer;
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ export interface ExcludedNetworkModifications {
modificationUuidsToExclude: UUID[];
}

export interface NetworkModificationMetadata {
uuid: UUID;
type: string;
date: Date;
stashed: boolean;
activated: boolean;
messageType: string;
messageValues: string;
}

export enum NetworkModificationCopyType {
COPY = 'COPY',
MOVE = 'MOVE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import React, { SetStateAction, useCallback, useEffect, useMemo, useRef } from 'react';
import React, { SetStateAction, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import {
CustomAGGrid,
type MuiStyles,
Expand All @@ -15,6 +15,7 @@ import {
} from '@gridsuite/commons-ui';
import type {
CellClickedEvent,
CellMouseOverEvent,
ColDef,
GetRowIdParams,
IRowDragItem,
Expand All @@ -39,6 +40,7 @@ import SwitchCellRenderer from './switch-cell-renderer';
import { AGGRID_LOCALES } from '../../../../translations/not-intl/aggrid-locales';
import { ExcludedNetworkModifications } from './network-modification-menu.type';
import { AgGridReact } from 'ag-grid-react';
import DescriptionRenderer from './DescriptionRenderer';

const styles = {
container: (theme) => ({
Expand Down Expand Up @@ -89,6 +91,7 @@ const NetworkModificationsTable: React.FC<NetworkModificationsTableProps> = ({
const rootNetworks = useSelector((state: AppState) => state.rootNetworks);
const isMonoRootStudy = useSelector((state: AppState) => state.isMonoRootStudy);
const highlightedModificationUuid = useSelector((state: AppState) => state.highlightedModificationUuid);
const [hoveredRowIndex, setHoveredRowIndex] = useState<number>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no initial value for this state ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe -1 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and no need to precise type if there is a default value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually when I precised -1 as a default value, the hovered index was lost when the page rerendered. It is surprising because according to react help it shouldn't. I don't have the explanation.


const intl = useIntl();
const { computeLabel } = useModificationLabelComputer();
Expand Down Expand Up @@ -143,6 +146,15 @@ const NetworkModificationsTable: React.FC<NetworkModificationsTableProps> = ({
flex: 1,
cellStyle: { cursor: 'pointer' },
},
{
colId: 'modificationDescription',
cellRenderer: DescriptionRenderer,
cellRendererParams: {
setModifications: setModifications,
hoveredRowIndex: hoveredRowIndex,
},
width: 30,
},
{
cellRenderer: SwitchCellRenderer,
cellRendererParams: {
Expand Down Expand Up @@ -199,6 +211,7 @@ const NetworkModificationsTable: React.FC<NetworkModificationsTableProps> = ({
currentRootNetworkUuid,
modificationsToExclude,
setModificationsToExclude,
hoveredRowIndex,
]);

const getRowId = (params: GetRowIdParams<NetworkModificationMetadata>) => params.data.uuid;
Expand Down Expand Up @@ -245,6 +258,10 @@ const NetworkModificationsTable: React.FC<NetworkModificationsTableProps> = ({
checkboxes: true,
headerCheckbox: true,
}}
onCellMouseOver={(event: CellMouseOverEvent<NetworkModificationMetadata>) =>
setHoveredRowIndex(event.rowIndex ?? -1)
}
onCellMouseOut={() => setHoveredRowIndex(-1)}
defaultColDef={defaultColumnDefinition}
onCellClicked={handleCellClick}
onRowSelected={onRowSelected}
Expand Down
2 changes: 1 addition & 1 deletion src/components/workspace/constants/workspace.constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const DEFAULT_PANEL_CONFIGS: Record<PanelType, PanelConfig> = {
[PanelType.NODE_EDITOR]: {
title: 'modifications',
defaultSize: { width: 0.2, height: 0.6 },
minSize: { width: 300, height: 300 },
minSize: { width: 340, height: 300 },
defaultPosition: { x: 0.05, y: 0 },
icon: <Tune fontSize="inherit" />,
},
Expand Down
17 changes: 17 additions & 0 deletions src/services/study/network-modifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ export function setModificationActivated(
});
}

export function setModificationDescription(
studyUuid: UUID | null,
nodeUuid: UUID | undefined,
modificationUuid: UUID,
description: string
): Promise<Response> {
const urlSearchParams = new URLSearchParams();
urlSearchParams.append('description', description);
urlSearchParams.append('uuid', String(modificationUuid));
const modificationUpdateActiveUrl =
getNetworkModificationUrl(studyUuid, nodeUuid) + '?' + urlSearchParams.toString();
console.debug(modificationUpdateActiveUrl);
return backendFetch(modificationUpdateActiveUrl, {
method: 'PUT',
});
}

export function updateModificationStatusByRootNetwork(
studyUuid: UUID,
nodeUuid: UUID,
Expand Down
Loading