The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
remove freeAccess user logic (#9866)
Etienne10476fcb01eb
diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.tsindex 109337e8f8f..11b82291415 100644--- a/packages/twenty-front/src/generated-metadata/graphql.ts+++ b/packages/twenty-front/src/generated-metadata/graphql.ts@@ -459,7 +459,6 @@ export enum FeatureFlagKey {IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',IsCopilotEnabled = 'IsCopilotEnabled',IsEventObjectEnabled = 'IsEventObjectEnabled',- IsFreeAccessEnabled = 'IsFreeAccessEnabled',IsJsonFilterEnabled = 'IsJsonFilterEnabled',IsLocalizationEnabled = 'IsLocalizationEnabled',IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled',diff --git a/packages/twenty-front/src/generated/graphql.tsx b/packages/twenty-front/src/generated/graphql.tsxindex 03d516706ae..e8a727b255b 100644--- a/packages/twenty-front/src/generated/graphql.tsx+++ b/packages/twenty-front/src/generated/graphql.tsx@@ -391,7 +391,6 @@ export enum FeatureFlagKey {IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',IsCopilotEnabled = 'IsCopilotEnabled',IsEventObjectEnabled = 'IsEventObjectEnabled',- IsFreeAccessEnabled = 'IsFreeAccessEnabled',IsJsonFilterEnabled = 'IsJsonFilterEnabled',IsLocalizationEnabled = 'IsLocalizationEnabled',IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled',diff --git a/packages/twenty-front/src/modules/app/components/AppRouter.tsx b/packages/twenty-front/src/modules/app/components/AppRouter.tsxindex f4637d2c42b..0ad07c1e49a 100644--- a/packages/twenty-front/src/modules/app/components/AppRouter.tsx+++ b/packages/twenty-front/src/modules/app/components/AppRouter.tsx@@ -1,22 +1,16 @@import { useCreateAppRouter } from '@/app/hooks/useCreateAppRouter';import { currentUserState } from '@/auth/states/currentUserState';import { billingState } from '@/client-config/states/billingState';-import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';import { RouterProvider } from 'react-router-dom';import { useRecoilValue } from 'recoil';-import { FeatureFlagKey } from '~/generated/graphql';export const AppRouter = () => {const billing = useRecoilValue(billingState);- const isFreeAccessEnabled = useIsFeatureEnabled(- FeatureFlagKey.IsFreeAccessEnabled,- );// We want to disable serverless function settings but keep the code for nowconst isFunctionSettingsEnabled = false;- const isBillingPageEnabled =- billing?.isBillingEnabled && !isFreeAccessEnabled;+ const isBillingPageEnabled = billing?.isBillingEnabled;const currentUser = useRecoilValue(currentUserState);diff --git a/packages/twenty-front/src/modules/settings/components/SettingsNavigationDrawerItems.tsx b/packages/twenty-front/src/modules/settings/components/SettingsNavigationDrawerItems.tsxindex 5fd9d1a8bbf..9083dfd879f 100644--- a/packages/twenty-front/src/modules/settings/components/SettingsNavigationDrawerItems.tsx+++ b/packages/twenty-front/src/modules/settings/components/SettingsNavigationDrawerItems.tsx@@ -35,10 +35,8 @@ import { NavigationDrawerItemGroup } from '@/ui/navigation/navigation-drawer/comimport { NavigationDrawerSection } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSection';import { NavigationDrawerSectionTitle } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle';import { getNavigationSubItemLeftAdornment } from '@/ui/navigation/navigation-drawer/utils/getNavigationSubItemLeftAdornment';-import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';import { useLingui } from '@lingui/react/macro';import { matchPath, resolvePath, useLocation } from 'react-router-dom';-import { FeatureFlagKey } from '~/generated/graphql';import { getSettingsPath } from '~/utils/navigation/getSettingsPath';type SettingsNavigationItem = {@@ -60,11 +58,7 @@ export const SettingsNavigationDrawerItems = () => {// for nowconst isFunctionSettingsEnabled = false;- const isFreeAccessEnabled = useIsFeatureEnabled(- FeatureFlagKey.IsFreeAccessEnabled,- );- const isBillingPageEnabled =- billing?.isBillingEnabled && !isFreeAccessEnabled;+ const isBillingPageEnabled = billing?.isBillingEnabled;const currentUser = useRecoilValue(currentUserState);const isAdminPageEnabled = currentUser?.canImpersonate;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.tsindex 6e30b9f3c2d..1d219aea839 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@@ -8,7 +8,6 @@ import { BillingSubscription } from 'src/engine/core-modules/billing/entities/biimport { BillingEntitlementKey } from 'src/engine/core-modules/billing/enums/billing-entitlement-key.enum';import { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.service';import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';-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';@Injectable()@@ -26,23 +25,13 @@ export class BillingService {return this.environmentService.get('IS_BILLING_ENABLED');}- async hasWorkspaceSubscriptionOrFreeAccess(workspaceId: string) {+ async hasWorkspaceAnySubscription(workspaceId: string) {const isBillingEnabled = this.isBillingEnabled();if (!isBillingEnabled) {return true;}- const isFreeAccessEnabled =- await this.isFeatureEnabledService.isFeatureEnabled(- FeatureFlagKey.IsFreeAccessEnabled,- workspaceId,- );-- if (isFreeAccessEnabled) {- return true;- }-const subscription = await this.billingSubscriptionRepository.findOne({where: { workspaceId },});@@ -50,7 +39,7 @@ export class BillingService {return isDefined(subscription);}- async hasFreeAccessOrEntitlement(+ async hasEntitlement(workspaceId: string,entitlementKey: BillingEntitlementKey,) {@@ -60,16 +49,6 @@ export class BillingService {return true;}- const isFreeAccessEnabled =- await this.isFeatureEnabledService.isFeatureEnabled(- FeatureFlagKey.IsFreeAccessEnabled,- workspaceId,- );-- if (isFreeAccessEnabled) {- return true;- }-return this.billingSubscriptionService.getWorkspaceEntitlementByKey(workspaceId,entitlementKey,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.tsindex a3c266ba490..b23ea9c810b 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@@ -4,7 +4,6 @@ export enum FeatureFlagKey {IsPostgreSQLIntegrationEnabled = 'IS_POSTGRESQL_INTEGRATION_ENABLED',IsStripeIntegrationEnabled = 'IS_STRIPE_INTEGRATION_ENABLED',IsCopilotEnabled = 'IS_COPILOT_ENABLED',- IsFreeAccessEnabled = 'IS_FREE_ACCESS_ENABLED',IsWorkflowEnabled = 'IS_WORKFLOW_ENABLED',IsAnalyticsV2Enabled = 'IS_ANALYTICS_V2_ENABLED',IsUniqueIndexesEnabled = 'IS_UNIQUE_INDEXES_ENABLED',diff --git a/packages/twenty-server/src/engine/core-modules/onboarding/onboarding.service.ts b/packages/twenty-server/src/engine/core-modules/onboarding/onboarding.service.tsindex 413df67c6fc..f8f81338377 100644--- a/packages/twenty-server/src/engine/core-modules/onboarding/onboarding.service.ts+++ b/packages/twenty-server/src/engine/core-modules/onboarding/onboarding.service.ts@@ -28,12 +28,10 @@ export class OnboardingService {) {}private async isSubscriptionIncompleteOnboardingStatus(workspace: Workspace) {- const hasSubscription =- await this.billingService.hasWorkspaceSubscriptionOrFreeAccess(- workspace.id,- );+ const hasAnySubscription =+ await this.billingService.hasWorkspaceAnySubscription(workspace.id);- return !hasSubscription;+ return !hasAnySubscription;}private isWorkspaceActivationPending(workspace: Workspace) {diff --git a/packages/twenty-server/src/engine/core-modules/sso/services/sso.service.ts b/packages/twenty-server/src/engine/core-modules/sso/services/sso.service.tsindex 3719bb6ee55..b72ab4f2111 100644--- a/packages/twenty-server/src/engine/core-modules/sso/services/sso.service.ts+++ b/packages/twenty-server/src/engine/core-modules/sso/services/sso.service.ts@@ -35,11 +35,10 @@ export class SSOService {) {}private async isSSOEnabled(workspaceId: string) {- const isSSOBillingEnabled =- await this.billingService.hasFreeAccessOrEntitlement(- workspaceId,- this.featureLookUpKey,- );+ const isSSOBillingEnabled = await this.billingService.hasEntitlement(+ workspaceId,+ this.featureLookUpKey,+ );if (!isSSOBillingEnabled) {throw new SSOException(