From 44c8f849ba4c609418fabb5f5fbe3f6ac725645b Mon Sep 17 00:00:00 2001 From: Alaister Young Date: Tue, 19 Aug 2025 12:03:29 +0800 Subject: [PATCH] feat: disable org features (#37991) * feat: disable logs features * feat: disable project homepage features * feat: disable org features * Nit fixes * reenable billing --------- Co-authored-by: Joshen Lim --- .../GeneralSettings/AIOptInLevelSelector.tsx | 83 +++++++++++++------ .../IntegrationSettings.tsx | 13 ++- .../Integrations/IntegrationsSettings.tsx | 13 ++- apps/studio/components/interfaces/Sidebar.tsx | 18 ++-- .../components/layouts/OrganizationLayout.tsx | 2 +- apps/studio/pages/org/[slug]/billing.tsx | 10 ++- .../enabled-features/enabled-features.json | 9 ++ .../enabled-features.schema.json | 33 ++++++++ 8 files changed, 140 insertions(+), 41 deletions(-) diff --git a/apps/studio/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector.tsx b/apps/studio/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector.tsx index 5744f9e177ba9..28e9686ef77e4 100644 --- a/apps/studio/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector.tsx +++ b/apps/studio/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector.tsx @@ -5,6 +5,7 @@ import { AIOptInFormValues } from 'hooks/forms/useAIOptInForm' import { FormField_Shadcn_, RadioGroup_Shadcn_, RadioGroupItem_Shadcn_ } from 'ui' import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' import { OptInToOpenAIToggle } from './OptInToOpenAIToggle' +import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' interface AIOptInLevelSelectorProps { control: Control @@ -13,39 +14,67 @@ interface AIOptInLevelSelectorProps { layout?: 'horizontal' | 'vertical' | 'flex-row-reverse' } -const AI_OPT_IN_LEVELS = [ - { - value: 'disabled', - title: 'Disabled', - description: - 'You do not consent to sharing any database information with Amazon Bedrock and understand that responses will be generic and not tailored to your database', - }, - { - value: 'schema', - title: 'Schema Only', - description: - 'You consent to sharing your database’s schema metadata (such as table and column names, data types, and relationships—but not actual database data) with Amazon Bedrock', - }, - { - value: 'schema_and_log', - title: 'Schema & Logs', - description: - 'You consent to sharing your schema and logs (which may contain PII/database data) with Amazon Bedrock for better results', - }, - { - value: 'schema_and_log_and_data', - title: 'Schema, Logs & Database Data', - description: - 'You consent to give Amazon Bedrock full access to run database read only queries and analyze results for optimal results', - }, -] - export const AIOptInLevelSelector = ({ control, disabled, label, layout = 'vertical', }: AIOptInLevelSelectorProps) => { + const { + aiOptInLevelDisabled, + aiOptInLevelSchema, + aiOptInLevelSchemaAndLog, + aiOptInLevelSchemaAndLogAndData, + } = useIsFeatureEnabled([ + 'ai:opt_in_level_disabled', + 'ai:opt_in_level_schema', + 'ai:opt_in_level_schema_and_log', + 'ai:opt_in_level_schema_and_log_and_data', + ]) + + const AI_OPT_IN_LEVELS = [ + ...(aiOptInLevelDisabled + ? [ + { + value: 'disabled', + title: 'Disabled', + description: + 'You do not consent to sharing any database information with Amazon Bedrock and understand that responses will be generic and not tailored to your database', + }, + ] + : []), + ...(aiOptInLevelSchema + ? [ + { + value: 'schema', + title: 'Schema Only', + description: + 'You consent to sharing your database’s schema metadata (such as table and column names, data types, and relationships—but not actual database data) with Amazon Bedrock', + }, + ] + : []), + ...(aiOptInLevelSchemaAndLog + ? [ + { + value: 'schema_and_log', + title: 'Schema & Logs', + description: + 'You consent to sharing your schema and logs (which may contain PII/database data) with Amazon Bedrock for better results', + }, + ] + : []), + ...(aiOptInLevelSchemaAndLogAndData + ? [ + { + value: 'schema_and_log_and_data', + title: 'Schema, Logs & Database Data', + description: + 'You consent to give Amazon Bedrock full access to run database read only queries and analyze results for optimal results', + }, + ] + : []), + ] + return ( { const router = useRouter() const { data: org } = useSelectedOrganizationQuery() + const showVercelIntegration = useIsFeatureEnabled('integrations:vercel') + const canReadGithubConnection = useCheckPermissions( PermissionAction.READ, 'integrations.github_connections' @@ -179,9 +182,13 @@ The GitHub app will watch for changes in your repository such as file changes, b Integrations - - - + {showVercelIntegration && ( + <> + + + + + )} ) } diff --git a/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx b/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx index 51ce7d775582c..2533fdfdf1df2 100644 --- a/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx +++ b/apps/studio/components/interfaces/Settings/Integrations/IntegrationsSettings.tsx @@ -2,6 +2,7 @@ import Link from 'next/link' import SidePanelVercelProjectLinker from 'components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker' import { ScaffoldContainer, ScaffoldDivider } from 'components/layouts/Scaffold' +import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useProjectByRefQuery, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { BASE_PATH } from 'lib/constants' import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, WarningIcon } from 'ui' @@ -23,6 +24,8 @@ const IntegrationSettings = () => { const { data: parentProject } = useProjectByRefQuery(project?.parent_project_ref) const isBranch = project?.parent_project_ref !== undefined + const showVercelIntegration = useIsFeatureEnabled('integrations:vercel') + return ( <> {isBranch && ( @@ -43,9 +46,13 @@ const IntegrationSettings = () => { )} - - - + {showVercelIntegration && ( + <> + + + + + )} ) } diff --git a/apps/studio/components/interfaces/Sidebar.tsx b/apps/studio/components/interfaces/Sidebar.tsx index 2f6c7ca7c01f9..efda42e425262 100644 --- a/apps/studio/components/interfaces/Sidebar.tsx +++ b/apps/studio/components/interfaces/Sidebar.tsx @@ -355,6 +355,8 @@ const OrganizationLinks = () => { const isUserMFAEnabled = useIsMFAEnabled() const disableAccessMfa = org?.organization_requires_mfa && !isUserMFAEnabled + const showBilling = useIsFeatureEnabled('billing:all') + const activeRoute = router.pathname.split('/')[3] const navMenuItems = [ @@ -382,12 +384,16 @@ const OrganizationLinks = () => { key: 'usage', icon: , }, - { - label: 'Billing', - href: `/org/${slug}/billing`, - key: 'billing', - icon: , - }, + ...(showBilling + ? [ + { + label: 'Billing', + href: `/org/${slug}/billing`, + key: 'billing', + icon: , + }, + ] + : []), { label: 'Organization settings', href: `/org/${slug}/general`, diff --git a/apps/studio/components/layouts/OrganizationLayout.tsx b/apps/studio/components/layouts/OrganizationLayout.tsx index 5df44aa907e58..a705d2c6d3fca 100644 --- a/apps/studio/components/layouts/OrganizationLayout.tsx +++ b/apps/studio/components/layouts/OrganizationLayout.tsx @@ -15,7 +15,7 @@ const OrganizationLayoutContent = ({ children }: PropsWithChildren<{}>) => { }) return ( -
+
{selectedOrganization && selectedOrganization?.managed_by !== 'supabase' && ( { - const { panel } = useParams() + const { panel, slug } = useParams() const snap = useOrgSettingsPageStateSnapshot() + const showBilling = useIsFeatureEnabled('billing:all') + useEffect(() => { const allowedValues = ['subscriptionPlan', 'costControl'] if (panel && typeof panel === 'string' && allowedValues.includes(panel)) { @@ -24,6 +28,10 @@ const OrgBillingSettings: NextPageWithLayout = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [panel]) + if (!showBilling) { + return + } + return } diff --git a/packages/common/enabled-features/enabled-features.json b/packages/common/enabled-features/enabled-features.json index abdb1d71d7fb2..173dfe94b1964 100644 --- a/packages/common/enabled-features/enabled-features.json +++ b/packages/common/enabled-features/enabled-features.json @@ -1,6 +1,15 @@ { "$schema": "./enabled-features.schema.json", + "ai:opt_in_level_disabled": true, + "ai:opt_in_level_schema": true, + "ai:opt_in_level_schema_and_log": true, + "ai:opt_in_level_schema_and_log_and_data": true, + + "billing:all": true, + + "integrations:vercel": true, + "logs:templates": true, "logs:collections": true, diff --git a/packages/common/enabled-features/enabled-features.schema.json b/packages/common/enabled-features/enabled-features.schema.json index 317fca868b22b..9d39cb94b89f3 100644 --- a/packages/common/enabled-features/enabled-features.schema.json +++ b/packages/common/enabled-features/enabled-features.schema.json @@ -6,6 +6,33 @@ "type": "string" }, + "ai:opt_in_level_disabled": { + "type": "boolean", + "description": "Enable the AI opt in level 'disabled'" + }, + "ai:opt_in_level_schema": { + "type": "boolean", + "description": "Enable the AI opt in level 'schema'" + }, + "ai:opt_in_level_schema_and_log": { + "type": "boolean", + "description": "Enable the AI opt in level 'schema_and_log'" + }, + "ai:opt_in_level_schema_and_log_and_data": { + "type": "boolean", + "description": "Enable the AI opt in level 'schema_and_log_and_data'" + }, + + "billing:all": { + "type": "boolean", + "description": "Enable the billing settings page" + }, + + "integrations:vercel": { + "type": "boolean", + "description": "Enable the vercel integration section in the organization and project settings pages" + }, + "logs:templates": { "type": "boolean", "description": "Enable the logs templates page" @@ -52,6 +79,12 @@ } }, "required": [ + "ai:opt_in_level_disabled", + "ai:opt_in_level_schema", + "ai:opt_in_level_schema_and_log", + "ai:opt_in_level_schema_and_log_and_data", + "billing:all", + "integrations:vercel", "profile:show_email", "profile:show_information", "logs:templates",