mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Dialogs now show properly in plugins (Fixes #1520)
This commit is contained in:
parent
a7ceb25ac7
commit
52519a5737
@ -10,16 +10,22 @@ import {
|
|||||||
import WrapperModal from '../../ui/components/modals/wrapper-modal';
|
import WrapperModal from '../../ui/components/modals/wrapper-modal';
|
||||||
|
|
||||||
export function init(renderPurpose: RenderPurpose = RENDER_PURPOSE_GENERAL): { app: Object } {
|
export function init(renderPurpose: RenderPurpose = RENDER_PURPOSE_GENERAL): { app: Object } {
|
||||||
|
const canShowDialogs =
|
||||||
|
renderPurpose === RENDER_PURPOSE_SEND || renderPurpose === RENDER_PURPOSE_NO_RENDER;
|
||||||
return {
|
return {
|
||||||
app: {
|
app: {
|
||||||
alert(title: string, message?: string): Promise<void> {
|
alert(title: string, message?: string): Promise<void> {
|
||||||
if (renderPurpose !== RENDER_PURPOSE_SEND && renderPurpose !== RENDER_PURPOSE_NO_RENDER) {
|
if (!canShowDialogs) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
return showAlert({ title, message });
|
return showAlert({ title, message });
|
||||||
},
|
},
|
||||||
showGenericModalDialog(title: string, options?: { html: string } = {}): Promise<void> {
|
showGenericModalDialog(title: string, options?: { html: string } = {}): Promise<void> {
|
||||||
|
if (renderPurpose !== RENDER_PURPOSE_SEND && renderPurpose !== RENDER_PURPOSE_NO_RENDER) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
return showModal(WrapperModal, { title, bodyHTML: options.html });
|
return showModal(WrapperModal, { title, bodyHTML: options.html });
|
||||||
},
|
},
|
||||||
prompt(
|
prompt(
|
||||||
@ -33,7 +39,7 @@ export function init(renderPurpose: RenderPurpose = RENDER_PURPOSE_GENERAL): { a
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
if (renderPurpose !== RENDER_PURPOSE_SEND) {
|
if (!canShowDialogs) {
|
||||||
return Promise.resolve(options.defaultValue || '');
|
return Promise.resolve(options.defaultValue || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +65,7 @@ export function init(renderPurpose: RenderPurpose = RENDER_PURPOSE_GENERAL): { a
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async showSaveDialog(options: { defaultPath?: string } = {}): Promise<string | null> {
|
async showSaveDialog(options: { defaultPath?: string } = {}): Promise<string | null> {
|
||||||
if (renderPurpose !== RENDER_PURPOSE_SEND) {
|
if (!canShowDialogs) {
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user