1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 19:53:43 +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

@@ -175,7 +175,10 @@ export class AddEditComponent implements OnChanges {
}
async delete() {
if (!confirm(this.i18nService.t('deleteItemConfirmation'))) {
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('deleteItemConfirmation'), this.i18nService.t('deleteItem'),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning')
if (!confirmed) {
return;
}
@@ -188,10 +191,14 @@ export class AddEditComponent implements OnChanges {
} catch { }
}
generatePassword() {
if (this.cipher.login != null && this.cipher.login.password != null && this.cipher.login.password.length &&
!confirm(this.i18nService.t('overwritePasswordConfirmation'))) {
return;
async generatePassword() {
if (this.cipher.login != null && this.cipher.login.password != null && this.cipher.login.password.length) {
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('overwritePasswordConfirmation'), this.i18nService.t('overwritePassword'),
this.i18nService.t('yes'), this.i18nService.t('no'))
if (!confirmed) {
return;
}
}
this.onGeneratePassword.emit();

View File

@@ -14,6 +14,7 @@ import { ToasterService } from 'angular2-toaster';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { TokenService } from 'jslib/abstractions/token.service';
import { Cipher } from 'jslib/models/domain/cipher';
@@ -37,7 +38,8 @@ export class AttachmentsComponent implements OnInit {
constructor(private cipherService: CipherService, private analytics: Angulartics2,
private toasterService: ToasterService, private i18nService: I18nService,
private cryptoService: CryptoService, private tokenService: TokenService) { }
private cryptoService: CryptoService, private tokenService: TokenService,
private platformUtilsService: PlatformUtilsService) { }
async ngOnInit() {
this.cipherDomain = await this.cipherService.get(this.cipherId);
@@ -49,9 +51,19 @@ export class AttachmentsComponent implements OnInit {
this.canAccessAttachments = isPremium || this.cipher.organizationId != null;
if (!this.canAccessAttachments) {
alert(this.i18nService.t('premiumRequiredDesc'));
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('premiumRequiredDesc'), this.i18nService.t('premiumRequired'),
this.i18nService.t('learnMore'), this.i18nService.t('cancel'))
if (confirmed) {
this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=purchase');
}
} else if (!this.hasUpdatedKey) {
alert(this.i18nService.t('updateKey'));
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('updateKey'), this.i18nService.t('featureUnavailable'),
this.i18nService.t('learnMore'), this.i18nService.t('cancel'), 'warning')
if (confirmed) {
this.platformUtilsService.launchUri('https://help.bitwarden.com/article/update-encryption-key/');
}
}
}
@@ -96,7 +108,10 @@ export class AttachmentsComponent implements OnInit {
return;
}
if (!confirm(this.i18nService.t('deleteAttachmentConfirmation'))) {
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('deleteAttachmentConfirmation'), this.i18nService.t('deleteAttachment'),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning')
if (!confirmed) {
return;
}

View File

@@ -13,6 +13,7 @@ import { ToasterService } from 'angular2-toaster';
import { FolderService } from 'jslib/abstractions/folder.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { FolderView } from 'jslib/models/view/folderView';
@@ -32,7 +33,8 @@ export class FolderAddEditComponent implements OnInit {
deletePromise: Promise<any>;
constructor(private folderService: FolderService, private i18nService: I18nService,
private analytics: Angulartics2, private toasterService: ToasterService) { }
private analytics: Angulartics2, private toasterService: ToasterService,
private platformUtilsService: PlatformUtilsService) { }
async ngOnInit() {
this.editMode = this.folderId != null;
@@ -66,7 +68,10 @@ export class FolderAddEditComponent implements OnInit {
}
async delete() {
if (!confirm(this.i18nService.t('deleteFolderConfirmation'))) {
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('deleteFolderConfirmation'), this.i18nService.t('deleteFolder'),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning')
if (!confirmed) {
return;
}