Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Dialog {
*
* @return Promise that resolves when the dialog is answered successfully and rejects on close
*/
async show() {
async show(): Promise<void> {
const result = await spawnDialog(
GenericDialog,
{
Expand Down Expand Up @@ -89,7 +89,7 @@ export class DialogBuilder {
*
* @param name The name or headline of the dialog
*/
setName(name: string) {
setName(name: string): this {
this.#name = name
return this
}
Expand All @@ -99,7 +99,7 @@ export class DialogBuilder {
*
* @param text Main text of the dialog
*/
setText(text: string) {
setText(text: string): this {
this.#text = text
return this
}
Expand All @@ -109,7 +109,7 @@ export class DialogBuilder {
*
* @param severity Severity of the dialog
*/
setSeverity(severity: IDialogSeverity) {
setSeverity(severity: IDialogSeverity): this {
this.#severity = severity
return this
}
Expand All @@ -119,7 +119,7 @@ export class DialogBuilder {
*
* @param buttons Either an array of dialog buttons
*/
setButtons(buttons: IDialogButton[]) {
setButtons(buttons: IDialogButton[]): this {
if (this.#buttons.length > 0) {
logger.warn('[@nextcloud/dialogs] Dialog buttons are already set - this overrides previous buttons.')
}
Expand All @@ -132,12 +132,12 @@ export class DialogBuilder {
*
* @param button Button to add
*/
addButton(button: IDialogButton) {
addButton(button: IDialogButton): this {
this.#buttons.push(button)
return this
}

build() {
build(): Dialog {
return new Dialog(this.#name, this.#text, this.#buttons, this.#severity)
}
}
Expand All @@ -156,7 +156,7 @@ export class DialogBuilder {
* .build()
* ```
*/
export function getDialogBuilder(name: string) {
export function getDialogBuilder(name: string): DialogBuilder {
return new DialogBuilder(name)
}

Expand Down
26 changes: 13 additions & 13 deletions lib/filepicker-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param container The dialog container
*/
public setContainer(container: string) {
public setContainer(container: string): this {
this.container = container
return this
}
Expand All @@ -161,7 +161,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param filter MIME type to allow
*/
public addMimeTypeFilter(filter: string) {
public addMimeTypeFilter(filter: string): this {
this.mimeTypeFilter.push(filter)
return this
}
Expand All @@ -171,7 +171,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param filter Array of allowed MIME types
*/
public setMimeTypeFilter(filter: string[]) {
public setMimeTypeFilter(filter: string[]): this {
this.mimeTypeFilter = filter
return this
}
Expand All @@ -182,7 +182,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param button The button
*/
public addButton(button: IFilePickerButton) {
public addButton(button: IFilePickerButton): this {
if (typeof this.buttons === 'function') {
logger.warn('FilePicker buttons were set to factory, now overwritten with button object.')
this.buttons = []
Expand All @@ -197,7 +197,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param factory The button factory
*/
public setButtonFactory(factory: IFilePickerButtonFactory) {
public setButtonFactory(factory: IFilePickerButtonFactory): this {
this.buttons = factory
return this
}
Expand All @@ -208,7 +208,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
* @param type The legacy filepicker type to emulate
* @deprecated Use `addButton` or `setButtonFactory` instead as with setType you do not know which button was pressed
*/
public setType(type: FilePickerType) {
public setType(type: FilePickerType): this {
this.buttons = (nodes, path) => {
const buttons: IFilePickerButton[] = []
const node = nodes[0]
Expand Down Expand Up @@ -254,7 +254,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param allow True to allow picking directories
*/
public allowDirectories(allow = true) {
public allowDirectories(allow = true): this {
this.directoriesAllowed = allow
return this
}
Expand All @@ -264,7 +264,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param noMenu True to hide menu
*/
public setNoMenu(noMenu = true) {
public setNoMenu(noMenu = true): this {
this.noMenu = noMenu
return this
}
Expand All @@ -274,7 +274,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param path Path to start from picking
*/
public startAt(path: string) {
public startAt(path: string): this {
this.path = path
return this
}
Expand All @@ -284,7 +284,7 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param filter Filter function to apply
*/
public setFilter(filter: IFilePickerFilter) {
public setFilter(filter: IFilePickerFilter): this {
this.filter = filter
return this
}
Expand All @@ -294,23 +294,23 @@ export class FilePickerBuilder<IsMultiSelect extends boolean> {
*
* @param canPick Function to decide if a node can be picked
*/
public setCanPick(canPick: IFilePickerCanPick) {
public setCanPick(canPick: IFilePickerCanPick): this {
this.canPick = canPick
return this
}

/**
* Disable navigation (view selection)
*/
public disableNavigation() {
public disableNavigation(): this {
this.disabledNavigation = true
return this
}

/**
* Construct the configured FilePicker
*/
public build() {
public build(): FilePicker<IsMultiSelect> {
return new FilePicker<IsMultiSelect>(
this.title,
this.multiSelect as IsMultiSelect,
Expand Down
Loading