1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-02 13:23:29 +01:00

[AC-1423] Update organization subscription cloud page (#5614)

* [AC-1423] Add ProgressModule to shared.module.ts

* [AC-1423] Update cloud subscription page styles

- Remove bootstrap styles
- Use CL components where applicable
- Use CL typography directives
- Update heading levels to prepare for new SM sections

* [AC-1423] Add usePasswordManager boolean to organization domain

* [AC-1423] Introduce BitwardenProductType enum

* [AC-1423] Update Organization subscription line items

- Add product type prefix
- Indent addon services like additional storage and service accounts
- Show line items for free plans

* [AC-1423] Simply sort function

* [AC-1423] Remove header border

* [AC-1423] Make "Password Manager" the default fallback for product name
This commit is contained in:
Shane Melton 2023-06-22 16:17:38 -07:00 committed by GitHub
parent 19d2b2594c
commit 797ca073b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 147 additions and 87 deletions

View File

@ -1,5 +1,5 @@
<div class="page-header"> <div class="tw-mb-2">
<h1> <h1 bitTypography="h1">
{{ "subscription" | i18n }} {{ "subscription" | i18n }}
<small *ngIf="firstLoaded && loading"> <small *ngIf="firstLoaded && loading">
<i <i
@ -7,7 +7,7 @@
title="{{ 'loading' | i18n }}" title="{{ 'loading' | i18n }}"
aria-hidden="true" aria-hidden="true"
></i> ></i>
<span class="sr-only">{{ "loading" | i18n }}</span> <span class="tw-sr-only">{{ "loading" | i18n }}</span>
</small> </small>
</h1> </h1>
</div> </div>
@ -40,47 +40,63 @@
</button> </button>
</bit-callout> </bit-callout>
<div class="row"> <dl class="tw-grid tw-grid-flow-col tw-grid-rows-2">
<div class="col-4"> <dt>{{ "billingPlan" | i18n }}</dt>
<dl> <dd>{{ sub.plan.name }}</dd>
<dt>{{ "billingPlan" | i18n }}</dt> <ng-container *ngIf="subscription">
<dd>{{ sub.plan.name }}</dd> <dt>{{ "status" | i18n }}</dt>
<ng-container *ngIf="subscription"> <dd>
<dt>{{ "status" | i18n }}</dt> <span class="tw-capitalize">{{
<dd> isSponsoredSubscription ? "sponsored" : subscription.status || "-"
<span class="text-capitalize">{{ }}</span>
isSponsoredSubscription ? "sponsored" : subscription.status || "-" <span bitBadge badgeType="warning" *ngIf="subscriptionMarkedForCancel">{{
}}</span> "pendingCancellation" | i18n
<span bitBadge badgeType="warning" *ngIf="subscriptionMarkedForCancel">{{ }}</span>
"pendingCancellation" | i18n </dd>
}}</span> <dt [ngClass]="{ 'tw-text-danger': isExpired }">
</dd> {{ "subscriptionExpiration" | i18n }}
<dt [ngClass]="{ 'tw-text-danger': isExpired }"> </dt>
{{ "subscriptionExpiration" | i18n }} <dd [ngClass]="{ 'tw-text-danger': isExpired }">
</dt> {{ nextInvoice ? (nextInvoice.date | date : "mediumDate") : "-" }}
<dd [ngClass]="{ 'tw-text-danger': isExpired }"> </dd>
{{ nextInvoice ? (nextInvoice.date | date : "mediumDate") : "-" }} </ng-container>
</dd> </dl>
</ng-container> <ng-container *ngIf="userOrg.canEditSubscription">
</dl> <div class="tw-mb-7 tw-flex-col">
</div> <strong class="tw-block tw-border-0 tw-border-b tw-border-solid tw-border-secondary-300">{{
<ng-container *ngIf="userOrg.canEditSubscription"> "details" | i18n
<div class="col-8" *ngIf="subscription"> }}</strong>
<strong class="d-block mb-1">{{ "details" | i18n }}</strong> <bit-table>
<table class="table"> <ng-template body>
<tbody> <ng-container *ngIf="subscription">
<tr *ngFor="let i of subscription.items"> <tr bitRow *ngFor="let i of lineItems">
<td> <td bitCell [ngClass]="{ 'tw-pl-20': i.addonSubscriptionItem }">
<span *ngIf="!i.addonSubscriptionItem"
>{{ productName(i.bitwardenProduct) }} -</span
>
{{ i.name }} {{ i.quantity > 1 ? "&times;" + i.quantity : "" }} @ {{ i.name }} {{ i.quantity > 1 ? "&times;" + i.quantity : "" }} @
{{ i.amount | currency : "$" }} {{ i.amount | currency : "$" }}
</td> </td>
<td>{{ i.quantity * i.amount | currency : "$" }} /{{ i.interval | i18n }}</td> <td bitCell class="tw-text-right">
{{ i.quantity * i.amount | currency : "$" }} /{{ i.interval | i18n }}
</td>
</tr> </tr>
</tbody> </ng-container>
</table> <ng-container *ngIf="userOrg.isFreeOrg">
</div> <tr bitRow *ngIf="userOrg.usePasswordManager">
</ng-container> <td bitCell>{{ "passwordManager" | i18n }} - {{ "freeOrganization" | i18n }}</td>
</div> <td bitCell class="tw-text-right">{{ "free" | i18n }}</td>
</tr>
<tr bitRow *ngIf="userOrg.useSecretsManager">
<td bitCell>{{ "secretsManager" | i18n }} - {{ "freeOrganization" | i18n }}</td>
<td bitCell class="tw-text-right">{{ "free" | i18n }}</td>
</tr>
</ng-container>
</ng-template>
</bit-table>
</div>
</ng-container>
<ng-container *ngIf="userOrg.canEditSubscription"> <ng-container *ngIf="userOrg.canEditSubscription">
<button <button
bitButton bitButton
@ -108,24 +124,23 @@
</ng-container> </ng-container>
<ng-container *ngIf="userOrg.canEditSubscription"> <ng-container *ngIf="userOrg.canEditSubscription">
<h2 class="spaced-header">{{ "manageSubscription" | i18n }}</h2> <h2 bitTypography="h2" class="tw-mt-7">{{ "manageSubscription" | i18n }}</h2>
<p class="mb-4">{{ subscriptionDesc }}</p> <p bitTypography="body1">{{ subscriptionDesc }}</p>
<ng-container <ng-container
*ngIf=" *ngIf="
subscription && canAdjustSeats && !subscription.cancelled && !subscriptionMarkedForCancel subscription && canAdjustSeats && !subscription.cancelled && !subscriptionMarkedForCancel
" "
> >
<div class="mt-3"> <h3 bitTypography="h3" class="tw-mt-7">{{ "passwordManager" | i18n }}</h3>
<app-adjust-subscription <app-adjust-subscription
[seatPrice]="seatPrice" [seatPrice]="seatPrice"
[organizationId]="organizationId" [organizationId]="organizationId"
[interval]="billingInterval" [interval]="billingInterval"
[currentSeatCount]="seats" [currentSeatCount]="seats"
[maxAutoscaleSeats]="maxAutoscaleSeats" [maxAutoscaleSeats]="maxAutoscaleSeats"
(onAdjusted)="subscriptionAdjusted()" (onAdjusted)="subscriptionAdjusted()"
> >
</app-adjust-subscription> </app-adjust-subscription>
</div>
</ng-container> </ng-container>
<button <button
bitButton bitButton
@ -136,33 +151,18 @@
> >
{{ "removeSponsorship" | i18n }} {{ "removeSponsorship" | i18n }}
</button> </button>
<h2 class="spaced-header">{{ "storage" | i18n }}</h2> <h4 bitTypography="h4" class="tw-mt-9">{{ "storage" | i18n }}</h4>
<p>{{ "subscriptionStorage" | i18n : sub.maxStorageGb || 0 : sub.storageName || "0 MB" }}</p> <p bitTypography="body1">
<div class="progress"> {{ "subscriptionStorage" | i18n : sub.maxStorageGb || 0 : sub.storageName || "0 MB" }}
<div </p>
class="progress-bar bg-success" <bit-progress [barWidth]="storagePercentage" bgColor="success"></bit-progress>
role="progressbar"
[ngStyle]="{ width: storageProgressWidth + '%' }"
[attr.aria-valuenow]="storagePercentage"
aria-valuemin="0"
aria-valuemax="100"
>
{{ storagePercentage / 100 | percent }}
</div>
</div>
<ng-container *ngIf="subscription && !subscription.cancelled && !subscriptionMarkedForCancel"> <ng-container *ngIf="subscription && !subscription.cancelled && !subscriptionMarkedForCancel">
<div class="mt-3"> <div class="tw-mt-3">
<div class="d-flex" *ngIf="!showAdjustStorage"> <div class="tw-flex tw-space-x-2" *ngIf="!showAdjustStorage">
<button bitButton buttonType="secondary" type="button" (click)="adjustStorage(true)"> <button bitButton buttonType="secondary" type="button" (click)="adjustStorage(true)">
{{ "addStorage" | i18n }} {{ "addStorage" | i18n }}
</button> </button>
<button <button bitButton buttonType="secondary" type="button" (click)="adjustStorage(false)">
bitButton
buttonType="secondary"
type="button"
class="ml-1"
(click)="adjustStorage(false)"
>
{{ "removeStorage" | i18n }} {{ "removeStorage" | i18n }}
</button> </button>
</div> </div>
@ -179,11 +179,11 @@
</ng-container> </ng-container>
</ng-container> </ng-container>
<h2 class="spaced-header">{{ "selfHostingTitle" | i18n }}</h2> <h2 bitTypography="h2" class="tw-mt-7">{{ "selfHostingTitle" | i18n }}</h2>
<p class="mb-4"> <p bitTypography="body1">
{{ "selfHostingEnterpriseOrganizationSectionCopy" | i18n }} {{ "selfHostingEnterpriseOrganizationSectionCopy" | i18n }}
</p> </p>
<div class="d-flex"> <div class="tw-flex tw-space-x-2">
<button <button
bitButton bitButton
buttonType="secondary" buttonType="secondary"
@ -198,14 +198,13 @@
bitButton bitButton
buttonType="secondary" buttonType="secondary"
type="button" type="button"
class="ml-1"
(click)="manageBillingSync()" (click)="manageBillingSync()"
*ngIf="canManageBillingSync" *ngIf="canManageBillingSync"
> >
{{ (hasBillingSyncToken ? "manageBillingSync" : "setUpBillingSync") | i18n }} {{ (hasBillingSyncToken ? "manageBillingSync" : "setUpBillingSync") | i18n }}
</button> </button>
</div> </div>
<div class="mt-3" *ngIf="showDownloadLicense"> <div class="tw-mt-3" *ngIf="showDownloadLicense">
<app-download-license <app-download-license
[organizationId]="organizationId" [organizationId]="organizationId"
(onDownloaded)="closeDownloadLicense()" (onDownloaded)="closeDownloadLicense()"
@ -213,17 +212,16 @@
></app-download-license> ></app-download-license>
</div> </div>
<ng-container *ngIf="userOrg.canEditSubscription"> <ng-container *ngIf="userOrg.canEditSubscription">
<h2 class="spaced-header">{{ "additionalOptions" | i18n }}</h2> <h2 bitTypography="h2" class="tw-mt-7">{{ "additionalOptions" | i18n }}</h2>
<p class="mb-4"> <p bitTypography="body1">
{{ "additionalOptionsDesc" | i18n }} {{ "additionalOptionsDesc" | i18n }}
</p> </p>
<div class="d-flex"> <div class="tw-flex tw-space-x-2">
<button <button
bitButton bitButton
buttonType="danger" buttonType="danger"
[bitAction]="cancel" [bitAction]="cancel"
type="button" type="button"
class="ml-1"
*ngIf="subscription && !subscription.cancelled && !subscriptionMarkedForCancel" *ngIf="subscription && !subscription.cancelled && !subscriptionMarkedForCancel"
> >
{{ "cancelSubscription" | i18n }} {{ "cancelSubscription" | i18n }}

View File

@ -10,7 +10,9 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
import { OrganizationApiKeyType } from "@bitwarden/common/admin-console/enums"; import { OrganizationApiKeyType } from "@bitwarden/common/admin-console/enums";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { PlanType } from "@bitwarden/common/billing/enums"; import { PlanType } from "@bitwarden/common/billing/enums";
import { BitwardenProductType } from "@bitwarden/common/billing/enums/bitwarden-product-type.enum";
import { OrganizationSubscriptionResponse } from "@bitwarden/common/billing/models/response/organization-subscription.response"; import { OrganizationSubscriptionResponse } from "@bitwarden/common/billing/models/response/organization-subscription.response";
import { BillingSubscriptionItemResponse } from "@bitwarden/common/billing/models/response/subscription.response";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
@ -26,6 +28,7 @@ import {
}) })
export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy { export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy {
sub: OrganizationSubscriptionResponse; sub: OrganizationSubscriptionResponse;
lineItems: BillingSubscriptionItemResponse[] = [];
organizationId: string; organizationId: string;
userOrg: Organization; userOrg: Organization;
showChangePlan = false; showChangePlan = false;
@ -68,6 +71,17 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
.subscribe(); .subscribe();
} }
productName(product: BitwardenProductType) {
switch (product) {
case BitwardenProductType.PasswordManager:
return this.i18nService.t("passwordManager");
case BitwardenProductType.SecretsManager:
return this.i18nService.t("secretsManager");
default:
return this.i18nService.t("passwordManager");
}
}
ngOnDestroy() { ngOnDestroy() {
this.destroy$.next(); this.destroy$.next();
this.destroy$.complete(); this.destroy$.complete();
@ -81,6 +95,7 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
this.userOrg = this.organizationService.get(this.organizationId); this.userOrg = this.organizationService.get(this.organizationId);
if (this.userOrg.canViewSubscription) { if (this.userOrg.canViewSubscription) {
this.sub = await this.organizationApiService.getSubscription(this.organizationId); this.sub = await this.organizationApiService.getSubscription(this.organizationId);
this.lineItems = this.sub?.subscription?.items?.sort(sortSubscriptionItems) ?? [];
} }
const apiKeyResponse = await this.organizationApiService.getApiKeyInformation( const apiKeyResponse = await this.organizationApiService.getApiKeyInformation(
@ -332,3 +347,23 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
return this.subscription == null && this.sub.planType === PlanType.Free && !this.showChangePlan; return this.subscription == null && this.sub.planType === PlanType.Free && !this.showChangePlan;
} }
} }
/**
* Helper to sort subscription items by product type and then by addon status
*/
function sortSubscriptionItems(
a: BillingSubscriptionItemResponse,
b: BillingSubscriptionItemResponse
) {
if (a.bitwardenProduct == b.bitwardenProduct) {
if (a.addonSubscriptionItem == b.addonSubscriptionItem) {
return 0;
}
// sort addon items to the bottom
if (a.addonSubscriptionItem) {
return 1;
}
return -1;
}
return a.bitwardenProduct - b.bitwardenProduct;
}

