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
14 changes: 14 additions & 0 deletions lib/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function createDialogs(channel: Channel, ids: IdsAPI): DialogsAPI
openConfirm: openSimpleDialog.bind(null, 'confirm'),
openPrompt: openSimpleDialog.bind(null, 'prompt'),
openExtension: openExtensionDialog,
openApp: openAppDialog,
openCurrentApp: openCurrentAppDialog,
openCurrent: openCurrentDialog,
selectSingleEntry: openEntitySelector.bind(null, 'Entry', false),
Expand Down Expand Up @@ -57,6 +58,19 @@ export default function createDialogs(channel: Channel, ids: IdsAPI): DialogsAPI
}
}

function openAppDialog(options?: OpenCustomWidgetOptions) {
options = prepareOptions(options)

// Use provided ID, default to the current app.
options = { ...options, id: options?.id || ids.app }
if (options.id) {
// Force ID of the current app.
return channel.call('openDialog', 'app', options)
} else {
throw new Error('App ID not provided.')
}
}

function openCurrentAppDialog(options?: Omit<OpenCustomWidgetOptions, 'id'>) {
options = prepareOptions(options)
if (ids.app) {
Expand Down
2 changes: 2 additions & 0 deletions lib/types/dialogs.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export interface DialogsAPI {
) => Promise<string | boolean>
/** Opens an extension in a dialog. */
openExtension: (options: OpenCustomWidgetOptions) => Promise<any>
/** Opens an app dialog */
openApp: (options?: OpenCustomWidgetOptions) => Promise<any>
/** Opens the current app in a dialog */
openCurrentApp: (options?: Omit<OpenCustomWidgetOptions, 'id'>) => Promise<any>
/** Opens the current app or extension in a dialog */
Expand Down