1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-07 19:13:39 +00:00

show dialog device util

This commit is contained in:
Kyle Spearrin
2018-02-02 23:42:33 -05:00
parent 269cacec45
commit 0a647e4846
5 changed files with 86 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
import { ipcRenderer, shell } from 'electron';
import { remote, shell } from 'electron';
import { DeviceType } from 'jslib/enums';
@@ -123,4 +123,24 @@ export class DesktopPlatformUtilsService implements PlatformUtilsService {
// ref: https://github.com/electron/electron/issues/3226
return false;
}
showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string):
Promise<boolean> {
const buttons = [confirmText == null ? this.i18nService.t('ok') : confirmText];
if (cancelText != null) {
buttons.push(cancelText);
}
const result = remote.dialog.showMessageBox(remote.getCurrentWindow(), {
type: type,
title: title,
message: text,
buttons: buttons,
cancelId: buttons.length === 2 ? 1 : null,
defaultId: 0,
noLink: true,
});
return Promise.resolve(result === 0);
}
}