mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-07 19:07:45 +01:00
[PM-14461] Update organization state after subscription update (#12222)
* Update organization state after subscription update * QA: Fix SM trial seat adjustment
This commit is contained in:
parent
af4311fa21
commit
15cc4ff1eb
@ -5,6 +5,8 @@ import { FormBuilder, Validators } from "@angular/forms";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
||||
import { InternalOrganizationServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { OrganizationData } from "@bitwarden/common/admin-console/models/data/organization.data";
|
||||
import { OrganizationSubscriptionUpdateRequest } from "@bitwarden/common/billing/models/request/organization-subscription-update.request";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { ToastService } from "@bitwarden/components";
|
||||
@ -34,6 +36,7 @@ export class AdjustSubscription implements OnInit, OnDestroy {
|
||||
private organizationApiService: OrganizationApiServiceAbstraction,
|
||||
private formBuilder: FormBuilder,
|
||||
private toastService: ToastService,
|
||||
private internalOrganizationService: InternalOrganizationServiceAbstraction,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -64,7 +67,20 @@ export class AdjustSubscription implements OnInit, OnDestroy {
|
||||
this.additionalSeatCount,
|
||||
this.adjustSubscriptionForm.value.newMaxSeats,
|
||||
);
|
||||
await this.organizationApiService.updatePasswordManagerSeats(this.organizationId, request);
|
||||
|
||||
const response = await this.organizationApiService.updatePasswordManagerSeats(
|
||||
this.organizationId,
|
||||
request,
|
||||
);
|
||||
|
||||
const organization = await this.internalOrganizationService.get(this.organizationId);
|
||||
|
||||
const organizationData = new OrganizationData(response, {
|
||||
isMember: organization.isMember,
|
||||
isProviderUser: organization.isProviderUser,
|
||||
});
|
||||
|
||||
await this.internalOrganizationService.upsert(organizationData);
|
||||
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
|
@ -5,6 +5,8 @@ import { FormBuilder, Validators } from "@angular/forms";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
||||
import { InternalOrganizationServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { OrganizationData } from "@bitwarden/common/admin-console/models/data/organization.data";
|
||||
import { OrganizationSmSubscriptionUpdateRequest } from "@bitwarden/common/billing/models/request/organization-sm-subscription-update.request";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
@ -104,6 +106,7 @@ export class SecretsManagerAdjustSubscriptionComponent implements OnInit, OnDest
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private toastService: ToastService,
|
||||
private internalOrganizationService: InternalOrganizationServiceAbstraction,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -157,11 +160,20 @@ export class SecretsManagerAdjustSubscriptionComponent implements OnInit, OnDest
|
||||
? this.formGroup.value.maxAutoscaleServiceAccounts
|
||||
: null;
|
||||
|
||||
await this.organizationApiService.updateSecretsManagerSubscription(
|
||||
const response = await this.organizationApiService.updateSecretsManagerSubscription(
|
||||
this.organizationId,
|
||||
request,
|
||||
);
|
||||
|
||||
const organization = await this.internalOrganizationService.get(this.organizationId);
|
||||
|
||||
const organizationData = new OrganizationData(response, {
|
||||
isMember: organization.isMember,
|
||||
isProviderUser: organization.isProviderUser,
|
||||
});
|
||||
|
||||
await this.internalOrganizationService.upsert(organizationData);
|
||||
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
title: null,
|
||||
|
@ -53,11 +53,11 @@ export class OrganizationApiServiceAbstraction {
|
||||
updatePasswordManagerSeats: (
|
||||
id: string,
|
||||
request: OrganizationSubscriptionUpdateRequest,
|
||||
) => Promise<void>;
|
||||
) => Promise<ProfileOrganizationResponse>;
|
||||
updateSecretsManagerSubscription: (
|
||||
id: string,
|
||||
request: OrganizationSmSubscriptionUpdateRequest,
|
||||
) => Promise<void>;
|
||||
) => Promise<ProfileOrganizationResponse>;
|
||||
updateSeats: (id: string, request: SeatRequest) => Promise<PaymentResponse>;
|
||||
updateStorage: (id: string, request: StorageRequest) => Promise<PaymentResponse>;
|
||||
verifyBank: (id: string, request: VerifyBankRequest) => Promise<void>;
|
||||
|
@ -161,27 +161,29 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
async updatePasswordManagerSeats(
|
||||
id: string,
|
||||
request: OrganizationSubscriptionUpdateRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
): Promise<ProfileOrganizationResponse> {
|
||||
const r = await this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + id + "/subscription",
|
||||
request,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
);
|
||||
return new ProfileOrganizationResponse(r);
|
||||
}
|
||||
|
||||
async updateSecretsManagerSubscription(
|
||||
id: string,
|
||||
request: OrganizationSmSubscriptionUpdateRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
): Promise<ProfileOrganizationResponse> {
|
||||
const r = await this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + id + "/sm-subscription",
|
||||
request,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
);
|
||||
return new ProfileOrganizationResponse(r);
|
||||
}
|
||||
|
||||
async updateSeats(id: string, request: SeatRequest): Promise<PaymentResponse> {
|
||||
|
Loading…
Reference in New Issue
Block a user