Show dialog to save when trying to execute a workflow that is not on the server
Fix #271 (closed)
The main problem is that handleSave
was returning early if the workflow was loaded from disk (https://gitlab.esrf.fr/workflow/ewoks/ewoksweb/-/blob/ae8416293f7ad22dd939f11ac7a8d34dc4c4906d/src/general/hooks.ts), setting isDialogOpen
to true
and expecting the component calling the hook to pop the save dialog.
But ExecutionDialog
was not doing it, so I added the dialog with the handling of its state.
Also, I now check the return value of handleSave
to see if the workflow should be executed or not. For a workflow loaded from disk, we don't want to execute the workflow in handleSave
but rather:
- Try
handleSave
: it fails. Do not execute. - Pop up the dialog window, ask the user for a name.
- If the saving via the dialog works, execute the workflow via the new
onSuccess
callback.
Note that this process is exactly the same for new workflows that were not saved to the server so it fixes two issues in one.
More generally, all this is a bit convoluted and far from ideal (implicit couplings, dialog on the top of another dialog)... It would warrant a more thorough refactoring.
But I needed an easy fix for this week's training