remove freeAccess user logic (#9866)
closes #9763 --------- Co-authored-by: etiennejouan <jouan.etienne@gmail.com>
This commit is contained in:
@ -459,7 +459,6 @@ export enum FeatureFlagKey {
|
|||||||
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
|
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
|
||||||
IsCopilotEnabled = 'IsCopilotEnabled',
|
IsCopilotEnabled = 'IsCopilotEnabled',
|
||||||
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
||||||
IsFreeAccessEnabled = 'IsFreeAccessEnabled',
|
|
||||||
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
|
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
|
||||||
IsLocalizationEnabled = 'IsLocalizationEnabled',
|
IsLocalizationEnabled = 'IsLocalizationEnabled',
|
||||||
IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled',
|
IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled',
|
||||||
|
|||||||
@ -391,7 +391,6 @@ export enum FeatureFlagKey {
|
|||||||
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
|
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
|
||||||
IsCopilotEnabled = 'IsCopilotEnabled',
|
IsCopilotEnabled = 'IsCopilotEnabled',
|
||||||
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
IsEventObjectEnabled = 'IsEventObjectEnabled',
|
||||||
IsFreeAccessEnabled = 'IsFreeAccessEnabled',
|
|
||||||
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
|
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
|
||||||
IsLocalizationEnabled = 'IsLocalizationEnabled',
|
IsLocalizationEnabled = 'IsLocalizationEnabled',
|
||||||
IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled',
|
IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled',
|
||||||
|
|||||||
@ -1,22 +1,16 @@
|
|||||||
import { useCreateAppRouter } from '@/app/hooks/useCreateAppRouter';
|
import { useCreateAppRouter } from '@/app/hooks/useCreateAppRouter';
|
||||||
import { currentUserState } from '@/auth/states/currentUserState';
|
import { currentUserState } from '@/auth/states/currentUserState';
|
||||||
import { billingState } from '@/client-config/states/billingState';
|
import { billingState } from '@/client-config/states/billingState';
|
||||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
|
||||||
import { RouterProvider } from 'react-router-dom';
|
import { RouterProvider } from 'react-router-dom';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { FeatureFlagKey } from '~/generated/graphql';
|
|
||||||
|
|
||||||
export const AppRouter = () => {
|
export const AppRouter = () => {
|
||||||
const billing = useRecoilValue(billingState);
|
const billing = useRecoilValue(billingState);
|
||||||
const isFreeAccessEnabled = useIsFeatureEnabled(
|
|
||||||
FeatureFlagKey.IsFreeAccessEnabled,
|
|
||||||
);
|
|
||||||
|
|
||||||
// We want to disable serverless function settings but keep the code for now
|
// We want to disable serverless function settings but keep the code for now
|
||||||
const isFunctionSettingsEnabled = false;
|
const isFunctionSettingsEnabled = false;
|
||||||
|
|
||||||
const isBillingPageEnabled =
|
const isBillingPageEnabled = billing?.isBillingEnabled;
|
||||||
billing?.isBillingEnabled && !isFreeAccessEnabled;
|
|
||||||
|
|
||||||
const currentUser = useRecoilValue(currentUserState);
|
const currentUser = useRecoilValue(currentUserState);
|
||||||
|
|
||||||
|
|||||||
@ -35,10 +35,8 @@ import { NavigationDrawerItemGroup } from '@/ui/navigation/navigation-drawer/com
|
|||||||
import { NavigationDrawerSection } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSection';
|
import { NavigationDrawerSection } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSection';
|
||||||
import { NavigationDrawerSectionTitle } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle';
|
import { NavigationDrawerSectionTitle } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle';
|
||||||
import { getNavigationSubItemLeftAdornment } from '@/ui/navigation/navigation-drawer/utils/getNavigationSubItemLeftAdornment';
|
import { getNavigationSubItemLeftAdornment } from '@/ui/navigation/navigation-drawer/utils/getNavigationSubItemLeftAdornment';
|
||||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
|
||||||
import { useLingui } from '@lingui/react/macro';
|
import { useLingui } from '@lingui/react/macro';
|
||||||
import { matchPath, resolvePath, useLocation } from 'react-router-dom';
|
import { matchPath, resolvePath, useLocation } from 'react-router-dom';
|
||||||
import { FeatureFlagKey } from '~/generated/graphql';
|
|
||||||
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
import { getSettingsPath } from '~/utils/navigation/getSettingsPath';
|
||||||
|
|
||||||
type SettingsNavigationItem = {
|
type SettingsNavigationItem = {
|
||||||
@ -60,11 +58,7 @@ export const SettingsNavigationDrawerItems = () => {
|
|||||||
// for now
|
// for now
|
||||||
const isFunctionSettingsEnabled = false;
|
const isFunctionSettingsEnabled = false;
|
||||||
|
|
||||||
const isFreeAccessEnabled = useIsFeatureEnabled(
|
const isBillingPageEnabled = billing?.isBillingEnabled;
|
||||||
FeatureFlagKey.IsFreeAccessEnabled,
|
|
||||||
);
|
|
||||||
const isBillingPageEnabled =
|
|
||||||
billing?.isBillingEnabled && !isFreeAccessEnabled;
|
|
||||||
|
|
||||||
const currentUser = useRecoilValue(currentUserState);
|
const currentUser = useRecoilValue(currentUserState);
|
||||||
const isAdminPageEnabled = currentUser?.canImpersonate;
|
const isAdminPageEnabled = currentUser?.canImpersonate;
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import { BillingSubscription } from 'src/engine/core-modules/billing/entities/bi
|
|||||||
import { BillingEntitlementKey } from 'src/engine/core-modules/billing/enums/billing-entitlement-key.enum';
|
import { 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 { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.service';
|
||||||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.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';
|
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -26,23 +25,13 @@ export class BillingService {
|
|||||||
return this.environmentService.get('IS_BILLING_ENABLED');
|
return this.environmentService.get('IS_BILLING_ENABLED');
|
||||||
}
|
}
|
||||||
|
|
||||||
async hasWorkspaceSubscriptionOrFreeAccess(workspaceId: string) {
|
async hasWorkspaceAnySubscription(workspaceId: string) {
|
||||||
const isBillingEnabled = this.isBillingEnabled();
|
const isBillingEnabled = this.isBillingEnabled();
|
||||||
|
|
||||||
if (!isBillingEnabled) {
|
if (!isBillingEnabled) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFreeAccessEnabled =
|
|
||||||
await this.isFeatureEnabledService.isFeatureEnabled(
|
|
||||||
FeatureFlagKey.IsFreeAccessEnabled,
|
|
||||||
workspaceId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isFreeAccessEnabled) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const subscription = await this.billingSubscriptionRepository.findOne({
|
const subscription = await this.billingSubscriptionRepository.findOne({
|
||||||
where: { workspaceId },
|
where: { workspaceId },
|
||||||
});
|
});
|
||||||
@ -50,7 +39,7 @@ export class BillingService {
|
|||||||
return isDefined(subscription);
|
return isDefined(subscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
async hasFreeAccessOrEntitlement(
|
async hasEntitlement(
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
entitlementKey: BillingEntitlementKey,
|
entitlementKey: BillingEntitlementKey,
|
||||||
) {
|
) {
|
||||||
@ -60,16 +49,6 @@ export class BillingService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFreeAccessEnabled =
|
|
||||||
await this.isFeatureEnabledService.isFeatureEnabled(
|
|
||||||
FeatureFlagKey.IsFreeAccessEnabled,
|
|
||||||
workspaceId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isFreeAccessEnabled) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.billingSubscriptionService.getWorkspaceEntitlementByKey(
|
return this.billingSubscriptionService.getWorkspaceEntitlementByKey(
|
||||||
workspaceId,
|
workspaceId,
|
||||||
entitlementKey,
|
entitlementKey,
|
||||||
|
|||||||
@ -4,7 +4,6 @@ export enum FeatureFlagKey {
|
|||||||
IsPostgreSQLIntegrationEnabled = 'IS_POSTGRESQL_INTEGRATION_ENABLED',
|
IsPostgreSQLIntegrationEnabled = 'IS_POSTGRESQL_INTEGRATION_ENABLED',
|
||||||
IsStripeIntegrationEnabled = 'IS_STRIPE_INTEGRATION_ENABLED',
|
IsStripeIntegrationEnabled = 'IS_STRIPE_INTEGRATION_ENABLED',
|
||||||
IsCopilotEnabled = 'IS_COPILOT_ENABLED',
|
IsCopilotEnabled = 'IS_COPILOT_ENABLED',
|
||||||
IsFreeAccessEnabled = 'IS_FREE_ACCESS_ENABLED',
|
|
||||||
IsWorkflowEnabled = 'IS_WORKFLOW_ENABLED',
|
IsWorkflowEnabled = 'IS_WORKFLOW_ENABLED',
|
||||||
IsAnalyticsV2Enabled = 'IS_ANALYTICS_V2_ENABLED',
|
IsAnalyticsV2Enabled = 'IS_ANALYTICS_V2_ENABLED',
|
||||||
IsUniqueIndexesEnabled = 'IS_UNIQUE_INDEXES_ENABLED',
|
IsUniqueIndexesEnabled = 'IS_UNIQUE_INDEXES_ENABLED',
|
||||||
|
|||||||
@ -28,12 +28,10 @@ export class OnboardingService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
private async isSubscriptionIncompleteOnboardingStatus(workspace: Workspace) {
|
private async isSubscriptionIncompleteOnboardingStatus(workspace: Workspace) {
|
||||||
const hasSubscription =
|
const hasAnySubscription =
|
||||||
await this.billingService.hasWorkspaceSubscriptionOrFreeAccess(
|
await this.billingService.hasWorkspaceAnySubscription(workspace.id);
|
||||||
workspace.id,
|
|
||||||
);
|
|
||||||
|
|
||||||
return !hasSubscription;
|
return !hasAnySubscription;
|
||||||
}
|
}
|
||||||
|
|
||||||
private isWorkspaceActivationPending(workspace: Workspace) {
|
private isWorkspaceActivationPending(workspace: Workspace) {
|
||||||
|
|||||||
@ -35,11 +35,10 @@ export class SSOService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
private async isSSOEnabled(workspaceId: string) {
|
private async isSSOEnabled(workspaceId: string) {
|
||||||
const isSSOBillingEnabled =
|
const isSSOBillingEnabled = await this.billingService.hasEntitlement(
|
||||||
await this.billingService.hasFreeAccessOrEntitlement(
|
workspaceId,
|
||||||
workspaceId,
|
this.featureLookUpKey,
|
||||||
this.featureLookUpKey,
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (!isSSOBillingEnabled) {
|
if (!isSSOBillingEnabled) {
|
||||||
throw new SSOException(
|
throw new SSOException(
|
||||||
|
|||||||
Reference in New Issue
Block a user