Skip to content

Offer a shared creation in the element save dialog - #1302

Merged
flomillot merged 4 commits into
mainfrom
feat/share-composite-modification
Sep 1, 2026
Merged

Offer a shared creation in the element save dialog#1302
flomillot merged 4 commits into
mainfrom
feat/share-composite-modification

Conversation

@flomillot

@flomillot flomillot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

ElementSaveDialog can now offer a third operation next to the creation and the update of an element: saving it as a shared one. It shows up only when an onSaveShared callback is given, so the other users of the dialog are left untouched, and it reuses the very same creation form — only the callback called on submit differs.

The option can be greyed out through createSharedDisabled when the current selection cannot be shared, RadioInput now accepting a disabled flag per option.

Should it become unavailable while the dialog is already open, the shared option falls back on the standard creation, the entered name and description being kept.

Also adds the message of the modification.badType business error introduced in gridsuite/network-modification-server#874.

Used by gridsuite/gridstudy-app to share a composite modification from a study.

When an onSaveShared callback is given, the dialog offers a third operation
saving the element as a shared one, which reuses the creation form. The
option can be greyed out with createSharedDisabled, RadioInput now supporting
disabled options.

Add the message of the new modification.badType business error.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: d58be59b-13fc-41bd-91a6-a8cf8e0b13ae


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

sx: {
'& .MuiFormControlLabel-root': {
marginRight: 15,
marginRight: onSaveShared ? 4 : 15,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it is kind of magic number here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's to adapt when we have three buttons instead of two.

const onSubmit = useCallback<SubmitHandler<SchemaType>>(
(values) => {
if (isCreateMode && destinationFolder && onSave) {
if (isCreateMode && destinationFolder) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

before this we have to check the createSharedDisabled (default value is false) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why ? The button is not reachable otherwise.
What do you mean ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if (createSharedDisabled && isCreateMode && destinationFolder) ?

@flomillot flomillot Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a use effect in the rare case where the selection became impossible to share from a background notification.

// Force create mode if in legacy mode
const operationType = createOnlyMode ? OperationType.CREATE : watch(FieldConstants.OPERATION_TYPE);
const isCreateMode = operationType === OperationType.CREATE;
const isCreateMode = operationType !== OperationType.UPDATE;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest reverting this and creating a separate one for shared creation in order to keep the two modes distinct

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what you want to do exactly ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

const isCreateMode = operationType === OperationType.CREATE; (to be reverted)
const isCreateSharedMode = operationType === OperationType.CREATE_SHARED;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They share the same usage on 19 lines. I don't think it's a good idea to separate it.

@flomillot
flomillot requested a review from ghazwarhili August 27, 2026 15:42
…lable

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@flomillot flomillot added the waiting-for-review PR ready for an owner to review label Sep 1, 2026

@TheMaskedTurtle TheMaskedTurtle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not tested but code ok, no big change for commons-ui architecture

@TheMaskedTurtle TheMaskedTurtle removed the waiting-for-review PR ready for an owner to review label Sep 1, 2026
@TheMaskedTurtle TheMaskedTurtle self-assigned this Sep 1, 2026
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

@flomillot
flomillot merged commit f3ea1a6 into main Sep 1, 2026
5 checks passed
@flomillot
flomillot deleted the feat/share-composite-modification branch September 1, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants