mirror of
https://github.com/bitwarden/web
synced 2025-12-06 00:03:28 +00:00
Compare commits
2 Commits
master
...
license-do
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db22f5dc92 | ||
|
|
bb8e982767 |
@@ -12,6 +12,8 @@ import { OrganizationService } from "jslib-common/abstractions/organization.serv
|
||||
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
|
||||
|
||||
import { PlanType } from "jslib-common/enums/planType";
|
||||
import { StateService } from "jslib-common/abstractions/state.service";
|
||||
import { ProductType } from "jslib-common/enums/productType";
|
||||
|
||||
@Component({
|
||||
selector: "app-org-subscription",
|
||||
@@ -27,6 +29,7 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
adjustStorageAdd = true;
|
||||
showAdjustStorage = false;
|
||||
showUpdateLicense = false;
|
||||
canDownloadLicense = false;
|
||||
showDownloadLicense = false;
|
||||
showChangePlan = false;
|
||||
sub: OrganizationSubscriptionResponse;
|
||||
@@ -42,6 +45,7 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
private apiService: ApiService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService,
|
||||
private stateService: StateService,
|
||||
private messagingService: MessagingService,
|
||||
private route: ActivatedRoute,
|
||||
private organizationService: OrganizationService,
|
||||
@@ -66,6 +70,13 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
this.loading = true;
|
||||
this.userOrg = await this.organizationService.get(this.organizationId);
|
||||
this.sub = await this.apiService.getOrganizationSubscription(this.organizationId);
|
||||
|
||||
const orgs = await this.stateService.getOrganizations();
|
||||
const isAllowedOrgType = Object.values(orgs).some(org => org.planProductType === (ProductType.Enterprise | ProductType.Families));
|
||||
const canDownload = (this.sub.planType !== PlanType.Free && this.subscription == null) ||
|
||||
(this.subscription != null && !this.subscription.cancelled);
|
||||
this.canDownloadLicense = canDownload && isAllowedOrgType;
|
||||
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
@@ -204,14 +215,22 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
get subscriptionMarkedForCancel() {
|
||||
get subscriptionMarkedForCancel() {
|
||||
return (
|
||||
this.subscription != null && !this.subscription.cancelled && this.subscription.cancelAtEndDate
|
||||
);
|
||||
}
|
||||
|
||||
get subscription() {
|
||||
return this.sub != null ? this.sub.subscription : null;
|
||||
const now = new Date();
|
||||
const fiveDays = now.setDate(now.getDate() + 5);
|
||||
if(this.sub === null) return null;
|
||||
if(this.sub.subscription == null) {
|
||||
this.sub.subscription = ({ cancelled: true, cancelAtEndDate: (fiveDays as any)} as any);
|
||||
this.sub.subscription.items = new Array({sponsoredSubscriptionItem: false} as any);
|
||||
}
|
||||
|
||||
return this.sub.subscription;
|
||||
}
|
||||
|
||||
get nextInvoice() {
|
||||
@@ -257,13 +276,6 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
return this.sub.subscription?.items.some((i) => i.sponsoredSubscriptionItem);
|
||||
}
|
||||
|
||||
get canDownloadLicense() {
|
||||
return (
|
||||
(this.sub.planType !== PlanType.Free && this.subscription == null) ||
|
||||
(this.subscription != null && !this.subscription.cancelled)
|
||||
);
|
||||
}
|
||||
|
||||
get subscriptionDesc() {
|
||||
if (this.sub.planType === PlanType.Free) {
|
||||
return this.i18nService.t("subscriptionFreePlan", this.sub.seats.toString());
|
||||
|
||||
Reference in New Issue
Block a user