1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

refactor toaster to platform showToast

This commit is contained in:
Kyle Spearrin
2018-10-02 23:09:19 -04:00
parent 45341ec408
commit f793ff0aa5
21 changed files with 85 additions and 117 deletions

View File

@@ -4,7 +4,6 @@ import {
Output,
} from '@angular/core';
import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { CipherType } from '../../enums/cipherType';
@@ -61,7 +60,7 @@ export class AddEditComponent {
constructor(protected cipherService: CipherService, protected folderService: FolderService,
protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected analytics: Angulartics2, protected toasterService: ToasterService,
protected analytics: Angulartics2,
protected auditService: AuditService, protected stateService: StateService) {
this.typeOptions = [
{ name: i18nService.t('typeLogin'), value: CipherType.Login },
@@ -152,7 +151,7 @@ export class AddEditComponent {
async submit(): Promise<boolean> {
if (this.cipher.name == null || this.cipher.name === '') {
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('nameRequired'));
return false;
}
@@ -169,7 +168,7 @@ export class AddEditComponent {
await this.formPromise;
this.cipher.id = cipher.id;
this.analytics.eventTrack.next({ action: this.editMode ? 'Edited Cipher' : 'Added Cipher' });
this.toasterService.popAsync('success', null,
this.platformUtilsService.showToast('success', null,
this.i18nService.t(this.editMode ? 'editedItem' : 'addedItem'));
this.onSavedCipher.emit(this.cipher);
return true;
@@ -238,7 +237,7 @@ export class AddEditComponent {
this.deletePromise = this.deleteCipher();
await this.deletePromise;
this.analytics.eventTrack.next({ action: 'Deleted Cipher' });
this.toasterService.popAsync('success', null, this.i18nService.t('deletedItem'));
this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedItem'));
this.onDeletedCipher.emit(this.cipher);
} catch { }
@@ -301,9 +300,10 @@ export class AddEditComponent {
this.checkPasswordPromise = null;
if (matches > 0) {
this.toasterService.popAsync('warning', null, this.i18nService.t('passwordExposed', matches.toString()));
this.platformUtilsService.showToast('warning', null,
this.i18nService.t('passwordExposed', matches.toString()));
} else {
this.toasterService.popAsync('success', null, this.i18nService.t('passwordSafe'));
this.platformUtilsService.showToast('success', null, this.i18nService.t('passwordSafe'));
}
}