mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
[PM-1504] Migrate Dialogs to DialogService (#5013)
This PR introduces a generic `DialogService` which can be used by all the clients. This allows us to decouple dialogs from the `PlatformUtilsHelper`. The `DialogService` provides a new method, `openSimpleDialog` which is the new interface for that type of dialogs. This gives us 3 different implementations: - Web: DialogService modern dialogs - Browser: SweetAlert - Desktop: Native electron based
This commit is contained in:
@@ -3,6 +3,7 @@ import * as os from "os";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { UntypedFormBuilder } from "@angular/forms";
|
||||
|
||||
import { DialogServiceAbstraction, SimpleDialogType } from "@bitwarden/angular/services/dialog";
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/tools/export/components/export.component";
|
||||
import { BroadcasterService } from "@bitwarden/common/abstractions/broadcaster.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
@@ -33,7 +34,8 @@ export class ExportComponent extends BaseExportComponent implements OnInit {
|
||||
formBuilder: UntypedFormBuilder,
|
||||
private broadcasterService: BroadcasterService,
|
||||
logService: LogService,
|
||||
fileDownloadService: FileDownloadService
|
||||
fileDownloadService: FileDownloadService,
|
||||
dialogService: DialogServiceAbstraction
|
||||
) {
|
||||
super(
|
||||
cryptoService,
|
||||
@@ -46,7 +48,8 @@ export class ExportComponent extends BaseExportComponent implements OnInit {
|
||||
logService,
|
||||
userVerificationService,
|
||||
formBuilder,
|
||||
fileDownloadService
|
||||
fileDownloadService,
|
||||
dialogService
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,25 +59,23 @@ export class ExportComponent extends BaseExportComponent implements OnInit {
|
||||
|
||||
async warningDialog() {
|
||||
if (this.encryptedFormat) {
|
||||
return await this.platformUtilsService.showDialog(
|
||||
this.i18nService.t("encExportKeyWarningDesc") +
|
||||
return await this.dialogService.openSimpleDialog({
|
||||
title: { key: "confirmVaultExport" },
|
||||
content:
|
||||
this.i18nService.t("encExportKeyWarningDesc") +
|
||||
os.EOL +
|
||||
os.EOL +
|
||||
this.i18nService.t("encExportAccountWarningDesc"),
|
||||
this.i18nService.t("confirmVaultExport"),
|
||||
this.i18nService.t("exportVault"),
|
||||
this.i18nService.t("cancel"),
|
||||
"warning",
|
||||
true
|
||||
);
|
||||
acceptButtonText: { key: "exportVault" },
|
||||
type: SimpleDialogType.WARNING,
|
||||
});
|
||||
} else {
|
||||
return await this.platformUtilsService.showDialog(
|
||||
this.i18nService.t("exportWarningDesc"),
|
||||
this.i18nService.t("confirmVaultExport"),
|
||||
this.i18nService.t("exportVault"),
|
||||
this.i18nService.t("cancel"),
|
||||
"warning"
|
||||
);
|
||||
return await this.dialogService.openSimpleDialog({
|
||||
title: { key: "confirmVaultExport" },
|
||||
content: { key: "exportWarningDesc" },
|
||||
acceptButtonText: { key: "exportVault" },
|
||||
type: SimpleDialogType.WARNING,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user