diff --git a/platform/ui/src/contextProviders/DialogProvider.js b/platform/ui/src/contextProviders/DialogProvider.js index 74e7c1419..71fec7115 100644 --- a/platform/ui/src/contextProviders/DialogProvider.js +++ b/platform/ui/src/contextProviders/DialogProvider.js @@ -45,36 +45,6 @@ const DialogProvider = ({ children, service }) => { }; }; - /** - * Sets the implementation of a dialog service that can be used by extensions. - * - * @returns void - */ - useEffect(() => { - if (service) { - service.setServiceImplementation({ create, dismiss, dismissAll }); - } - }, [create, dismiss, service]); - - /** - * UI Dialog - * - * @typedef {Object} DialogProps - * @property {string} id The dialog id. - * @property {DialogContent} content The dialog content. - * @property {Object} contentProps The dialog content props. - * @property {boolean} isDraggable Controls if dialog content is draggable or not. - * @property {boolean} showOverlay Controls dialog overlay. - * @property {boolean} centralize Center the dialog on the screen. - * @property {boolean} preservePosition Use last position instead of default. - * @property {ElementPosition} defaultPosition Specifies the `x` and `y` that the dragged item should start at. - * @property {Function} onStart Called when dragging starts. If `false` is returned any handler, the action will cancel. - * @property {Function} onStop Called when dragging stops. - * @property {Function} onDrag Called while dragging. - */ - - useEffect(() => _bringToFront(lastDialogId), [_bringToFront, lastDialogId]); - /** * Creates a new dialog and return its id. * @@ -109,20 +79,15 @@ const DialogProvider = ({ children, service }) => { ); /** - * Dismisses all dialogs. + * Sets the implementation of a dialog service that can be used by extensions. * * @returns void */ - const dismissAll = () => { - setDialogs([]); - }; - - /** - * Indicate if there are no dialogs present. - * - * @returns True if no dialogs are present. - */ - const isEmpty = () => dialogs && dialogs.length < 1; + useEffect(() => { + if (service) { + service.setServiceImplementation({ create, dismiss, dismissAll }); + } + }, [create, dismiss, service]); /** * Moves the dialog to the foreground if clicked. @@ -139,6 +104,41 @@ const DialogProvider = ({ children, service }) => { }); }, []); + /** + * UI Dialog + * + * @typedef {Object} DialogProps + * @property {string} id The dialog id. + * @property {DialogContent} content The dialog content. + * @property {Object} contentProps The dialog content props. + * @property {boolean} isDraggable Controls if dialog content is draggable or not. + * @property {boolean} showOverlay Controls dialog overlay. + * @property {boolean} centralize Center the dialog on the screen. + * @property {boolean} preservePosition Use last position instead of default. + * @property {ElementPosition} defaultPosition Specifies the `x` and `y` that the dragged item should start at. + * @property {Function} onStart Called when dragging starts. If `false` is returned any handler, the action will cancel. + * @property {Function} onStop Called when dragging stops. + * @property {Function} onDrag Called while dragging. + */ + + useEffect(() => _bringToFront(lastDialogId), [_bringToFront, lastDialogId]); + + /** + * Dismisses all dialogs. + * + * @returns void + */ + const dismissAll = () => { + setDialogs([]); + }; + + /** + * Indicate if there are no dialogs present. + * + * @returns True if no dialogs are present. + */ + const isEmpty = () => dialogs && dialogs.length < 1; + const renderDialogs = () => dialogs.map(dialog => { const { @@ -219,14 +219,12 @@ const DialogProvider = ({ children, service }) => { ); - return ( - showOverlay ? ( -