openModal
How to use
openModal method takes an object as an argument. This object should contain at least the component key which should point to your Modal component. You could also add a props key pointing to an objecting containing extra properties that will be passed down the modal component.
Properties
Sizes
Dashboard comes with a range of predefined sizes you'll be able to choose from in order to render your modal.
Choose your size by first retrieve the available ones form the PluginAPI
Multiple modals
Before Dashboard 4.1, modals used to be rendered by calling Plugin.modal.open(...) And that allowed the plugins to render one modal at a time, but with the new ModalAPI, Dashboard supports opening multiple modals at the same time without un-mounting the previous ones.
For example, if you call the deprecated method Plugin.modal.open(...) while you have a modal already rendered, Dashboard will un-mount the rendered modal, and mount the new one. When them a user closes the modal, Dashboard will close the current opened one without going back to the previous one
With the new API Dashboard will stack the modals on top of each other every time Plugin.openModal(...) has been called
So to open multiple modals, simply call Plugin.openModal(...) with your new modal properties
Confirm before close
You can tell Dashboard to display a confirm prompt to the user, when the user tries to close your modal This could be appropriate to do if your modal has changes that will get lost, or still processing some data.
Dashboard will look into your modal component ref and check if the ref has aonBeforeClose()
method.
If so Dashboard will call the method and wait for it to resolve or reject, therefore it should return a promise.
If onBeforeClose() resolves then Dashboard will close the modal right away. If it's rejected, Dashboard will display a dialog to the user to confirm closing the modal, or cancel.
You can specify the dialog message along with the dialog button labels. You also can register callbacks to see what action the user took, onConfirm/onCancel
The object you reject with, will be the dialog params
Dialog params
Example
Last updated