Skip to content

Commit

Permalink
fix: Add missing types for confirmation dialogs
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jul 2, 2024
1 parent 76f339f commit 1980caf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
36 changes: 35 additions & 1 deletion lib/common/OC.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,48 @@ declare namespace Nextcloud.Common {
FILEPICKER_TYPE_COPY: number;
FILEPICKER_TYPE_COPY_MOVE: number;

readonly YES_NO_BUTTONS: number,
readonly OK_BUTTONS: number,

filepicker(
title: string,
callback: Function,
multiselect?: boolean,
mimeTypeFilter?: Array<string>,
modal?: boolean,
type?: number,
path?: string): void;
path?: string,
): void;

/**
* Displays confirmation dialog
* @param text content of dialog
* @param title dialog title
* @param callback which will be triggered when user presses OK (true or false would be passed to callback respectively)
* @param modal make the dialog modal
*/
confirm(
text: string,
title: string,
callback: (answer: boolean) => void,
modal?: boolean,
): Promise<void>;

/**
* Displays confirmation dialog
* @param text content of dialog
* @param title dialog title
* @param buttons text content of buttons
* @param callback which will be triggered when user presses OK (true or false would be passed to callback respectively)
* @param modal make the dialog modal
*/
confirmDestructive(
text: string,
title: string,
buttons: number | { type: number, confirm: string, cancel: string, confirmClasses: string },
callback: (answer: boolean) => void,
modal?: boolean,
): Promise<void>;
}

interface TranslationOptions {
Expand Down
11 changes: 4 additions & 7 deletions lib/v17/OC.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ declare namespace Nextcloud.v17 {
allowDirectoryChooser: boolean
}

interface Dialogs {
FILEPICKER_TYPE_CHOOSE: number;
FILEPICKER_TYPE_MOVE: number;
FILEPICKER_TYPE_COPY: number;
FILEPICKER_TYPE_COPY_MOVE: number;

interface Dialogs extends Omit<Nextcloud.v16.OC['dialogs'], 'filepicker'>{
// options parameter was added
filepicker(
title: string,
callback: Function,
Expand All @@ -18,7 +14,8 @@ declare namespace Nextcloud.v17 {
modal?: boolean,
type?: number,
path?: string,
options?: FilePickerOptions): void;
options?: FilePickerOptions,
): void;
}

interface OC extends Nextcloud.v16.OC {
Expand Down

0 comments on commit 1980caf

Please sign in to comment.