-
-
{{ "downloadLicense" | i18n }}
-
-
+
+
+
+
+
+
diff --git a/apps/web/src/app/billing/organizations/download-license.component.ts b/apps/web/src/app/billing/organizations/download-license.component.ts
index 88a37a28aa..6b3a93548b 100644
--- a/apps/web/src/app/billing/organizations/download-license.component.ts
+++ b/apps/web/src/app/billing/organizations/download-license.component.ts
@@ -1,50 +1,61 @@
-import { Component, EventEmitter, Input, Output } from "@angular/core";
+import { DialogConfig, DIALOG_DATA, DialogRef } from "@angular/cdk/dialog";
+import { Component, Inject } from "@angular/core";
+import { FormBuilder, Validators } from "@angular/forms";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
-import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
+import { DialogService } from "@bitwarden/components";
+
+export enum DownloadLicenseDialogResult {
+ Cancelled = "cancelled",
+ Downloaded = "downloaded",
+}
+type DownloadLicenseDialogData = {
+ /** current organization id */
+ organizationId: string;
+};
@Component({
- selector: "app-download-license",
templateUrl: "download-license.component.html",
})
-export class DownloadLicenseComponent {
- @Input() organizationId: string;
- @Output() onDownloaded = new EventEmitter();
- @Output() onCanceled = new EventEmitter();
-
- installationId: string;
- formPromise: Promise
;
-
+export class DownloadLicenceDialogComponent {
+ licenseForm = this.formBuilder.group({
+ installationId: ["", [Validators.required]],
+ });
constructor(
+ @Inject(DIALOG_DATA) protected data: DownloadLicenseDialogData,
+ private dialogRef: DialogRef,
private fileDownloadService: FileDownloadService,
- private logService: LogService,
private organizationApiService: OrganizationApiServiceAbstraction,
+ protected formBuilder: FormBuilder,
) {}
- async submit() {
- if (this.installationId == null || this.installationId === "") {
+ submit = async () => {
+ this.licenseForm.markAllAsTouched();
+ const installationId = this.licenseForm.get("installationId").value;
+ if (installationId == null || installationId === "") {
return;
}
-
- try {
- this.formPromise = this.organizationApiService.getLicense(
- this.organizationId,
- this.installationId,
- );
- const license = await this.formPromise;
- const licenseString = JSON.stringify(license, null, 2);
- this.fileDownloadService.download({
- fileName: "bitwarden_organization_license.json",
- blobData: licenseString,
- });
- this.onDownloaded.emit();
- } catch (e) {
- this.logService.error(e);
- }
- }
-
- cancel() {
- this.onCanceled.emit();
+ const license = await this.organizationApiService.getLicense(
+ this.data.organizationId,
+ installationId,
+ );
+ const licenseString = JSON.stringify(license, null, 2);
+ this.fileDownloadService.download({
+ fileName: "bitwarden_organization_license.json",
+ blobData: licenseString,
+ });
+ this.dialogRef.close(DownloadLicenseDialogResult.Downloaded);
+ };
+ /**
+ * Strongly typed helper to open a DownloadLicenceDialogComponent
+ * @param dialogService Instance of the dialog service that will be used to open the dialog
+ * @param config Configuration for the dialog
+ */
+ static open(dialogService: DialogService, config: DialogConfig) {
+ return dialogService.open(DownloadLicenceDialogComponent, config);
}
+ cancel = () => {
+ this.dialogRef.close(DownloadLicenseDialogResult.Cancelled);
+ };
}
diff --git a/apps/web/src/app/billing/organizations/organization-billing.module.ts b/apps/web/src/app/billing/organizations/organization-billing.module.ts
index 490ebafbff..a95efe32e4 100644
--- a/apps/web/src/app/billing/organizations/organization-billing.module.ts
+++ b/apps/web/src/app/billing/organizations/organization-billing.module.ts
@@ -8,7 +8,7 @@ import { AdjustSubscription } from "./adjust-subscription.component";
import { BillingSyncApiKeyComponent } from "./billing-sync-api-key.component";
import { BillingSyncKeyComponent } from "./billing-sync-key.component";
import { ChangePlanComponent } from "./change-plan.component";
-import { DownloadLicenseComponent } from "./download-license.component";
+import { DownloadLicenceDialogComponent } from "./download-license.component";
import { OrgBillingHistoryViewComponent } from "./organization-billing-history-view.component";
import { OrganizationBillingRoutingModule } from "./organization-billing-routing.module";
import { OrganizationPlansComponent } from "./organization-plans.component";
@@ -32,7 +32,7 @@ import { SubscriptionStatusComponent } from "./subscription-status.component";
BillingSyncApiKeyComponent,
BillingSyncKeyComponent,
ChangePlanComponent,
- DownloadLicenseComponent,
+ DownloadLicenceDialogComponent,
OrganizationSubscriptionCloudComponent,
OrganizationSubscriptionSelfhostComponent,
OrgBillingHistoryViewComponent,
diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html
index 25ac3a7a15..e11cf602ad 100644
--- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html
+++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html
@@ -246,13 +246,6 @@
{{ (hasBillingSyncToken ? "manageBillingSync" : "setUpBillingSync") | i18n }}
-
{{ "additionalOptions" | i18n }}
diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts
index a0db7b5a20..b6282f1e7b 100644
--- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts
+++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts
@@ -29,6 +29,7 @@ import {
} from "../shared/offboarding-survey.component";
import { BillingSyncApiKeyComponent } from "./billing-sync-api-key.component";
+import { DownloadLicenceDialogComponent } from "./download-license.component";
import { ManageBilling } from "./icons/manage-billing.icon";
import { SecretsManagerSubscriptionOptions } from "./sm-adjust-subscription.component";
@@ -354,8 +355,12 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
this.showChangePlan = false;
}
- downloadLicense() {
- this.showDownloadLicense = !this.showDownloadLicense;
+ async downloadLicense() {
+ DownloadLicenceDialogComponent.open(this.dialogService, {
+ data: {
+ organizationId: this.organizationId,
+ },
+ });
}
async manageBillingSync() {