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
This commit is contained in:
parent
2b4a8705da
commit
d68680a789
|
@ -10,7 +10,9 @@
|
|||
<bit-form-field class="tw-max-w-sm">
|
||||
<bit-label>{{ "fileFormat" | i18n }}</bit-label>
|
||||
<select bitInput formControlName="format">
|
||||
<option *ngFor="let format of exportFormats" [ngValue]="format">{{ format }}</option>
|
||||
<option *ngFor="let format of exportFormats; let i = index" [value]="i">
|
||||
{{ format.name }}
|
||||
</option>
|
||||
</select>
|
||||
</bit-form-field>
|
||||
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue