diff --git a/packages/console/src/components/ApplicationCreation/CreateForm/Footer/index.tsx b/packages/console/src/components/ApplicationCreation/CreateForm/Footer/index.tsx index 3dc21dd38e9..0ae1d908d07 100644 --- a/packages/console/src/components/ApplicationCreation/CreateForm/Footer/index.tsx +++ b/packages/console/src/components/ApplicationCreation/CreateForm/Footer/index.tsx @@ -27,7 +27,7 @@ type Props = { function Footer({ selectedType, isLoading, onClickCreate, isThirdParty }: Props) { const { currentSku, - currentSubscription: { planId, isAddOnAvailable, isEnterprisePlan }, + currentSubscription: { planId, isEnterprisePlan }, currentSubscriptionQuota, } = useContext(SubscriptionDataContext); const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell' }); @@ -44,7 +44,6 @@ function Footer({ selectedType, isLoading, onClickCreate, isThirdParty }: Props) if (selectedType) { if ( selectedType === ApplicationType.MachineToMachine && - isAddOnAvailable && hasMachineToMachineAppsReachedLimit && // Just in case the enterprise plan has reached the resource limit, we still need to show charge notice. isPaidPlan(planId, isEnterprisePlan) && diff --git a/packages/console/src/components/ApplicationCreation/CreateForm/index.tsx b/packages/console/src/components/ApplicationCreation/CreateForm/index.tsx index 14778525241..56ee1812631 100644 --- a/packages/console/src/components/ApplicationCreation/CreateForm/index.tsx +++ b/packages/console/src/components/ApplicationCreation/CreateForm/index.tsx @@ -23,6 +23,7 @@ import TypeDescription from '@/pages/Applications/components/TypeDescription'; import modalStyles from '@/scss/modal.module.scss'; import { applicationTypeI18nKey } from '@/types/applications'; import { trySubmitSafe } from '@/utils/form'; +import { isPaidPlan } from '@/utils/subscription'; import Footer from './Footer'; import styles from './index.module.scss'; @@ -57,10 +58,11 @@ function CreateForm({ defaultValues: { type: defaultCreateType, isThirdParty: isDefaultCreateThirdParty }, }); const { - currentSubscription: { isAddOnAvailable, planId }, + currentSubscription: { planId, isEnterprisePlan }, } = useContext(SubscriptionDataContext); const { user } = useCurrentUser(); const { mutate: mutateGlobal } = useSWRConfig(); + const isPaidTenant = isPaidPlan(planId, isEnterprisePlan); const { field: { onChange, value, name, ref }, @@ -125,13 +127,13 @@ function CreateForm({ title="applications.create" subtitle={subtitleElement} paywall={conditional( - isAddOnAvailable && + isPaidTenant && watch('type') === ApplicationType.MachineToMachine && planId !== ReservedPlanId.Pro && ReservedPlanId.Pro )} hasAddOnTag={ - isAddOnAvailable && + isPaidTenant && watch('type') === ApplicationType.MachineToMachine && hasMachineToMachineAppsReachedLimit } diff --git a/packages/console/src/components/FeatureTag/index.tsx b/packages/console/src/components/FeatureTag/index.tsx index 04814275fa1..2a6947d488f 100644 --- a/packages/console/src/components/FeatureTag/index.tsx +++ b/packages/console/src/components/FeatureTag/index.tsx @@ -80,7 +80,7 @@ type CombinedAddOnAndFeatureTagProps = { export function CombinedAddOnAndFeatureTag(props: CombinedAddOnAndFeatureTagProps) { const { hasAddOnTag, className, paywall } = props; const { - currentSubscription: { planId, isAddOnAvailable, isEnterprisePlan }, + currentSubscription: { planId, isEnterprisePlan }, } = useContext(SubscriptionDataContext); // We believe that the enterprise plan has already allocated sufficient resource quotas in the deal negotiation, so there is no need for upselling, nor will it trigger the add-on tag prompt. @@ -88,8 +88,8 @@ export function CombinedAddOnAndFeatureTag(props: CombinedAddOnAndFeatureTagProp return null; } - // Show the "Add-on" tag for Pro plan when dev features enabled. - if (hasAddOnTag && isAddOnAvailable && isCloud && planId === ReservedPlanId.Pro) { + // Show the "Add-on" tag for Pro plan. + if (hasAddOnTag && isCloud && planId === ReservedPlanId.Pro) { return (
Add-on
); diff --git a/packages/console/src/components/PlanUsage/index.tsx b/packages/console/src/components/PlanUsage/index.tsx index 0157c4c53f9..3eff315bccd 100644 --- a/packages/console/src/components/PlanUsage/index.tsx +++ b/packages/console/src/components/PlanUsage/index.tsx @@ -63,13 +63,7 @@ function PlanUsage({ periodicUsage: rawPeriodicUsage }: Props) { currentSubscriptionQuota, currentSubscriptionBasicQuota, currentSubscriptionUsage, - currentSubscription: { - currentPeriodStart, - currentPeriodEnd, - planId, - isAddOnAvailable, - isEnterprisePlan, - }, + currentSubscription: { currentPeriodStart, currentPeriodEnd, planId, isEnterprisePlan }, } = useContext(SubscriptionDataContext); const { currentTenant } = useContext(TenantsContext); @@ -90,19 +84,13 @@ function PlanUsage({ periodicUsage: rawPeriodicUsage }: Props) { } const isPaidTenant = isPaidPlan(planId, isEnterprisePlan); - const onlyShowPeriodicUsage = - planId === ReservedPlanId.Free || (!isAddOnAvailable && planId === ReservedPlanId.Pro); + const onlyShowPeriodicUsage = planId === ReservedPlanId.Free; const usages: PlanUsageCardProps[] = usageKeys // Show all usages for Pro plan and only show MAU and token usage for Free plan .filter( (key) => - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - isAddOnAvailable || - // TODO: design a flow for enterprise tenants onboarding. - // Show all usages for Enterprise plan since some of the enterprise tenants does not have Stripe subscription, as a result, the `isAddOnAvailable` will be undefined in this case, even if we will deprecate `isAddOnAvailable` soon, the plan usage will not be automatically fixed for these enterprise tenants. - isEnterprisePlan || - (onlyShowPeriodicUsage && (key === 'mauLimit' || key === 'tokenLimit')) + isPaidTenant || (onlyShowPeriodicUsage && (key === 'mauLimit' || key === 'tokenLimit')) ) .map((key) => ({ usage: getUsageByKey(key, { diff --git a/packages/console/src/pages/ApiResources/components/CreateForm/Footer.tsx b/packages/console/src/pages/ApiResources/components/CreateForm/Footer.tsx index 4da39009ce0..1d418b6db55 100644 --- a/packages/console/src/pages/ApiResources/components/CreateForm/Footer.tsx +++ b/packages/console/src/pages/ApiResources/components/CreateForm/Footer.tsx @@ -25,7 +25,7 @@ type Props = { function Footer({ isCreationLoading, onClickCreate }: Props) { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { - currentSubscription: { planId, isAddOnAvailable, isEnterprisePlan }, + currentSubscription: { planId, isEnterprisePlan }, currentSubscriptionUsage: { resourcesLimit }, currentSku, } = useContext(SubscriptionDataContext); @@ -59,7 +59,6 @@ function Footer({ isCreationLoading, onClickCreate }: Props) { } if ( - isAddOnAvailable && hasReachedLimit && // Just in case the enterprise plan has reached the resource limit, we still need to show charge notice. isPaidPlan(planId, isEnterprisePlan) && diff --git a/packages/console/src/pages/ApiResources/components/CreateForm/index.tsx b/packages/console/src/pages/ApiResources/components/CreateForm/index.tsx index 4200bbcc013..d944c46abe2 100644 --- a/packages/console/src/pages/ApiResources/components/CreateForm/index.tsx +++ b/packages/console/src/pages/ApiResources/components/CreateForm/index.tsx @@ -16,6 +16,7 @@ import useApi from '@/hooks/use-api'; import useApiResourcesUsage from '@/hooks/use-api-resources-usage'; import modalStyles from '@/scss/modal.module.scss'; import { trySubmitSafe } from '@/utils/form'; +import { isPaidPlan } from '@/utils/subscription'; import Footer from './Footer'; @@ -31,7 +32,7 @@ type Props = { function CreateForm({ onClose }: Props) { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { - currentSubscription: { planId, isAddOnAvailable }, + currentSubscription: { planId, isEnterprisePlan }, } = useContext(SubscriptionDataContext); const { @@ -69,7 +70,7 @@ function CreateForm({ onClose }: Props) { title="api_resources.create" subtitle="api_resources.subtitle" paywall={conditional(planId !== ReservedPlanId.Pro && ReservedPlanId.Pro)} - hasAddOnTag={isAddOnAvailable && hasReachedLimit} + hasAddOnTag={isPaidPlan(planId, isEnterprisePlan) && hasReachedLimit} footer={