remove feature flag on billing metered product + fixes (#11570)
- remove feature flag - design fixes
This commit is contained in:
@ -606,7 +606,6 @@ export enum FeatureFlagKey {
|
|||||||
IsCustomDomainEnabled = 'IsCustomDomainEnabled',
|
IsCustomDomainEnabled = 'IsCustomDomainEnabled',
|
||||||
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
||||||
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
|
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
|
||||||
IsMeteredProductBillingEnabled = 'IsMeteredProductBillingEnabled',
|
|
||||||
IsNewRelationEnabled = 'IsNewRelationEnabled',
|
IsNewRelationEnabled = 'IsNewRelationEnabled',
|
||||||
IsPermissionsV2Enabled = 'IsPermissionsV2Enabled',
|
IsPermissionsV2Enabled = 'IsPermissionsV2Enabled',
|
||||||
IsPostgreSQLIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled',
|
IsPostgreSQLIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled',
|
||||||
|
|||||||
@ -544,7 +544,6 @@ export enum FeatureFlagKey {
|
|||||||
IsCustomDomainEnabled = 'IsCustomDomainEnabled',
|
IsCustomDomainEnabled = 'IsCustomDomainEnabled',
|
||||||
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
||||||
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
|
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
|
||||||
IsMeteredProductBillingEnabled = 'IsMeteredProductBillingEnabled',
|
|
||||||
IsNewRelationEnabled = 'IsNewRelationEnabled',
|
IsNewRelationEnabled = 'IsNewRelationEnabled',
|
||||||
IsPermissionsV2Enabled = 'IsPermissionsV2Enabled',
|
IsPermissionsV2Enabled = 'IsPermissionsV2Enabled',
|
||||||
IsPostgreSQLIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled',
|
IsPostgreSQLIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled',
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const StyledContainer = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledLabelSpan = styled.span`
|
const StyledLabelSpan = styled.span`
|
||||||
color: ${({ theme }) => theme.font.color.light};
|
color: ${({ theme }) => theme.font.color.tertiary};
|
||||||
font-size: ${({ theme }) => theme.font.size.xs};
|
font-size: ${({ theme }) => theme.font.size.xs};
|
||||||
font-weight: ${({ theme }) => theme.font.weight.semiBold};
|
font-weight: ${({ theme }) => theme.font.weight.semiBold};
|
||||||
`;
|
`;
|
||||||
@ -20,7 +20,7 @@ const StyledLabelSpan = styled.span`
|
|||||||
const StyledValueSpan = styled.span<{ isPrimaryColor: boolean }>`
|
const StyledValueSpan = styled.span<{ isPrimaryColor: boolean }>`
|
||||||
color: ${({ theme, isPrimaryColor }) =>
|
color: ${({ theme, isPrimaryColor }) =>
|
||||||
isPrimaryColor ? theme.font.color.primary : theme.font.color.secondary};
|
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};
|
font-weight: ${({ theme }) => theme.font.weight.medium};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@ -42,15 +42,14 @@ export const SettingsBillingMonthlyCreditsSection = () => {
|
|||||||
totalCostCents,
|
totalCostCents,
|
||||||
} = useGetWorkflowNodeExecutionUsage();
|
} = useGetWorkflowNodeExecutionUsage();
|
||||||
|
|
||||||
const progressBarValue =
|
const isFreeCreditProgressBarCompleted =
|
||||||
freeUsageQuantity === includedFreeQuantity
|
freeUsageQuantity === includedFreeQuantity;
|
||||||
? 0
|
|
||||||
: (freeUsageQuantity / includedFreeQuantity) * 100;
|
|
||||||
|
|
||||||
const formattedFreeUsageQuantity =
|
const progressBarValue = (freeUsageQuantity / includedFreeQuantity) * 100;
|
||||||
freeUsageQuantity === includedFreeQuantity
|
|
||||||
? formatAmount(freeUsageQuantity)
|
const formattedFreeUsageQuantity = isFreeCreditProgressBarCompleted
|
||||||
: formatNumber(freeUsageQuantity);
|
? formatAmount(freeUsageQuantity)
|
||||||
|
: formatNumber(freeUsageQuantity);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Section>
|
<Section>
|
||||||
@ -65,7 +64,11 @@ export const SettingsBillingMonthlyCreditsSection = () => {
|
|||||||
/>
|
/>
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
value={progressBarValue}
|
value={progressBarValue}
|
||||||
barColor={COLOR.blue}
|
barColor={
|
||||||
|
isFreeCreditProgressBarCompleted
|
||||||
|
? BACKGROUND_LIGHT.quaternary
|
||||||
|
: COLOR.blue
|
||||||
|
}
|
||||||
backgroundColor={BACKGROUND_LIGHT.tertiary}
|
backgroundColor={BACKGROUND_LIGHT.tertiary}
|
||||||
withBorderRadius={true}
|
withBorderRadius={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -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 { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/page/components/SubMenuTopBarContainer';
|
||||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
|
||||||
import { useSubscriptionStatus } from '@/workspace/hooks/useSubscriptionStatus';
|
import { useSubscriptionStatus } from '@/workspace/hooks/useSubscriptionStatus';
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
import {
|
import {
|
||||||
@ -23,7 +22,6 @@ import {
|
|||||||
import { Button } from 'twenty-ui/input';
|
import { Button } from 'twenty-ui/input';
|
||||||
import { Section } from 'twenty-ui/layout';
|
import { Section } from 'twenty-ui/layout';
|
||||||
import {
|
import {
|
||||||
FeatureFlagKey,
|
|
||||||
SubscriptionInterval,
|
SubscriptionInterval,
|
||||||
SubscriptionStatus,
|
SubscriptionStatus,
|
||||||
useBillingPortalSessionQuery,
|
useBillingPortalSessionQuery,
|
||||||
@ -96,10 +94,6 @@ export const SettingsBilling = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isMeteredProductBillingEnabled = useIsFeatureEnabled(
|
|
||||||
FeatureFlagKey.IsMeteredProductBillingEnabled,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SubMenuTopBarContainer
|
<SubMenuTopBarContainer
|
||||||
title={t`Billing`}
|
title={t`Billing`}
|
||||||
@ -112,9 +106,7 @@ export const SettingsBilling = () => {
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<SettingsPageContainer>
|
<SettingsPageContainer>
|
||||||
{isMeteredProductBillingEnabled && (
|
<SettingsBillingMonthlyCreditsSection />
|
||||||
<SettingsBillingMonthlyCreditsSection />
|
|
||||||
)}
|
|
||||||
<Section>
|
<Section>
|
||||||
<H2Title
|
<H2Title
|
||||||
title={t`Manage your subscription`}
|
title={t`Manage your subscription`}
|
||||||
|
|||||||
@ -139,7 +139,9 @@ export class BillingPlanService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const filterPricesByInterval = (product: BillingProduct) =>
|
const filterPricesByInterval = (product: BillingProduct) =>
|
||||||
product.billingPrices.filter((price) => price.interval === interval);
|
product.billingPrices.filter(
|
||||||
|
(price) => price.interval === interval && price.active,
|
||||||
|
);
|
||||||
|
|
||||||
const meteredProductsPrices = meteredProducts.flatMap(
|
const meteredProductsPrices = meteredProducts.flatMap(
|
||||||
filterPricesByInterval,
|
filterPricesByInterval,
|
||||||
|
|||||||
@ -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 { BillingProductService } from 'src/engine/core-modules/billing/services/billing-product.service';
|
||||||
import { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.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 { 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';
|
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -24,7 +22,6 @@ export class BillingService {
|
|||||||
private readonly twentyConfigService: TwentyConfigService,
|
private readonly twentyConfigService: TwentyConfigService,
|
||||||
private readonly billingSubscriptionService: BillingSubscriptionService,
|
private readonly billingSubscriptionService: BillingSubscriptionService,
|
||||||
private readonly billingProductService: BillingProductService,
|
private readonly billingProductService: BillingProductService,
|
||||||
private readonly featureFlagService: FeatureFlagService,
|
|
||||||
@InjectRepository(BillingSubscription, 'core')
|
@InjectRepository(BillingSubscription, 'core')
|
||||||
private readonly billingSubscriptionRepository: Repository<BillingSubscription>,
|
private readonly billingSubscriptionRepository: Repository<BillingSubscription>,
|
||||||
) {}
|
) {}
|
||||||
@ -74,16 +71,6 @@ export class BillingService {
|
|||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
productKey: BillingProductKey,
|
productKey: BillingProductKey,
|
||||||
) {
|
) {
|
||||||
const isMeteredProductBillingEnabled =
|
|
||||||
await this.featureFlagService.isFeatureEnabled(
|
|
||||||
FeatureFlagKey.IsMeteredProductBillingEnabled,
|
|
||||||
workspaceId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!isMeteredProductBillingEnabled) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const subscription =
|
const subscription =
|
||||||
await this.billingSubscriptionService.getCurrentBillingSubscriptionOrThrow(
|
await this.billingSubscriptionService.getCurrentBillingSubscriptionOrThrow(
|
||||||
{ workspaceId },
|
{ workspaceId },
|
||||||
|
|||||||
@ -12,5 +12,4 @@ export enum FeatureFlagKey {
|
|||||||
IsApprovedAccessDomainsEnabled = 'IS_APPROVED_ACCESS_DOMAINS_ENABLED',
|
IsApprovedAccessDomainsEnabled = 'IS_APPROVED_ACCESS_DOMAINS_ENABLED',
|
||||||
IsNewRelationEnabled = 'IS_NEW_RELATION_ENABLED',
|
IsNewRelationEnabled = 'IS_NEW_RELATION_ENABLED',
|
||||||
IsPermissionsV2Enabled = 'IS_PERMISSIONS_V2_ENABLED',
|
IsPermissionsV2Enabled = 'IS_PERMISSIONS_V2_ENABLED',
|
||||||
IsMeteredProductBillingEnabled = 'IS_METERED_PRODUCT_BILLING_ENABLED',
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user