View File

@ -1,6 +1,6 @@
<form *ngIf="showSecretsManager" [formGroup]="formGroup" [bitSubmit]="submit"> <form *ngIf="showSecretsManager" [formGroup]="formGroup" [bitSubmit]="submit">
<h2 class="spaced-header">{{ "secretsManagerBeta" | i18n }}</h2> <h2 bitTypography="h2" class="tw-mt-7">{{ "secretsManagerBeta" | i18n }}</h2>
<p>{{ "secretsManagerSubscriptionDesc" | i18n }}</p> <p bitTypography="body1">{{ "secretsManagerSubscriptionDesc" | i18n }}</p>
<bit-form-control> <bit-form-control>
<input type="checkbox" bitCheckbox formControlName="enabled" /> <input type="checkbox" bitCheckbox formControlName="enabled" />

View File

@ -23,6 +23,7 @@ import {
LinkModule, LinkModule,
MenuModule, MenuModule,
MultiSelectModule, MultiSelectModule,
ProgressModule,
RadioButtonModule, RadioButtonModule,
SelectModule, SelectModule,
TableModule, TableModule,
@ -69,6 +70,7 @@ import "./locales";
LinkModule, LinkModule,
MenuModule, MenuModule,
MultiSelectModule, MultiSelectModule,
ProgressModule,
RadioButtonModule, RadioButtonModule,
TableModule, TableModule,
TabsModule, TabsModule,
@ -103,6 +105,7 @@ import "./locales";
LinkModule, LinkModule,
MenuModule, MenuModule,
MultiSelectModule, MultiSelectModule,
ProgressModule,
RadioButtonModule, RadioButtonModule,
SelectModule, SelectModule,
TableModule, TableModule,

View File

@ -6610,6 +6610,9 @@
"changeKdfLoggedOutWarning": { "changeKdfLoggedOutWarning": {
"message": "Proceeding will log you out of all active sessions. You will need to log back in and complete two-step login setup. We recommend exporting your vault before changing your encryption settings to prevent data loss." "message": "Proceeding will log you out of all active sessions. You will need to log back in and complete two-step login setup. We recommend exporting your vault before changing your encryption settings to prevent data loss."
}, },
"secretsManager": {
"message": "Secrets Manager"
},
"secretsManagerBeta": { "secretsManagerBeta": {
"message": "Secrets Manager Beta" "message": "Secrets Manager Beta"
}, },
@ -6902,5 +6905,11 @@
}, },
"removeMembersWithoutMasterPasswordWarning": { "removeMembersWithoutMasterPasswordWarning": {
"message": "Removing members who do not have master passwords without setting one for them may restrict access to their full account." "message": "Removing members who do not have master passwords without setting one for them may restrict access to their full account."
},
"passwordManager": {
"message": "Password Manager"
},
"freeOrganization": {
"message": "Free Organization"
} }
} }

View File

@ -22,6 +22,7 @@ export class OrganizationData {
useCustomPermissions: boolean; useCustomPermissions: boolean;
useResetPassword: boolean; useResetPassword: boolean;
useSecretsManager: boolean; useSecretsManager: boolean;
usePasswordManager: boolean;
useActivateAutofillPolicy: boolean; useActivateAutofillPolicy: boolean;
selfHost: boolean; selfHost: boolean;
usersGetPremium: boolean; usersGetPremium: boolean;
@ -74,6 +75,7 @@ export class OrganizationData {
this.useCustomPermissions = response.useCustomPermissions; this.useCustomPermissions = response.useCustomPermissions;
this.useResetPassword = response.useResetPassword; this.useResetPassword = response.useResetPassword;
this.useSecretsManager = response.useSecretsManager; this.useSecretsManager = response.useSecretsManager;
this.usePasswordManager = response.usePasswordManager;
this.useActivateAutofillPolicy = response.useActivateAutofillPolicy; this.useActivateAutofillPolicy = response.useActivateAutofillPolicy;
this.selfHost = response.selfHost; this.selfHost = response.selfHost;
this.usersGetPremium = response.usersGetPremium; this.usersGetPremium = response.usersGetPremium;

View File

@ -31,6 +31,7 @@ export class Organization {
useCustomPermissions: boolean; useCustomPermissions: boolean;
useResetPassword: boolean; useResetPassword: boolean;
useSecretsManager: boolean; useSecretsManager: boolean;
usePasswordManager: boolean;
useActivateAutofillPolicy: boolean; useActivateAutofillPolicy: boolean;
selfHost: boolean; selfHost: boolean;
usersGetPremium: boolean; usersGetPremium: boolean;
@ -87,6 +88,7 @@ export class Organization {
this.useCustomPermissions = obj.useCustomPermissions; this.useCustomPermissions = obj.useCustomPermissions;
this.useResetPassword = obj.useResetPassword; this.useResetPassword = obj.useResetPassword;
this.useSecretsManager = obj.useSecretsManager; this.useSecretsManager = obj.useSecretsManager;
this.usePasswordManager = obj.usePasswordManager;
this.useActivateAutofillPolicy = obj.useActivateAutofillPolicy; this.useActivateAutofillPolicy = obj.useActivateAutofillPolicy;
this.selfHost = obj.selfHost; this.selfHost = obj.selfHost;
this.usersGetPremium = obj.usersGetPremium; this.usersGetPremium = obj.usersGetPremium;

View File

@ -19,6 +19,7 @@ export class ProfileOrganizationResponse extends BaseResponse {
useCustomPermissions: boolean; useCustomPermissions: boolean;
useResetPassword: boolean; useResetPassword: boolean;
useSecretsManager: boolean; useSecretsManager: boolean;
usePasswordManager: boolean;
useActivateAutofillPolicy: boolean; useActivateAutofillPolicy: boolean;
selfHost: boolean; selfHost: boolean;
usersGetPremium: boolean; usersGetPremium: boolean;
@ -65,6 +66,7 @@ export class ProfileOrganizationResponse extends BaseResponse {
this.useCustomPermissions = this.getResponseProperty("UseCustomPermissions") ?? false; this.useCustomPermissions = this.getResponseProperty("UseCustomPermissions") ?? false;
this.useResetPassword = this.getResponseProperty("UseResetPassword"); this.useResetPassword = this.getResponseProperty("UseResetPassword");
this.useSecretsManager = this.getResponseProperty("UseSecretsManager"); this.useSecretsManager = this.getResponseProperty("UseSecretsManager");
this.usePasswordManager = this.getResponseProperty("UsePasswordManager");
this.useActivateAutofillPolicy = this.getResponseProperty("UseActivateAutofillPolicy"); this.useActivateAutofillPolicy = this.getResponseProperty("UseActivateAutofillPolicy");
this.selfHost = this.getResponseProperty("SelfHost"); this.selfHost = this.getResponseProperty("SelfHost");
this.usersGetPremium = this.getResponseProperty("UsersGetPremium"); this.usersGetPremium = this.getResponseProperty("UsersGetPremium");

View File

@ -0,0 +1,4 @@
export enum BitwardenProductType {
PasswordManager = 0,
SecretsManager = 1,
}

View File

@ -1,4 +1,5 @@
import { BaseResponse } from "../../../models/response/base.response"; import { BaseResponse } from "../../../models/response/base.response";
import { BitwardenProductType } from "../../enums/bitwarden-product-type.enum";
export class SubscriptionResponse extends BaseResponse { export class SubscriptionResponse extends BaseResponse {
storageName: string; storageName: string;
@ -62,6 +63,8 @@ export class BillingSubscriptionItemResponse extends BaseResponse {
quantity: number; quantity: number;
interval: string; interval: string;
sponsoredSubscriptionItem: boolean; sponsoredSubscriptionItem: boolean;
addonSubscriptionItem: boolean;
bitwardenProduct: BitwardenProductType;
constructor(response: any) { constructor(response: any) {
super(response); super(response);
@ -70,6 +73,8 @@ export class BillingSubscriptionItemResponse extends BaseResponse {
this.quantity = this.getResponseProperty("Quantity"); this.quantity = this.getResponseProperty("Quantity");
this.interval = this.getResponseProperty("Interval"); this.interval = this.getResponseProperty("Interval");
this.sponsoredSubscriptionItem = this.getResponseProperty("SponsoredSubscriptionItem"); this.sponsoredSubscriptionItem = this.getResponseProperty("SponsoredSubscriptionItem");
this.addonSubscriptionItem = this.getResponseProperty("AddonSubscriptionItem");
this.bitwardenProduct = this.getResponseProperty("BitwardenProduct");
} }
} }