-
Notifications
You must be signed in to change notification settings - Fork 4
add field description to modification #3546
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
Merged
+120
−24
Merged
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a3e97aa
add netmod decsription
Mathieu-Deharbe 3511693
add netmod decsription
Mathieu-Deharbe 1d9168f
use commons-ui EditNoteIcon
Mathieu-Deharbe 143d9f3
min size of NODE_EDITOR
Mathieu-Deharbe 416b9e0
window opening and update calls
Mathieu-Deharbe 22cecf2
use commons-ui EditNoteIcon
Mathieu-Deharbe 87cef39
removes duplicate NetworkModificationMetadata
Mathieu-Deharbe 17c5c2a
hidden icon when not hovering it
Mathieu-Deharbe fa3fd9f
lod descriptionFr + En
Mathieu-Deharbe ff7700a
empty declaration
Mathieu-Deharbe 0415424
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe bed8e2a
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe 1dcc6d6
post review
Mathieu-Deharbe d8cfbbb
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe cf392a1
setModificationMetadata
Mathieu-Deharbe b55ac84
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe adbd106
remove import
Mathieu-Deharbe 98a4363
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe 5b5875f
Upgrade commons-ui v0.146.0
Mathieu-Deharbe 87a888a
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe fc27ab6
Merge branch 'main' into add-netmod-description
Mathieu-Deharbe 4e52563
corrections post conflict
Mathieu-Deharbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/components/graph/menus/network-modifications/DescriptionRenderer.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /** | ||
| * 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'; | ||
| import React, { 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 { setModificationMetadata } from '../../../../services/study/network-modifications'; | ||
|
|
||
| export interface DescriptionRendererProps extends ICellRendererParams<NetworkModificationMetadata> { | ||
| hoveredRowIndex: number; | ||
| } | ||
|
|
||
| const DescriptionRenderer = (props: DescriptionRendererProps) => { | ||
| const { hoveredRowIndex, 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 = data?.description; | ||
| const empty = !description; | ||
|
|
||
| const updateModification = useCallback( | ||
| async (uuid: UUID, descriptionRecord: Record<string, string>) => { | ||
| setIsLoading(true); | ||
|
|
||
| return setModificationMetadata(studyUuid, currentNode?.id, uuid, { | ||
| description: descriptionRecord.description, | ||
|
Check failure on line 40 in src/components/graph/menus/network-modifications/DescriptionRenderer.tsx
|
||
| type: data?.type, | ||
| }).finally(() => { | ||
| setIsLoading(false); | ||
| }); | ||
| }, | ||
| [studyUuid, currentNode?.id, data?.type] | ||
| ); | ||
|
|
||
| const handleDescDialogClose = useCallback(() => { | ||
| setOpenDescModificationDialog(false); | ||
| api.stopEditing(); | ||
| }, [api, setOpenDescModificationDialog]); | ||
|
|
||
| const handleModifyDescription = useCallback(() => { | ||
| setOpenDescModificationDialog(true); | ||
| }, [setOpenDescModificationDialog]); | ||
|
|
||
| return ( | ||
| <> | ||
| {openDescModificationDialog && modificationUuid && ( | ||
| <DescriptionModificationDialog | ||
| open | ||
| description={description ?? ''} | ||
| elementUuid={modificationUuid} | ||
| onClose={handleDescDialogClose} | ||
| updateElement={updateModification} | ||
| /> | ||
| )} | ||
| <Tooltip title={description} arrow placement="right"> | ||
| <IconButton | ||
| color="primary" | ||
| onClick={handleModifyDescription} | ||
| disabled={isLoading || isAnyNodeBuilding || mapDataLoading} | ||
| > | ||
| <EditNoteIcon empty={empty} hidden={node.rowIndex !== hoveredRowIndex} /> | ||
| </IconButton> | ||
| </Tooltip> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default DescriptionRenderer; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still have a global react import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry : removed here : adbd106