From 6dd1616b5a02d75de1385a29354c4233abd85435 Mon Sep 17 00:00:00 2001 From: Shane Melton Date: Thu, 22 Jun 2023 09:08:31 -0700 Subject: [PATCH] Revert "[AC-1423] Switch to AddonProductType enum instead of boolean" This reverts commit 204f64b4e7f76cf43a7dbc6161332553047592df. --- ...ganization-subscription-cloud.component.html | 6 ++++-- ...organization-subscription-cloud.component.ts | 17 +++++++---------- .../billing/enums/addon-product-type.enum.ts | 8 -------- .../models/response/subscription.response.ts | 5 ++--- 4 files changed, 13 insertions(+), 23 deletions(-) delete mode 100644 libs/common/src/billing/enums/addon-product-type.enum.ts diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html index f6d78864574..20dc22597f5 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html @@ -70,8 +70,10 @@ - - {{ productName(i.bitwardenProduct) }} - + + {{ productName(i.bitwardenProduct) }} - {{ i.name }} {{ i.quantity > 1 ? "×" + i.quantity : "" }} @ {{ i.amount | currency : "$" }} diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts index 7e8fed21d74..ae455e6354f 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.ts @@ -349,25 +349,22 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy } /** - * Helper to sort subscription items by product type and then by addon product type + * Helper to sort subscription items by product type and then by addon status */ function sortSubscriptionItems( a: BillingSubscriptionItemResponse, b: BillingSubscriptionItemResponse ) { if (a.bitwardenProduct == b.bitwardenProduct) { - // Both are addon products, sort by enum value - if (a.addonProduct != null && b.addonProduct != null) { - return a.addonProduct - b.addonProduct; + // sort addon items to the bottom + if (a.addonSubscriptionItem == b.addonSubscriptionItem) { + return 0; } - // 'a' is not an addon product, sort it to the bottom - if (a.addonProduct == null) { - return -1; + if (a.addonSubscriptionItem) { + return 1; } - - // 'a' is an addon product, sort it to the top - return 1; + return -1; } return a.bitwardenProduct - b.bitwardenProduct; } diff --git a/libs/common/src/billing/enums/addon-product-type.enum.ts b/libs/common/src/billing/enums/addon-product-type.enum.ts deleted file mode 100644 index 2e93a10f3e4..00000000000 --- a/libs/common/src/billing/enums/addon-product-type.enum.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Used to identify the various types of "addon" products that can be added - * to an existing product subscription. - */ -export enum AddonProductType { - PasswordManager_Storage = 0, - SecretsManager_ServiceAccounts = 1, -} diff --git a/libs/common/src/billing/models/response/subscription.response.ts b/libs/common/src/billing/models/response/subscription.response.ts index 216d33b28f3..f966a3e9bfa 100644 --- a/libs/common/src/billing/models/response/subscription.response.ts +++ b/libs/common/src/billing/models/response/subscription.response.ts @@ -1,5 +1,4 @@ import { BaseResponse } from "../../../models/response/base.response"; -import { AddonProductType } from "../../enums/addon-product-type.enum"; import { BitwardenProductType } from "../../enums/bitwarden-product-type.enum"; export class SubscriptionResponse extends BaseResponse { @@ -64,7 +63,7 @@ export class BillingSubscriptionItemResponse extends BaseResponse { quantity: number; interval: string; sponsoredSubscriptionItem: boolean; - addonProduct?: AddonProductType; + addonSubscriptionItem: boolean; bitwardenProduct: BitwardenProductType; constructor(response: any) { @@ -74,7 +73,7 @@ export class BillingSubscriptionItemResponse extends BaseResponse { this.quantity = this.getResponseProperty("Quantity"); this.interval = this.getResponseProperty("Interval"); this.sponsoredSubscriptionItem = this.getResponseProperty("SponsoredSubscriptionItem"); - this.addonProduct = this.getResponseProperty("AddonProduct"); + this.addonSubscriptionItem = this.getResponseProperty("AddonSubscriptionItem"); this.bitwardenProduct = this.getResponseProperty("BitwardenProduct"); } }