Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<AIOptInFormValues>
Expand All @@ -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 (
<FormItemLayout
label={label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useGitHubConnectionDeleteMutation } from 'data/integrations/github-conn
import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query'
import type { IntegrationProjectConnection } from 'data/integrations/integrations.types'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { BASE_PATH } from 'lib/constants'
import {
Expand All @@ -45,6 +46,8 @@ const IntegrationSettings = () => {
const router = useRouter()
const { data: org } = useSelectedOrganizationQuery()

const showVercelIntegration = useIsFeatureEnabled('integrations:vercel')

const canReadGithubConnection = useCheckPermissions(
PermissionAction.READ,
'integrations.github_connections'
Expand Down Expand Up @@ -179,9 +182,13 @@ The GitHub app will watch for changes in your repository such as file changes, b
<ScaffoldTitle>Integrations</ScaffoldTitle>
</ScaffoldContainerLegacy>
<GitHubSection />
<ScaffoldDivider />
<VercelSection isProjectScoped={false} />
<SidePanelVercelProjectLinker />
{showVercelIntegration && (
<>
<ScaffoldDivider />
<VercelSection isProjectScoped={false} />
<SidePanelVercelProjectLinker />
</>
)}
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 && (
Expand All @@ -43,9 +46,13 @@ const IntegrationSettings = () => {
</ScaffoldContainer>
)}
<GitHubSection />
<ScaffoldDivider />
<VercelSection isProjectScoped={true} />
<SidePanelVercelProjectLinker />
{showVercelIntegration && (
<>
<ScaffoldDivider />
<VercelSection isProjectScoped={true} />
<SidePanelVercelProjectLinker />
</>
)}
</>
)
}
Expand Down
18 changes: 12 additions & 6 deletions apps/studio/components/interfaces/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -382,12 +384,16 @@ const OrganizationLinks = () => {
key: 'usage',
icon: <ChartArea size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
},
{
label: 'Billing',
href: `/org/${slug}/billing`,
key: 'billing',
icon: <Receipt size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
},
...(showBilling
? [
{
label: 'Billing',
href: `/org/${slug}/billing`,
key: 'billing',
icon: <Receipt size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
},
]
: []),
{
label: 'Organization settings',
href: `/org/${slug}/general`,
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/components/layouts/OrganizationLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const OrganizationLayoutContent = ({ children }: PropsWithChildren<{}>) => {
})

return (
<div className={cn('w-full flex flex-col overflow-hidden')}>
<div className={cn('h-full w-full flex flex-col overflow-hidden')}>
{selectedOrganization && selectedOrganization?.managed_by !== 'supabase' && (
<Alert_Shadcn_
variant="default"
Expand Down
10 changes: 9 additions & 1 deletion apps/studio/pages/org/[slug]/billing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import { BillingSettings } from 'components/interfaces/Organization/BillingSetti
import DefaultLayout from 'components/layouts/DefaultLayout'
import OrganizationLayout from 'components/layouts/OrganizationLayout'
import OrganizationSettingsLayout from 'components/layouts/ProjectLayout/OrganizationSettingsLayout'
import { UnknownInterface } from 'components/ui/UnknownInterface'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import {
ORG_SETTINGS_PANEL_KEYS,
useOrgSettingsPageStateSnapshot,
} from 'state/organization-settings'
import type { NextPageWithLayout } from 'types'

const OrgBillingSettings: NextPageWithLayout = () => {
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)) {
Expand All @@ -24,6 +28,10 @@ const OrgBillingSettings: NextPageWithLayout = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [panel])

if (!showBilling) {
return <UnknownInterface urlBack={`/org/${slug}`} />
}

return <BillingSettings />
}

Expand Down
9 changes: 9 additions & 0 deletions packages/common/enabled-features/enabled-features.json
Original file line number Diff line number Diff line change
@@ -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,

Expand Down
33 changes: 33 additions & 0 deletions packages/common/enabled-features/enabled-features.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
Loading