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

[EC-97] Organization Billing Language / RxJS Warnings #3688

Merged
merged 3 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -1,5 +1,6 @@
import { Component, OnInit } from "@angular/core";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { concatMap, Subject, takeUntil } from "rxjs";

import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
import { BillingHistoryResponse } from "@bitwarden/common/models/response/billingHistoryResponse";
Expand All @@ -8,25 +9,35 @@ import { BillingHistoryResponse } from "@bitwarden/common/models/response/billin
selector: "app-org-billing-history-view",
templateUrl: "organization-billing-history-view.component.html",
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class OrgBillingHistoryViewComponent implements OnInit {
export class OrgBillingHistoryViewComponent implements OnInit, OnDestroy {
loading = false;
firstLoaded = false;
billing: BillingHistoryResponse;
organizationId: string;

private destroy$ = new Subject<void>();

constructor(
private organizationApiService: OrganizationApiServiceAbstraction,
private route: ActivatedRoute
) {}

async ngOnInit() {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.route.params.subscribe(async (params) => {
this.organizationId = params.organizationId;
await this.load();
this.firstLoaded = true;
});
this.route.params
.pipe(
concatMap(async (params) => {
this.organizationId = params.organizationId;
await this.load();
this.firstLoaded = true;
}),
takeUntil(this.destroy$)
)
.subscribe();
}

ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}

async load() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
import { Component, OnDestroy, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { concatMap, Subject, takeUntil } from "rxjs";

import { ModalRef } from "@bitwarden/angular/components/modal/modal.ref";
import { ModalService } from "@bitwarden/angular/services/modal.service";
Expand All @@ -26,17 +27,13 @@ import { BillingSyncApiKeyComponent } from "./billing-sync-api-key.component";
selector: "app-org-subscription",
templateUrl: "organization-subscription.component.html",
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class OrganizationSubscriptionComponent implements OnInit {
export class OrganizationSubscriptionComponent implements OnInit, OnDestroy {
@ViewChild("setupBillingSyncTemplate", { read: ViewContainerRef, static: true })
setupBillingSyncModalRef: ViewContainerRef;

loading = false;
firstLoaded = false;
organizationId: string;
adjustSeatsAdd = true;
showAdjustSeats = false;
showAdjustSeatAutoscale = false;
adjustStorageAdd = true;
showAdjustStorage = false;
showUpdateLicense = false;
Expand All @@ -58,6 +55,8 @@ export class OrganizationSubscriptionComponent implements OnInit {
billingSyncKeyViewContainerRef: ViewContainerRef;
billingSyncKeyRef: [ModalRef, BillingSyncKeyComponent];

private destroy$ = new Subject<void>();

constructor(
private apiService: ApiService,
private platformUtilsService: PlatformUtilsService,
Expand All @@ -73,19 +72,27 @@ export class OrganizationSubscriptionComponent implements OnInit {
}

async ngOnInit() {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.route.parent.parent.params.subscribe(async (params) => {
this.organizationId = params.organizationId;
await this.load();
this.firstLoaded = true;
});
this.route.params
.pipe(
concatMap(async (params) => {
this.organizationId = params.organizationId;
await this.load();
this.firstLoaded = true;
}),
takeUntil(this.destroy$)
)
.subscribe();
}

ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}

async load() {
if (this.loading) {
return;
}

this.loading = true;
this.userOrg = this.organizationService.get(this.organizationId);
if (this.userOrg.canManageBilling) {
Expand Down Expand Up @@ -172,7 +179,7 @@ export class OrganizationSubscriptionComponent implements OnInit {
this.showChangePlan = !this.showChangePlan;
}

closeChangePlan(changed: boolean) {
closeChangePlan() {
this.showChangePlan = false;
}

Expand All @@ -189,10 +196,14 @@ export class OrganizationSubscriptionComponent implements OnInit {
comp.hasBillingToken = this.hasBillingSyncToken;
}
);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
ref.onClosed.subscribe(async () => {
await this.load();
});
ref.onClosed
.pipe(
concatMap(async () => {
await this.load();
}),
takeUntil(this.destroy$)
)
.subscribe();
}

closeDownloadLicense() {
Expand Down
16 changes: 8 additions & 8 deletions apps/web/src/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3126,7 +3126,7 @@
"message": "Enter your installation id"
},
"limitSubscriptionDesc": {
"message": "Set a seat limit for your subscription. Once this limit is reached, you will not be able to invite new users."
"message": "Set a seat limit for your subscription. Once this limit is reached, you will not be able to invite new members."
},
"maxSeatLimit": {
"message": "Maximum Seat Limit (optional)",
Expand All @@ -3147,7 +3147,7 @@
"message": "Adjustments to your subscription will result in prorated changes to your billing totals. If newly invited users exceed your subscription seats, you will immediately receive a prorated charge for the additional users."
},
"subscriptionUserSeats": {
"message": "Your subscription allows for a total of $COUNT$ users.",
"message": "Your subscription allows for a total of $COUNT$ members.",
"placeholders": {
"count": {
"content": "$1",
Expand All @@ -3171,10 +3171,10 @@
"message": "For additional help in managing your subscription, please contact Customer Support."
},
"subscriptionUserSeatsUnlimitedAutoscale": {
"message": "Adjustments to your subscription will result in prorated changes to your billing totals. If newly invited users exceed your subscription seats, you will immediately receive a prorated charge for the additional users."
"message": "Adjustments to your subscription will result in prorated changes to your billing totals. If newly invited members exceed your subscription seats, you will immediately receive a prorated charge for the additional members."
},
"subscriptionUserSeatsLimitedAutoscale": {
"message": "Adjustments to your subscription will result in prorated changes to your billing totals. If newly invited users exceed your subscription seats, you will immediately receive a prorated charge for the additional users until your $MAX$ seat limit is reached.",
"message": "Adjustments to your subscription will result in prorated changes to your billing totals. If newly invited members exceed your subscription seats, you will immediately receive a prorated charge for the additional members until your $MAX$ seat limit is reached.",
"placeholders": {
"max": {
"content": "$1",
Expand All @@ -3183,7 +3183,7 @@
}
},
"subscriptionFreePlan": {
"message": "You cannot invite more than $COUNT$ users without upgrading your plan.",
"message": "You cannot invite more than $COUNT$ members without upgrading your plan.",
"placeholders": {
"count": {
"content": "$1",
Expand All @@ -3192,7 +3192,7 @@
}
},
"subscriptionFamiliesPlan": {
"message": "You cannot invite more than $COUNT$ users without upgrading your plan. Please contact Customer Support to upgrade.",
"message": "You cannot invite more than $COUNT$ members without upgrading your plan. Please contact Customer Support to upgrade.",
"placeholders": {
"count": {
"content": "$1",
Expand All @@ -3201,7 +3201,7 @@
}
},
"subscriptionSponsoredFamiliesPlan": {
"message": "Your subscription allows for a total of $COUNT$ users. Your plan is sponsored and billed to an external organization.",
"message": "Your subscription allows for a total of $COUNT$ members. Your plan is sponsored and billed to an external organization.",
"placeholders": {
"count": {
"content": "$1",
Expand All @@ -3210,7 +3210,7 @@
}
},
"subscriptionMaxReached": {
"message": "Adjustments to your subscription will result in prorated changes to your billing totals. You cannot invite more than $COUNT$ users without increasing your subscription seats.",
"message": "Adjustments to your subscription will result in prorated changes to your billing totals. You cannot invite more than $COUNT$ members without increasing your subscription seats.",
"placeholders": {
"count": {
"content": "$1",
Expand Down