From 0249cf3b34b82aca8d0a003f36531ab429badd0d Mon Sep 17 00:00:00 2001 From: Etienne <45695613+etiennejouan@users.noreply.github.com> Date: Mon, 14 Apr 2025 18:39:19 +0200 Subject: [PATCH] remove feature flag on billing metered product + fixes (#11570) - remove feature flag - design fixes --- .../src/generated-metadata/graphql.ts | 1 - .../twenty-front/src/generated/graphql.tsx | 1 - .../SettingsBillingLabelValueItem.tsx | 4 ++-- .../SettingsBillingMonthlyCreditsSection.tsx | 21 +++++++++++-------- .../src/pages/settings/SettingsBilling.tsx | 10 +-------- .../billing/services/billing-plan.service.ts | 4 +++- .../billing/services/billing.service.ts | 13 ------------ .../enums/feature-flag-key.enum.ts | 1 - 8 files changed, 18 insertions(+), 37 deletions(-) diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts index d71c26ea2..7e7916d49 100644 --- a/packages/twenty-front/src/generated-metadata/graphql.ts +++ b/packages/twenty-front/src/generated-metadata/graphql.ts @@ -606,7 +606,6 @@ export enum FeatureFlagKey { IsCustomDomainEnabled = 'IsCustomDomainEnabled', IsEventObjectEnabled = 'IsEventObjectEnabled', IsJsonFilterEnabled = 'IsJsonFilterEnabled', - IsMeteredProductBillingEnabled = 'IsMeteredProductBillingEnabled', IsNewRelationEnabled = 'IsNewRelationEnabled', IsPermissionsV2Enabled = 'IsPermissionsV2Enabled', IsPostgreSQLIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled', diff --git a/packages/twenty-front/src/generated/graphql.tsx b/packages/twenty-front/src/generated/graphql.tsx index 8825ebd00..dc4f30cbe 100644 --- a/packages/twenty-front/src/generated/graphql.tsx +++ b/packages/twenty-front/src/generated/graphql.tsx @@ -544,7 +544,6 @@ export enum FeatureFlagKey { IsCustomDomainEnabled = 'IsCustomDomainEnabled', IsEventObjectEnabled = 'IsEventObjectEnabled', IsJsonFilterEnabled = 'IsJsonFilterEnabled', - IsMeteredProductBillingEnabled = 'IsMeteredProductBillingEnabled', IsNewRelationEnabled = 'IsNewRelationEnabled', IsPermissionsV2Enabled = 'IsPermissionsV2Enabled', IsPostgreSQLIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled', diff --git a/packages/twenty-front/src/modules/billing/components/SettingsBillingLabelValueItem.tsx b/packages/twenty-front/src/modules/billing/components/SettingsBillingLabelValueItem.tsx index e6e7bd9e0..0d7664719 100644 --- a/packages/twenty-front/src/modules/billing/components/SettingsBillingLabelValueItem.tsx +++ b/packages/twenty-front/src/modules/billing/components/SettingsBillingLabelValueItem.tsx @@ -12,7 +12,7 @@ const StyledContainer = styled.div` `; const StyledLabelSpan = styled.span` - color: ${({ theme }) => theme.font.color.light}; + color: ${({ theme }) => theme.font.color.tertiary}; font-size: ${({ theme }) => theme.font.size.xs}; font-weight: ${({ theme }) => theme.font.weight.semiBold}; `; @@ -20,7 +20,7 @@ const StyledLabelSpan = styled.span` const StyledValueSpan = styled.span<{ isPrimaryColor: boolean }>` color: ${({ theme, isPrimaryColor }) => isPrimaryColor ? theme.font.color.primary : theme.font.color.secondary}; - font-size: ${({ theme }) => theme.font.size.xs}; + font-size: ${({ theme }) => theme.font.size.sm}; font-weight: ${({ theme }) => theme.font.weight.medium}; `; diff --git a/packages/twenty-front/src/modules/billing/components/SettingsBillingMonthlyCreditsSection.tsx b/packages/twenty-front/src/modules/billing/components/SettingsBillingMonthlyCreditsSection.tsx index 5eb24ed59..e02d8b71b 100644 --- a/packages/twenty-front/src/modules/billing/components/SettingsBillingMonthlyCreditsSection.tsx +++ b/packages/twenty-front/src/modules/billing/components/SettingsBillingMonthlyCreditsSection.tsx @@ -42,15 +42,14 @@ export const SettingsBillingMonthlyCreditsSection = () => { totalCostCents, } = useGetWorkflowNodeExecutionUsage(); - const progressBarValue = - freeUsageQuantity === includedFreeQuantity - ? 0 - : (freeUsageQuantity / includedFreeQuantity) * 100; + const isFreeCreditProgressBarCompleted = + freeUsageQuantity === includedFreeQuantity; - const formattedFreeUsageQuantity = - freeUsageQuantity === includedFreeQuantity - ? formatAmount(freeUsageQuantity) - : formatNumber(freeUsageQuantity); + const progressBarValue = (freeUsageQuantity / includedFreeQuantity) * 100; + + const formattedFreeUsageQuantity = isFreeCreditProgressBarCompleted + ? formatAmount(freeUsageQuantity) + : formatNumber(freeUsageQuantity); return (
@@ -65,7 +64,11 @@ export const SettingsBillingMonthlyCreditsSection = () => { /> diff --git a/packages/twenty-front/src/pages/settings/SettingsBilling.tsx b/packages/twenty-front/src/pages/settings/SettingsBilling.tsx index 6444fa14a..e066cfd21 100644 --- a/packages/twenty-front/src/pages/settings/SettingsBilling.tsx +++ b/packages/twenty-front/src/pages/settings/SettingsBilling.tsx @@ -11,7 +11,6 @@ import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/Snac import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal'; import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer'; -import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { useSubscriptionStatus } from '@/workspace/hooks/useSubscriptionStatus'; import { isDefined } from 'twenty-shared/utils'; import { @@ -23,7 +22,6 @@ import { import { Button } from 'twenty-ui/input'; import { Section } from 'twenty-ui/layout'; import { - FeatureFlagKey, SubscriptionInterval, SubscriptionStatus, useBillingPortalSessionQuery, @@ -96,10 +94,6 @@ export const SettingsBilling = () => { } }; - const isMeteredProductBillingEnabled = useIsFeatureEnabled( - FeatureFlagKey.IsMeteredProductBillingEnabled, - ); - return ( { ]} > - {isMeteredProductBillingEnabled && ( - - )} +
- product.billingPrices.filter((price) => price.interval === interval); + product.billingPrices.filter( + (price) => price.interval === interval && price.active, + ); const meteredProductsPrices = meteredProducts.flatMap( filterPricesByInterval, diff --git a/packages/twenty-server/src/engine/core-modules/billing/services/billing.service.ts b/packages/twenty-server/src/engine/core-modules/billing/services/billing.service.ts index b024edf9d..9347bb562 100644 --- a/packages/twenty-server/src/engine/core-modules/billing/services/billing.service.ts +++ b/packages/twenty-server/src/engine/core-modules/billing/services/billing.service.ts @@ -13,8 +13,6 @@ import { SubscriptionStatus } from 'src/engine/core-modules/billing/enums/billin import { BillingProductService } from 'src/engine/core-modules/billing/services/billing-product.service'; import { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.service'; import { getPlanKeyFromSubscription } from 'src/engine/core-modules/billing/utils/get-plan-key-from-subscription.util'; -import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum'; -import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service'; import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service'; @Injectable() @@ -24,7 +22,6 @@ export class BillingService { private readonly twentyConfigService: TwentyConfigService, private readonly billingSubscriptionService: BillingSubscriptionService, private readonly billingProductService: BillingProductService, - private readonly featureFlagService: FeatureFlagService, @InjectRepository(BillingSubscription, 'core') private readonly billingSubscriptionRepository: Repository, ) {} @@ -74,16 +71,6 @@ export class BillingService { workspaceId: string, productKey: BillingProductKey, ) { - const isMeteredProductBillingEnabled = - await this.featureFlagService.isFeatureEnabled( - FeatureFlagKey.IsMeteredProductBillingEnabled, - workspaceId, - ); - - if (!isMeteredProductBillingEnabled) { - return true; - } - const subscription = await this.billingSubscriptionService.getCurrentBillingSubscriptionOrThrow( { workspaceId }, diff --git a/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts b/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts index cafc1006f..d277aedf6 100644 --- a/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts +++ b/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts @@ -12,5 +12,4 @@ export enum FeatureFlagKey { IsApprovedAccessDomainsEnabled = 'IS_APPROVED_ACCESS_DOMAINS_ENABLED', IsNewRelationEnabled = 'IS_NEW_RELATION_ENABLED', IsPermissionsV2Enabled = 'IS_PERMISSIONS_V2_ENABLED', - IsMeteredProductBillingEnabled = 'IS_METERED_PRODUCT_BILLING_ENABLED', }