How to use the @webiny/app/hooks/useUi.useUi function in @webiny/app

To help you get started, we’ve selected a few @webiny/app examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / app-admin / src / hooks / useConfirmationDialog.js View on Github external
const useConfirmationDialog = ({ title, message }) => {
    const ui = useUi();

    return {
        showConfirmation: (onAccept, onCancel) => {
            ui.setState(ui => {
                return {
                    ...ui,
                    dialog: {
                        message,
                        options: {
                            title,
                            actions: {
                                accept: {
                                    label: t`Confirm`,
                                    onClick: onAccept
                                },
                                cancel: {
github webiny / webiny-js / packages / app-admin / src / plugins / Menu / Hamburger.js View on Github external
const Hamburger = () => {
    const ui = useUi();

    const toggleMenu = useCallback(() => {
        ui.setState(ui => set(ui, "appsMenu.show", !(get(ui, "appsMenu.show") || false)));
    }, [ui]);

    return (
        
            } onClick={toggleMenu} />
            {ReactDOM.createPortal(, getElement())}
        
    );
};
github webiny / webiny-js / packages / app-admin / src / hooks / useDialog.js View on Github external
const useDialog = () => {
    const ui = useUi();
    return {
        showDialog: (message, options) => {
            ui.setState(ui => {
                return { ...ui, dialog: { message, options } };
            });
        }
    };
};
github webiny / webiny-js / packages / app-admin / src / plugins / Dialog / Dialog.js View on Github external
const DialogMain = () => {
    const ui = useUi();
    const message = get(ui, "dialog.message");
    const options = get(ui, "dialog.options", {});

    const hideDialog = useCallback(() => {
        ui.setState(ui => ({ ...ui, dialog: null }));
    }, [ui]);

    return (
        <dialog>
            <dialog open="{!!message}">
                {options.title &amp;&amp; {options.title}}
                {message}
                
                    OK
                
            </dialog></dialog>