Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-14461] Update organization state after subscription update #12222

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
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";

Check warning on line 9 in apps/web/src/app/billing/organizations/adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/adjust-subscription.component.ts#L8-L9

Added lines #L8 - L9 were not covered by tests
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";
Expand Down Expand Up @@ -34,6 +36,7 @@
private organizationApiService: OrganizationApiServiceAbstraction,
private formBuilder: FormBuilder,
private toastService: ToastService,
private internalOrganizationService: InternalOrganizationServiceAbstraction,

Check warning on line 39 in apps/web/src/app/billing/organizations/adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/adjust-subscription.component.ts#L39

Added line #L39 was not covered by tests
) {}

ngOnInit() {
Expand Down Expand Up @@ -64,7 +67,20 @@
this.additionalSeatCount,
this.adjustSubscriptionForm.value.newMaxSeats,
);
await this.organizationApiService.updatePasswordManagerSeats(this.organizationId, request);

const response = await this.organizationApiService.updatePasswordManagerSeats(

Check warning on line 71 in apps/web/src/app/billing/organizations/adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/adjust-subscription.component.ts#L71

Added line #L71 was not covered by tests
this.organizationId,
request,
);

const organization = await this.internalOrganizationService.get(this.organizationId);

Check warning on line 76 in apps/web/src/app/billing/organizations/adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/adjust-subscription.component.ts#L76

Added line #L76 was not covered by tests

const organizationData = new OrganizationData(response, {

Check warning on line 78 in apps/web/src/app/billing/organizations/adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/adjust-subscription.component.ts#L78

Added line #L78 was not covered by tests
isMember: organization.isMember,
isProviderUser: organization.isProviderUser,
});

await this.internalOrganizationService.upsert(organizationData);

Check warning on line 83 in apps/web/src/app/billing/organizations/adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/adjust-subscription.component.ts#L83

Added line #L83 was not covered by tests

this.toastService.showToast({
variant: "success",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
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";

Check warning on line 9 in apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts#L8-L9

Added lines #L8 - L9 were not covered by tests
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";
Expand Down Expand Up @@ -104,6 +106,7 @@
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private toastService: ToastService,
private internalOrganizationService: InternalOrganizationServiceAbstraction,

Check warning on line 109 in apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts#L109

Added line #L109 was not covered by tests
) {}

ngOnInit() {
Expand Down Expand Up @@ -157,11 +160,20 @@
? this.formGroup.value.maxAutoscaleServiceAccounts
: null;

await this.organizationApiService.updateSecretsManagerSubscription(
const response = await this.organizationApiService.updateSecretsManagerSubscription(

Check warning on line 163 in apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts#L163

Added line #L163 was not covered by tests
this.organizationId,
request,
);

const organization = await this.internalOrganizationService.get(this.organizationId);

Check warning on line 168 in apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts#L168

Added line #L168 was not covered by tests

const organizationData = new OrganizationData(response, {

Check warning on line 170 in apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts#L170

Added line #L170 was not covered by tests
isMember: organization.isMember,
isProviderUser: organization.isProviderUser,
});

await this.internalOrganizationService.upsert(organizationData);

Check warning on line 175 in apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/organizations/sm-adjust-subscription.component.ts#L175

Added line #L175 was not covered by tests

this.toastService.showToast({
variant: "success",
title: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,29 @@
async updatePasswordManagerSeats(
id: string,
request: OrganizationSubscriptionUpdateRequest,
): Promise<void> {
return this.apiService.send(
): Promise<ProfileOrganizationResponse> {
const r = await this.apiService.send(

Check warning on line 165 in libs/common/src/admin-console/services/organization/organization-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/admin-console/services/organization/organization-api.service.ts#L165

Added line #L165 was not covered by tests
"POST",
"/organizations/" + id + "/subscription",
request,
true,
false,
true,
);
return new ProfileOrganizationResponse(r);

Check warning on line 172 in libs/common/src/admin-console/services/organization/organization-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/admin-console/services/organization/organization-api.service.ts#L172

Added line #L172 was not covered by tests
}

async updateSecretsManagerSubscription(
id: string,
request: OrganizationSmSubscriptionUpdateRequest,
): Promise<void> {
return this.apiService.send(
): Promise<ProfileOrganizationResponse> {
const r = await this.apiService.send(

Check warning on line 179 in libs/common/src/admin-console/services/organization/organization-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/admin-console/services/organization/organization-api.service.ts#L179

Added line #L179 was not covered by tests
"POST",
"/organizations/" + id + "/sm-subscription",
request,
true,
false,
true,
);
return new ProfileOrganizationResponse(r);

Check warning on line 186 in libs/common/src/admin-console/services/organization/organization-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/admin-console/services/organization/organization-api.service.ts#L186

Added line #L186 was not covered by tests
}

async updateSeats(id: string, request: SeatRequest): Promise<PaymentResponse> {
Expand Down
Loading