From 88cbee9b0aeb1ad6b06ba997704a8b1ce3558020 Mon Sep 17 00:00:00 2001 From: Alex Morask <144709477+amorask-bitwarden@users.noreply.github.com> Date: Wed, 13 Nov 2024 09:01:22 -0500 Subject: [PATCH] Remove consolidated billing feature flag (#11969) --- .../layouts/organization-layout.component.ts | 13 ++----- .../guards/organization-is-unmanaged.guard.ts | 11 ------ ...ganization-subscription-cloud.component.ts | 8 +---- .../providers/clients/clients.component.ts | 11 +++--- .../providers/providers-layout.component.html | 2 +- .../providers/providers-layout.component.ts | 12 +++---- .../providers/setup/setup.component.html | 6 ++-- .../providers/setup/setup.component.ts | 36 +++++++------------ .../clients/manage-clients.component.ts | 11 +++--- .../guards/has-consolidated-billing.guard.ts | 13 +------ libs/common/src/billing/abstractions/index.ts | 1 - .../provider-billing.service.abstraction.ts | 23 ------------ libs/common/src/enums/feature-flag.enum.ts | 2 -- 13 files changed, 34 insertions(+), 115 deletions(-) delete mode 100644 libs/common/src/billing/abstractions/provider-billing.service.abstraction.ts diff --git a/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.ts b/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.ts index 6813a59ce4..c4ed44ab0c 100644 --- a/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.ts +++ b/apps/web/src/app/admin-console/organizations/layouts/organization-layout.component.ts @@ -55,10 +55,6 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy { private _destroy = new Subject(); - protected consolidatedBillingEnabled$ = this.configService.getFeatureFlag$( - FeatureFlag.EnableConsolidatedBilling, - ); - constructor( private route: ActivatedRoute, private organizationService: OrganizationService, @@ -101,14 +97,9 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy { switchMap((organization) => this.providerService.get$(organization.providerId)), ); - this.organizationIsUnmanaged$ = combineLatest([ - this.consolidatedBillingEnabled$, - this.organization$, - provider$, - ]).pipe( + this.organizationIsUnmanaged$ = combineLatest([this.organization$, provider$]).pipe( map( - ([consolidatedBillingEnabled, organization, provider]) => - !consolidatedBillingEnabled || + ([organization, provider]) => !organization.hasProvider || !provider || provider.providerStatus !== ProviderStatusType.Billable, diff --git a/apps/web/src/app/billing/guards/organization-is-unmanaged.guard.ts b/apps/web/src/app/billing/guards/organization-is-unmanaged.guard.ts index a915d8f8a6..0f6baa5f32 100644 --- a/apps/web/src/app/billing/guards/organization-is-unmanaged.guard.ts +++ b/apps/web/src/app/billing/guards/organization-is-unmanaged.guard.ts @@ -4,22 +4,11 @@ import { ActivatedRouteSnapshot, CanActivateFn } from "@angular/router"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service"; import { ProviderStatusType } from "@bitwarden/common/admin-console/enums"; -import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; export const organizationIsUnmanaged: CanActivateFn = async (route: ActivatedRouteSnapshot) => { - const configService = inject(ConfigService); const organizationService = inject(OrganizationService); const providerService = inject(ProviderService); - const consolidatedBillingEnabled = await configService.getFeatureFlag( - FeatureFlag.EnableConsolidatedBilling, - ); - - if (!consolidatedBillingEnabled) { - return true; - } - const organization = await organizationService.get(route.params.organizationId); if (!organization.hasProvider) { 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 d4d11d91e0..f5cc89c86b 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 @@ -60,10 +60,6 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy protected readonly subscriptionHiddenIcon = SubscriptionHiddenIcon; protected readonly teamsStarter = ProductTierType.TeamsStarter; - protected enableConsolidatedBilling$ = this.configService.getFeatureFlag$( - FeatureFlag.EnableConsolidatedBilling, - ); - protected enableUpgradePasswordManagerSub$ = this.configService.getFeatureFlag$( FeatureFlag.EnableUpgradePasswordManagerSub, ); @@ -124,8 +120,6 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy this.locale = await firstValueFrom(this.i18nService.locale$); this.userOrg = await this.organizationService.get(this.organizationId); - const consolidatedBillingEnabled = await firstValueFrom(this.enableConsolidatedBilling$); - const isIndependentOrganizationOwner = !this.userOrg.hasProvider && this.userOrg.isOwner; const isResoldOrganizationOwner = this.userOrg.hasReseller && this.userOrg.isOwner; const isMSPUser = this.userOrg.hasProvider && this.userOrg.isProviderUser; @@ -135,7 +129,7 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy ); this.organizationIsManagedByConsolidatedBillingMSP = - consolidatedBillingEnabled && this.userOrg.hasProvider && metadata.isManaged; + this.userOrg.hasProvider && metadata.isManaged; this.showSubscription = isIndependentOrganizationOwner || diff --git a/bitwarden_license/bit-web/src/app/admin-console/providers/clients/clients.component.ts b/bitwarden_license/bit-web/src/app/admin-console/providers/clients/clients.component.ts index 88f125a65a..e397c7ed8e 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/providers/clients/clients.component.ts +++ b/bitwarden_license/bit-web/src/app/admin-console/providers/clients/clients.component.ts @@ -8,11 +8,9 @@ import { SearchService } from "@bitwarden/common/abstractions/search.service"; import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service"; -import { ProviderUserType } from "@bitwarden/common/admin-console/enums"; +import { ProviderStatusType, ProviderUserType } from "@bitwarden/common/admin-console/enums"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; -import { hasConsolidatedBilling } from "@bitwarden/common/billing/abstractions/provider-billing.service.abstraction"; import { PlanType } from "@bitwarden/common/billing/enums"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service"; import { DialogService, ToastService } from "@bitwarden/components"; @@ -46,7 +44,6 @@ export class ClientsComponent extends BaseClientsComponent implements OnInit, On private apiService: ApiService, private organizationService: OrganizationService, private organizationApiService: OrganizationApiServiceAbstraction, - private configService: ConfigService, activatedRoute: ActivatedRoute, dialogService: DialogService, i18nService: I18nService, @@ -72,9 +69,9 @@ export class ClientsComponent extends BaseClientsComponent implements OnInit, On switchMap((params) => { this.providerId = params.providerId; return this.providerService.get$(this.providerId).pipe( - hasConsolidatedBilling(this.configService), - map((hasConsolidatedBilling) => { - if (hasConsolidatedBilling) { + map((provider) => provider?.providerStatus === ProviderStatusType.Billable), + map((isBillable) => { + if (isBillable) { return from( this.router.navigate(["../manage-client-organizations"], { relativeTo: this.activatedRoute, diff --git a/bitwarden_license/bit-web/src/app/admin-console/providers/providers-layout.component.html b/bitwarden_license/bit-web/src/app/admin-console/providers/providers-layout.component.html index 0536221caf..bd21e70a07 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/providers/providers-layout.component.html +++ b/bitwarden_license/bit-web/src/app/admin-console/providers/providers-layout.component.html @@ -5,7 +5,7 @@ (); protected provider$: Observable; - protected hasConsolidatedBilling$: Observable; + protected isBillable: Observable; protected canAccessBilling$: Observable; protected showProviderClientVaultPrivacyWarningBanner$ = this.configService.getFeatureFlag$( @@ -58,12 +58,12 @@ export class ProvidersLayoutComponent implements OnInit, OnDestroy { takeUntil(this.destroy$), ); - this.hasConsolidatedBilling$ = this.provider$.pipe( - hasConsolidatedBilling(this.configService), + this.isBillable = this.provider$.pipe( + map((provider) => provider?.providerStatus === ProviderStatusType.Billable), takeUntil(this.destroy$), ); - this.canAccessBilling$ = combineLatest([this.hasConsolidatedBilling$, this.provider$]).pipe( + this.canAccessBilling$ = combineLatest([this.isBillable, this.provider$]).pipe( map( ([hasConsolidatedBilling, provider]) => hasConsolidatedBilling && provider.isProviderAdmin, ), diff --git a/bitwarden_license/bit-web/src/app/admin-console/providers/setup/setup.component.html b/bitwarden_license/bit-web/src/app/admin-console/providers/setup/setup.component.html index 482b85b712..33a20444c2 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/providers/setup/setup.component.html +++ b/bitwarden_license/bit-web/src/app/admin-console/providers/setup/setup.component.html @@ -24,13 +24,11 @@ {{ "billingEmail" | i18n }} - {{ - "providerBillingEmailHint" | i18n - }} + {{ "providerBillingEmailHint" | i18n }} - + diff --git a/bitwarden_license/bit-web/src/app/admin-console/providers/setup/setup.component.ts b/bitwarden_license/bit-web/src/app/admin-console/providers/setup/setup.component.ts index aaad0ce457..72d954e8cd 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/providers/setup/setup.component.ts +++ b/bitwarden_license/bit-web/src/app/admin-console/providers/setup/setup.component.ts @@ -1,14 +1,13 @@ import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core"; import { FormBuilder, Validators } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; -import { firstValueFrom, Subject, switchMap } from "rxjs"; +import { Subject, switchMap } from "rxjs"; import { first, takeUntil } from "rxjs/operators"; import { ManageTaxInformationComponent } from "@bitwarden/angular/billing/components"; import { ProviderApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/provider/provider-api.service.abstraction"; import { ProviderSetupRequest } from "@bitwarden/common/admin-console/models/request/provider/provider-setup.request"; import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request"; -import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service"; @@ -34,10 +33,6 @@ export class SetupComponent implements OnInit, OnDestroy { billingEmail: ["", [Validators.required, Validators.email]], }); - protected enableConsolidatedBilling$ = this.configService.getFeatureFlag$( - FeatureFlag.EnableConsolidatedBilling, - ); - private destroy$ = new Subject(); constructor( @@ -112,13 +107,9 @@ export class SetupComponent implements OnInit, OnDestroy { submit = async () => { try { - const consolidatedBillingEnabled = await firstValueFrom(this.enableConsolidatedBilling$); - this.formGroup.markAllAsTouched(); - const formIsValid = consolidatedBillingEnabled - ? this.formGroup.valid && this.manageTaxInformationComponent.touch() - : this.formGroup.valid; + const formIsValid = this.formGroup.valid && this.manageTaxInformationComponent.touch(); if (!formIsValid) { return; @@ -133,19 +124,18 @@ export class SetupComponent implements OnInit, OnDestroy { request.token = this.token; request.key = key; - if (consolidatedBillingEnabled) { - request.taxInfo = new ExpandedTaxInfoUpdateRequest(); - const taxInformation = this.manageTaxInformationComponent.getTaxInformation(); + request.taxInfo = new ExpandedTaxInfoUpdateRequest(); + const taxInformation = this.manageTaxInformationComponent.getTaxInformation(); - request.taxInfo.country = taxInformation.country; - request.taxInfo.postalCode = taxInformation.postalCode; - if (taxInformation.includeTaxId) { - request.taxInfo.taxId = taxInformation.taxId; - request.taxInfo.line1 = taxInformation.line1; - request.taxInfo.line2 = taxInformation.line2; - request.taxInfo.city = taxInformation.city; - request.taxInfo.state = taxInformation.state; - } + request.taxInfo.country = taxInformation.country; + request.taxInfo.postalCode = taxInformation.postalCode; + + if (taxInformation.includeTaxId) { + request.taxInfo.taxId = taxInformation.taxId; + request.taxInfo.line1 = taxInformation.line1; + request.taxInfo.line2 = taxInformation.line2; + request.taxInfo.city = taxInformation.city; + request.taxInfo.state = taxInformation.state; } const provider = await this.providerApiService.postProviderSetup(this.providerId, request); diff --git a/bitwarden_license/bit-web/src/app/billing/providers/clients/manage-clients.component.ts b/bitwarden_license/bit-web/src/app/billing/providers/clients/manage-clients.component.ts index a870b053db..b41702e47a 100644 --- a/bitwarden_license/bit-web/src/app/billing/providers/clients/manage-clients.component.ts +++ b/bitwarden_license/bit-web/src/app/billing/providers/clients/manage-clients.component.ts @@ -6,13 +6,11 @@ import { switchMap } from "rxjs/operators"; import { SearchService } from "@bitwarden/common/abstractions/search.service"; import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service"; -import { ProviderUserType } from "@bitwarden/common/admin-console/enums"; +import { ProviderStatusType, ProviderUserType } from "@bitwarden/common/admin-console/enums"; import { Provider } from "@bitwarden/common/admin-console/models/domain/provider"; import { ProviderOrganizationOrganizationDetailsResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-organization.response"; import { BillingApiServiceAbstraction as BillingApiService } from "@bitwarden/common/billing/abstractions/billing-api.service.abstraction"; -import { hasConsolidatedBilling } from "@bitwarden/common/billing/abstractions/provider-billing.service.abstraction"; import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service"; import { DialogService, ToastService } from "@bitwarden/components"; @@ -47,7 +45,6 @@ export class ManageClientsComponent extends BaseClientsComponent { constructor( private billingApiService: BillingApiService, - private configService: ConfigService, private providerService: ProviderService, private router: Router, activatedRoute: ActivatedRoute, @@ -73,9 +70,9 @@ export class ManageClientsComponent extends BaseClientsComponent { switchMap((params) => { this.providerId = params.providerId; return this.providerService.get$(this.providerId).pipe( - hasConsolidatedBilling(this.configService), - map((hasConsolidatedBilling) => { - if (!hasConsolidatedBilling) { + map((provider) => provider?.providerStatus === ProviderStatusType.Billable), + map((isBillable) => { + if (!isBillable) { return from( this.router.navigate(["../clients"], { relativeTo: this.activatedRoute, diff --git a/bitwarden_license/bit-web/src/app/billing/providers/guards/has-consolidated-billing.guard.ts b/bitwarden_license/bit-web/src/app/billing/providers/guards/has-consolidated-billing.guard.ts index 213b9a5368..60dbf4b3b8 100644 --- a/bitwarden_license/bit-web/src/app/billing/providers/guards/has-consolidated-billing.guard.ts +++ b/bitwarden_license/bit-web/src/app/billing/providers/guards/has-consolidated-billing.guard.ts @@ -4,24 +4,13 @@ import { firstValueFrom } from "rxjs"; import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service"; import { ProviderStatusType } from "@bitwarden/common/admin-console/enums"; -import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; export const hasConsolidatedBilling: CanActivateFn = async (route: ActivatedRouteSnapshot) => { - const configService = inject(ConfigService); const providerService = inject(ProviderService); const provider = await firstValueFrom(providerService.get$(route.params.providerId)); - const consolidatedBillingEnabled = await configService.getFeatureFlag( - FeatureFlag.EnableConsolidatedBilling, - ); - - if ( - !consolidatedBillingEnabled || - !provider || - provider.providerStatus !== ProviderStatusType.Billable - ) { + if (!provider || provider.providerStatus !== ProviderStatusType.Billable) { return createUrlTreeFromSnapshot(route, ["/providers", route.params.providerId]); } diff --git a/libs/common/src/billing/abstractions/index.ts b/libs/common/src/billing/abstractions/index.ts index 7ed0f1251a..3f72cd9d2c 100644 --- a/libs/common/src/billing/abstractions/index.ts +++ b/libs/common/src/billing/abstractions/index.ts @@ -1,4 +1,3 @@ export * from "./account/billing-account-profile-state.service"; export * from "./billing-api.service.abstraction"; export * from "./organization-billing.service"; -export * from "./provider-billing.service.abstraction"; diff --git a/libs/common/src/billing/abstractions/provider-billing.service.abstraction.ts b/libs/common/src/billing/abstractions/provider-billing.service.abstraction.ts deleted file mode 100644 index aa8568d8e9..0000000000 --- a/libs/common/src/billing/abstractions/provider-billing.service.abstraction.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { map, Observable, OperatorFunction, switchMap } from "rxjs"; - -import { ProviderStatusType } from "@bitwarden/common/admin-console/enums"; -import { Provider } from "@bitwarden/common/admin-console/models/domain/provider"; -import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; - -type MaybeProvider = Provider | undefined; - -export const hasConsolidatedBilling = ( - configService: ConfigService, -): OperatorFunction => - switchMap>((provider) => - configService - .getFeatureFlag$(FeatureFlag.EnableConsolidatedBilling) - .pipe( - map((consolidatedBillingEnabled) => - provider - ? provider.providerStatus === ProviderStatusType.Billable && consolidatedBillingEnabled - : false, - ), - ), - ); diff --git a/libs/common/src/enums/feature-flag.enum.ts b/libs/common/src/enums/feature-flag.enum.ts index bb96e9b3ee..a12d05e99b 100644 --- a/libs/common/src/enums/feature-flag.enum.ts +++ b/libs/common/src/enums/feature-flag.enum.ts @@ -7,7 +7,6 @@ export enum FeatureFlag { BrowserFilelessImport = "browser-fileless-import", ItemShare = "item-share", GeneratorToolsModernization = "generator-tools-modernization", - EnableConsolidatedBilling = "enable-consolidated-billing", AC1795_UpdatedSubscriptionStatusSection = "AC-1795_updated-subscription-status-section", ExtensionRefresh = "extension-refresh", PersistPopupView = "persist-popup-view", @@ -59,7 +58,6 @@ export const DefaultFeatureFlagValue = { [FeatureFlag.BrowserFilelessImport]: FALSE, [FeatureFlag.ItemShare]: FALSE, [FeatureFlag.GeneratorToolsModernization]: FALSE, - [FeatureFlag.EnableConsolidatedBilling]: FALSE, [FeatureFlag.AC1795_UpdatedSubscriptionStatusSection]: FALSE, [FeatureFlag.ExtensionRefresh]: FALSE, [FeatureFlag.PersistPopupView]: FALSE,