Offer a shared creation in the element save dialog - #1302
Conversation
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>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 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. Comment |
| sx: { | ||
| '& .MuiFormControlLabel-root': { | ||
| marginRight: 15, | ||
| marginRight: onSaveShared ? 4 : 15, |
There was a problem hiding this comment.
it is kind of magic number here
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
before this we have to check the createSharedDisabled (default value is false) ?
There was a problem hiding this comment.
Why ? The button is not reachable otherwise.
What do you mean ?
There was a problem hiding this comment.
if (createSharedDisabled && isCreateMode && destinationFolder) ?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
I suggest reverting this and creating a separate one for shared creation in order to keep the two modes distinct
There was a problem hiding this comment.
I don't understand what you want to do exactly ?
There was a problem hiding this comment.
const isCreateMode = operationType === OperationType.CREATE; (to be reverted)
const isCreateSharedMode = operationType === OperationType.CREATE_SHARED;
There was a problem hiding this comment.
They share the same usage on 19 lines. I don't think it's a good idea to separate it.
…lable Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
TheMaskedTurtle
left a comment
There was a problem hiding this comment.
Not tested but code ok, no big change for commons-ui architecture
|



ElementSaveDialogcan 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 anonSaveSharedcallback 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
createSharedDisabledwhen the current selection cannot be shared,RadioInputnow accepting adisabledflag 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.badTypebusiness error introduced in gridsuite/network-modification-server#874.Used by gridsuite/gridstudy-app to share a composite modification from a study.