nextcloud-libraries / nextcloud-dialogs

Nextcloud dialog helpers https://npmjs.org/@nextcloud/dialogs
https://nextcloud-libraries.github.io/nextcloud-dialogs/
GNU Affero General Public License v3.0
19 stars 9 forks source link

Add confim() #1371

Closed thlehmann-ionos closed 2 months ago

thlehmann-ionos commented 2 months ago

Background

Request

confirm()

Workaround

Adding this as src/oc.d.ts to a typscript-able app:

/// <reference types="@nextcloud/typings" />

declare namespace Nextcloud28WithPolyfills {
    interface DialogsPolyfill {
        confirm(
            title: string,
            message: string,
            callback: Function,
            modal: boolean): void;
    }

    interface OC extends Nextcloud.v28.OC {
        dialogs: Nextcloud.Common.Dialogs & DialogsPolyfill;
    }
}

declare var OC: Nextcloud28WithPolyfills;
susnux commented 2 months ago

If you use Vue then I recommend simply directly using NcDialog from @nextcloud/vue.

If not you can use this library, as the replacement for the deprecated function is to use the DialogBuilder from this library, see: https://nextcloud-libraries.github.io/nextcloud-dialogs/classes/index.DialogBuilder.html

thlehmann-ionos commented 2 months ago

Thanks for pointing that out.

Note: unfortunately, <NcDialog> leads to repetition and possibly inconsistent UI because every confirm dialog has to be re-implemented (icon, button order). ´. Same for the DialogBuilder, which is a bit better because it includes the facility for that, but still repeated code.