From d68680a789cd32fdfdbc5d92b6bca8059d607907 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 9 Mar 2023 13:56:29 -0500 Subject: [PATCH] SM-634: Fix file extension bug on export (#4964) * SM-634: Fix file extension bug on export * SM-634: Refactor to use index for option selection --- .../settings/porting/sm-export.component.html | 4 +++- .../settings/porting/sm-export.component.ts | 17 ++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/settings/porting/sm-export.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/settings/porting/sm-export.component.html index 65740bba97..4d663f85bc 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/settings/porting/sm-export.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/settings/porting/sm-export.component.html @@ -10,7 +10,9 @@ {{ "fileFormat" | i18n }} diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/settings/porting/sm-export.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/settings/porting/sm-export.component.ts index d090f3246c..7c6ad26855 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/settings/porting/sm-export.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/settings/porting/sm-export.component.ts @@ -14,6 +14,11 @@ import { UserVerificationPromptComponent } from "@bitwarden/web-vault/app/compon import { SecretsManagerPortingApiService } from "../services/sm-porting-api.service"; import { SecretsManagerPortingService } from "../services/sm-porting.service"; +type ExportFormat = { + name: string; + fileExtension: string; +}; + @Component({ selector: "sm-export", templateUrl: "./sm-export.component.html", @@ -23,10 +28,10 @@ export class SecretsManagerExportComponent implements OnInit, OnDestroy { protected orgName: string; protected orgId: string; - protected exportFormats: string[] = ["Bitwarden (json)"]; + protected exportFormats: ExportFormat[] = [{ name: "Bitwarden (json)", fileExtension: "json" }]; protected formGroup = new FormGroup({ - format: new FormControl("Bitwarden (json)", [Validators.required]), + format: new FormControl(0, [Validators.required]), }); constructor( @@ -76,12 +81,10 @@ export class SecretsManagerExportComponent implements OnInit, OnDestroy { }; private async doExport() { - const exportData = await this.secretsManagerApiService.export( - this.orgId, - this.formGroup.get("format").value - ); + const fileExtension = this.exportFormats[this.formGroup.get("format").value].fileExtension; + const exportData = await this.secretsManagerApiService.export(this.orgId, fileExtension); - await this.downloadFile(exportData, this.formGroup.get("format").value); + await this.downloadFile(exportData, fileExtension); this.platformUtilsService.showToast("success", null, this.i18nService.t("dataExportSuccess")); }