From e0d5a4d8b706f3b44a07d2d77e1bf127a117179d Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 31 May 2018 14:40:01 -0400 Subject: [PATCH] show toast util --- src/abstractions/platformUtils.service.ts | 1 + src/electron/services/electronPlatformUtils.service.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/abstractions/platformUtils.service.ts b/src/abstractions/platformUtils.service.ts index c15da85f2c..d623250bfa 100644 --- a/src/abstractions/platformUtils.service.ts +++ b/src/abstractions/platformUtils.service.ts @@ -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; isDev: () => boolean; diff --git a/src/electron/services/electronPlatformUtils.service.ts b/src/electron/services/electronPlatformUtils.service.ts index c6444e183e..3af58fbb41 100644 --- a/src/electron/services/electronPlatformUtils.service.ts +++ b/src/electron/services/electronPlatformUtils.service.ts @@ -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 { const buttons = [confirmText == null ? this.i18nService.t('ok') : confirmText];