Skip to content

Commit 5c671b7

Browse files
committed
fix(data-retention): bypass enterprise gate when billing is disabled for self-hosted
1 parent f1076c0 commit 5c671b7

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

apps/sim/app/api/workspaces/[id]/data-retention/route.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { CLEANUP_CONFIG } from '@/lib/billing/cleanup-dispatcher'
1010
import { getHighestPrioritySubscription } from '@/lib/billing/core/plan'
1111
import { isEnterprisePlan } from '@/lib/billing/core/subscription'
1212
import { getPlanType, type PlanCategory } from '@/lib/billing/plan-helpers'
13+
import { isBillingEnabled } from '@/lib/core/config/feature-flags'
1314
import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils'
1415
import { getWorkspaceBilledAccountUserId } from '@/lib/workspaces/utils'
1516

@@ -79,7 +80,7 @@ export async function GET(_request: NextRequest, { params }: { params: Promise<{
7980

8081
const plan = await resolveWorkspacePlan(ws.billedAccountUserId)
8182
const defaults = getPlanDefaults(plan)
82-
const isEnterpriseWorkspace = plan === 'enterprise'
83+
const isEnterpriseWorkspace = !isBillingEnabled || plan === 'enterprise'
8384

8485
return NextResponse.json({
8586
success: true,
@@ -135,12 +136,14 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
135136
return NextResponse.json({ error: 'Workspace not found' }, { status: 404 })
136137
}
137138

138-
const hasEnterprise = await isEnterprisePlan(billedAccountUserId)
139-
if (!hasEnterprise) {
140-
return NextResponse.json(
141-
{ error: 'Data Retention configuration is available on Enterprise plans only' },
142-
{ status: 403 }
143-
)
139+
if (isBillingEnabled) {
140+
const hasEnterprise = await isEnterprisePlan(billedAccountUserId)
141+
if (!hasEnterprise) {
142+
return NextResponse.json(
143+
{ error: 'Data Retention configuration is available on Enterprise plans only' },
144+
{ status: 403 }
145+
)
146+
}
144147
}
145148

146149
const body = await request.json()

apps/sim/ee/data-retention/components/data-retention-settings.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createLogger } from '@sim/logger'
55
import { toError } from '@sim/utils/errors'
66
import { useParams } from 'next/navigation'
77
import { Button, Combobox, toast } from '@/components/emcn'
8+
import { isBillingEnabled } from '@/lib/core/config/feature-flags'
89
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
910
import { SettingRow } from '@/ee/components/setting-row'
1011
import { DataRetentionSkeleton } from '@/ee/data-retention/components/data-retention-skeleton'
@@ -132,7 +133,7 @@ export function DataRetentionSettings() {
132133
)
133134
}
134135

135-
if (!data.isEnterprise) {
136+
if (isBillingEnabled && !data.isEnterprise) {
136137
return (
137138
<div className='flex h-full items-center justify-center text-[var(--text-muted)] text-sm'>
138139
Data retention is available on Enterprise plans only.

0 commit comments

Comments
 (0)