1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-29 07:59:42 +01:00

show toast util

This commit is contained in:
Kyle Spearrin 2018-05-31 14:40:01 -04:00
parent 79f8370f7c
commit e0d5a4d8b7
2 changed files with 11 additions and 0 deletions

View File

@ -19,6 +19,7 @@ export abstract class PlatformUtilsService {
getApplicationVersion: () => string;
supportsU2f: (win: Window) => boolean;
supportsDuo: () => boolean;
showToast: (type: 'error' | 'success' | 'warning' | 'info', title: string, text: string) => void;
showDialog: (text: string, title?: string, confirmText?: string, cancelText?: string,
type?: string) => Promise<boolean>;
isDev: () => boolean;

View File

@ -127,6 +127,16 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
return true;
}
showToast(type: 'error' | 'success' | 'warning' | 'info', title: string, text: string, global?: any): void {
if (global == null && Utils.isBrowser) {
global = window;
}
if (global == null || global.BitwardenToasterService == null) {
throw new Error('BitwardenToasterService not available on global.');
}
global.BitwardenToasterService.popAsync(type, title, text);
}
showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string):
Promise<boolean> {
const buttons = [confirmText == null ? this.i18nService.t('ok') : confirmText];