-
Notifications
You must be signed in to change notification settings - Fork 6
Allow to share a composite modification from a study #4157
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,7 @@ | |
| assembleModificationsIntoComposite, | ||
| fetchExcludedNetworkModifications, | ||
| fetchNetworkModifications, | ||
| shareCompositeModification, | ||
| stashModifications, | ||
| } from '../../../../services/study/network-modifications'; | ||
| import { | ||
|
|
@@ -991,6 +992,37 @@ | |
| }); | ||
| }; | ||
|
|
||
| const doShareCompositeModificationElement = ({ | ||
| name, | ||
| description, | ||
| folderName, | ||
| folderId, | ||
| }: IElementCreationDialog) => { | ||
| const compositeToShare = selectedNetworkModifications[0]; | ||
| // the selection may have been emptied by a refresh while the dialog was open | ||
| if (!compositeToShare) { | ||
| return; | ||
| } | ||
|
|
||
| setSaveInProgress(true); | ||
| shareCompositeModification(studyUuid, currentNode?.id, compositeToShare.uuid, name, description, folderId) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| .then(() => { | ||
| snackInfo({ | ||
| headerId: 'infoShareModificationMsg', | ||
| headerValues: { | ||
| item: name, | ||
| directory: folderName, | ||
| }, | ||
| }); | ||
| }) | ||
| .catch((error) => { | ||
| snackWithFallback(snackError, error, { headerId: 'errShareModificationMsg' }); | ||
| }) | ||
| .finally(() => { | ||
| setSaveInProgress(false); | ||
| }); | ||
| }; | ||
|
|
||
| const doUpdateCompositeModificationsElements = ({ | ||
| id, | ||
| name, | ||
|
|
@@ -1149,6 +1181,14 @@ | |
| ? (JSON.parse(selectedNetworkModifications[0]?.messageValues)?.name ?? null) | ||
| : null; | ||
|
|
||
| // Sharing moves the selected composite itself into gridexplore : it needs exactly one composite, and an | ||
| // already shared one (a reference) cannot be shared again. Only a composite of the node itself can be shared, | ||
| // not one nested in another composite, so the third condition: the modifications list holds the modifications of the node only | ||
| const isSharingAvailable = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useMemo
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No it's counterproductive here. |
||
| selectedNetworkModifications.length === 1 && | ||
| selectedNetworkModifications[0].type === ModificationType.COMPOSITE_MODIFICATION && | ||
| modifications.some((modification) => modification.uuid === selectedNetworkModifications[0].uuid); | ||
|
|
||
| const renderNetworkModificationsTable = () => { | ||
| if (isRootNode) { | ||
| return ( | ||
|
|
@@ -1204,6 +1244,8 @@ | |
| <ElementSaveDialog | ||
| open={createCompositeModificationDialogOpen} | ||
| onSave={doCreateCompositeModificationsElements} | ||
| onSaveShared={doShareCompositeModificationElement} | ||
|
Check failure on line 1247 in src/components/graph/menus/network-modifications/network-modification-node-editor.tsx
|
||
| createSharedDisabled={!isSharingAvailable} | ||
| OnUpdate={doUpdateCompositeModificationsElements} | ||
| onClose={() => setCreateCompositeModificationDialogOpen(false)} | ||
| type={ElementType.MODIFICATION} | ||
|
|
@@ -1213,6 +1255,7 @@ | |
| studyUuid={studyUuid} | ||
| selectorTitleId="SelectCompositeModificationTitle" | ||
| createLabelId="CreateCompositeModificationLabel" | ||
| createSharedLabelId="ShareCompositeModificationLabel" | ||
| updateLabelId="UpdateCompositeModificationLabel" | ||
| /> | ||
| ) | ||
|
|
||
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.
it is not related to your code but it should be directoryId/directoryName (directory-server)
the naming of folderId/folderName sounds so weired for me (it is for UI level)
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.
As you said it's an existing issue, so if we want to change it we should create a new ticket.