Skip to content

Commit

Permalink
[EC-97] Organization Billing Language / RxJS Warnings (#3688)
Browse files Browse the repository at this point in the history
* [EC-97] Update copy to use the word members in a few places

* [EC-97] Cleanup RxJS warnings and unused properties in org billing components
  • Loading branch information
shane-melton authored Oct 7, 2022
1 parent 4d83b81 commit e91106a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 35 deletions.
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 @@ -3144,7 +3144,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 @@ -3165,7 +3165,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 @@ -3189,10 +3189,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 @@ -3201,7 +3201,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 @@ -3210,7 +3210,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 @@ -3219,7 +3219,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 @@ -3228,7 +3228,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

0 comments on commit e91106a

Please sign in to comment.