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-15840] When org reaches collection limit, organization upgrade pa… #12648

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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 @@ -2,7 +2,7 @@
// @ts-strict-ignore
import { Component, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { concatMap, firstValueFrom, lastValueFrom, Observable, Subject, takeUntil } from "rxjs";
import { firstValueFrom, lastValueFrom, Observable, Subject } from "rxjs";

import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
Expand Down Expand Up @@ -42,6 +42,9 @@ import { SecretsManagerSubscriptionOptions } from "./sm-adjust-subscription.comp
templateUrl: "organization-subscription-cloud.component.html",
})
export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy {
static readonly QUERY_PARAM_UPGRADE: string = "upgrade";
static readonly ROUTE_PARAM_ORGANIZATION_ID: string = "organizationId";

sub: OrganizationSubscriptionResponse;
lineItems: BillingSubscriptionItemResponse[] = [];
organizationId: string;
Expand Down Expand Up @@ -82,7 +85,19 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
) {}

async ngOnInit() {
if (this.route.snapshot.queryParamMap.get("upgrade")) {
this.organizationId =
this.route.snapshot.params[
OrganizationSubscriptionCloudComponent.ROUTE_PARAM_ORGANIZATION_ID
];
await this.load();

this.showUpdatedSubscriptionStatusSection$ = this.configService.getFeatureFlag$(
FeatureFlag.AC1795_UpdatedSubscriptionStatusSection,
);

if (
this.route.snapshot.queryParams[OrganizationSubscriptionCloudComponent.QUERY_PARAM_UPGRADE]
) {
await this.changePlan();
const productTierTypeStr = this.route.snapshot.queryParamMap.get("productTierType");
if (productTierTypeStr != null) {
Expand All @@ -92,20 +107,6 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
}
}
}

this.route.params
.pipe(
concatMap(async (params) => {
this.organizationId = params.organizationId;
await this.load();
}),
takeUntil(this.destroy$),
)
.subscribe();

this.showUpdatedSubscriptionStatusSection$ = this.configService.getFeatureFlag$(
FeatureFlag.AC1795_UpdatedSubscriptionStatusSection,
);
}

ngOnDestroy() {
Expand Down
Loading