Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: disable database features (#38019)

Alaister Young33bd798d1421
diff --git a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
index fb4b6348f36..0d6d2f67061 100644
--- a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
@@ -65,7 +65,8 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
const isView = isTableLikeView(table)
const isMaterializedView = isTableLikeMaterializedView(table)
- const realtimeEnabled = useIsFeatureEnabled('realtime:all')
+ const { realtimeAll: realtimeEnabled, tableEditorEnableRlsToggle: enableRlsToggle } =
+ useIsFeatureEnabled(['realtime:all', 'table_editor:enable_rls_toggle'])
const { isSchemaLocked } = useIsProtectedSchema({ schema: table.schema })
const { mutate: updateTable } = useTableUpdateMutation({
@@ -210,7 +211,8 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
</TooltipContent>
</Tooltip>
)}
- {isTable && !isSchemaLocked ? (
+
+ {enableRlsToggle && isTable && !isSchemaLocked ? (
table.rls_enabled ? (
<>
{policies.length < 1 && !isSchemaLocked ? (
@@ -306,6 +308,7 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
</Popover_Shadcn_>
)
) : null}
+
{isView && viewHasLints && (
<Popover_Shadcn_ modal={false} open={showWarning} onOpenChange={setShowWarning}>
<PopoverTrigger_Shadcn_ asChild>
@@ -356,6 +359,7 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
</PopoverContent_Shadcn_>
</Popover_Shadcn_>
)}
+
{isMaterializedView && materializedViewHasLints && (
<Popover_Shadcn_ modal={false} open={showWarning} onOpenChange={setShowWarning}>
<PopoverTrigger_Shadcn_ asChild>
@@ -398,6 +402,7 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
</PopoverContent_Shadcn_>
</Popover_Shadcn_>
)}
+
{isForeignTable && table.schema === 'public' && (
<Popover_Shadcn_ modal={false} open={showWarning} onOpenChange={setShowWarning}>
<PopoverTrigger_Shadcn_ asChild>
@@ -435,7 +440,9 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
</PopoverContent_Shadcn_>
</Popover_Shadcn_>
)}
+
<RoleImpersonationPopover serviceRoleLabel="postgres" />
+
{isTable && realtimeEnabled && (
<Button
type="default"
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index b1081d1e43d..b62381c2a5b 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -85,7 +85,8 @@ const TableEditor = ({
const { data: org } = useSelectedOrganizationQuery()
const { selectedSchema } = useQuerySchemaState()
const isNewRecord = isUndefined(table)
- const realtimeEnabled = useIsFeatureEnabled('realtime:all')
+ const { realtimeAll: realtimeEnabled, tableEditorEnableRlsToggle: enableRlsToggle } =
+ useIsFeatureEnabled(['realtime:all', 'table_editor:enable_rls_toggle'])
const { mutate: sendEvent } = useSendEventMutation()
const [params, setParams] = useUrlState()
@@ -292,64 +293,68 @@ const TableEditor = ({
</SidePanel.Content>
<SidePanel.Separator />
<SidePanel.Content className="space-y-10 py-6">
- <Checkbox
- id="enable-rls"
- // @ts-ignore
- label={
- <div className="flex items-center space-x-2">
- <span>Enable Row Level Security (RLS)</span>
- <Badge>Recommended</Badge>
- </div>
- }
- description="Restrict access to your table by enabling RLS and writing Postgres policies."
- checked={tableFields.isRLSEnabled}
- onChange={() => {
- // if isEnabled, show confirm modal to turn off
- // if not enabled, allow turning on without modal confirmation
- tableFields.isRLSEnabled
- ? setRlsConfirmVisible(true)
- : onUpdateField({ isRLSEnabled: !tableFields.isRLSEnabled })
- }}
- size="medium"
- />
- {tableFields.isRLSEnabled ? (
- <Admonition
- type="default"
- className="!mt-3"
- title="Policies are required to query data"
- description={
- <>
- You need to create an access policy before you can query data from this table.
- Without a policy, querying this table will return an{' '}
- <u className="text-foreground">empty array</u> of results.{' '}
- {isNewRecord ? 'You can create policies after saving this table.' : ''}
- </>
- }
- >
- <DocsButton
- abbrev={false}
- className="mt-2"
- href="https://supabase.com/docs/guides/auth/row-level-security"
- />
- </Admonition>
- ) : (
- <Admonition
- type="warning"
- className="!mt-3"
- title="You are allowing anonymous access to your table"
- description={
- <>
- {tableFields.name ? `The table ${tableFields.name}` : 'Your table'} will be publicly
- writable and readable
- </>
- }
- >
- <DocsButton
- abbrev={false}
- className="mt-2"
- href="https://supabase.com/docs/guides/auth/row-level-security"
+ {enableRlsToggle && (
+ <>
+ <Checkbox
+ id="enable-rls"
+ // @ts-ignore
+ label={
+ <div className="flex items-center space-x-2">
+ <span>Enable Row Level Security (RLS)</span>
+ <Badge>Recommended</Badge>
+ </div>
+ }
+ description="Restrict access to your table by enabling RLS and writing Postgres policies."
+ checked={tableFields.isRLSEnabled}
+ onChange={() => {
+ // if isEnabled, show confirm modal to turn off
+ // if not enabled, allow turning on without modal confirmation
+ tableFields.isRLSEnabled
+ ? setRlsConfirmVisible(true)
+ : onUpdateField({ isRLSEnabled: !tableFields.isRLSEnabled })
+ }}
+ size="medium"
/>
- </Admonition>
+ {tableFields.isRLSEnabled ? (
+ <Admonition
+ type="default"
+ className="!mt-3"
+ title="Policies are required to query data"
+ description={
+ <>
+ You need to create an access policy before you can query data from this table.
+ Without a policy, querying this table will return an{' '}
+ <u className="text-foreground">empty array</u> of results.{' '}
+ {isNewRecord ? 'You can create policies after saving this table.' : ''}
+ </>
+ }
+ >
+ <DocsButton
+ abbrev={false}
+ className="mt-2"
+ href="https://supabase.com/docs/guides/auth/row-level-security"
+ />
+ </Admonition>
+ ) : (
+ <Admonition
+ type="warning"
+ className="!mt-3"
+ title="You are allowing anonymous access to your table"
+ description={
+ <>
+ {tableFields.name ? `The table ${tableFields.name}` : 'Your table'} will be
+ publicly writable and readable
+ </>
+ }
+ >
+ <DocsButton
+ abbrev={false}
+ className="mt-2"
+ href="https://supabase.com/docs/guides/auth/row-level-security"
+ />
+ </Admonition>
+ )}
+ </>
)}
{realtimeEnabled && (
<Checkbox
diff --git a/apps/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx b/apps/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx
index b3a1b016cff..0d71b585f89 100644
--- a/apps/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx
+++ b/apps/studio/components/layouts/DatabaseLayout/DatabaseLayout.tsx
@@ -5,6 +5,7 @@ import { useIsColumnLevelPrivilegesEnabled } from 'components/interfaces/App/Fea
import { ProductMenu } from 'components/ui/ProductMenu'
import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
+import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { withAuth } from 'hooks/misc/withAuth'
import { useFlag } from 'hooks/ui/useFlag'
@@ -32,6 +33,11 @@ const DatabaseProductMenu = () => {
const columnLevelPrivileges = useIsColumnLevelPrivilegesEnabled()
const enablePgReplicate = useFlag('enablePgReplicate')
+ const { databaseReplication: showPgReplicate, databaseRoles: showRoles } = useIsFeatureEnabled([
+ 'database:replication',
+ 'database:roles',
+ ])
+
return (
<>
<ProductMenu
@@ -41,6 +47,8 @@ const DatabaseProductMenu = () => {
pitrEnabled,
columnLevelPrivileges,
enablePgReplicate,
+ showPgReplicate,
+ showRoles,
})}
/>
</>
diff --git a/apps/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.tsx b/apps/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.tsx
index eb9648b64c7..0e0f2309e30 100644
--- a/apps/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.tsx
+++ b/apps/studio/components/layouts/DatabaseLayout/DatabaseMenu.utils.tsx
@@ -10,11 +10,19 @@ export const generateDatabaseMenu = (
pitrEnabled: boolean
columnLevelPrivileges: boolean
enablePgReplicate: boolean
+ showPgReplicate: boolean
+ showRoles: boolean
}
): ProductMenuGroup[] => {
const ref = project?.ref ?? 'default'
- const { pgNetExtensionExists, pitrEnabled, columnLevelPrivileges, enablePgReplicate } =
- flags || {}
+ const {
+ pgNetExtensionExists,
+ pitrEnabled,
+ columnLevelPrivileges,
+ enablePgReplicate,
+ showPgReplicate,
+ showRoles,
+ } = flags || {}
return [
{
@@ -64,30 +72,25 @@ export const generateDatabaseMenu = (
url: `/project/${ref}/database/publications`,
items: [],
},
- ...(enablePgReplicate
+ ...(showPgReplicate
? [
{
name: 'Replication',
key: 'replication',
url: `/project/${ref}/database/replication`,
+ label: !enablePgReplicate ? 'Coming soon' : undefined,
items: [],
},
]
- : [
- {
- name: 'Replication',
- key: 'replication',
- url: `/project/${ref}/database/replication`,
- label: 'Coming Soon',
- items: [],
- },
- ]),
+ : []),
],
},
{
title: 'Configuration',
items: [
- { name: 'Roles', key: 'roles', url: `/project/${ref}/database/roles`, items: [] },
+ ...(showRoles
+ ? [{ name: 'Roles', key: 'roles', url: `/project/${ref}/database/roles`, items: [] }]
+ : []),
...(columnLevelPrivileges
? [
{
diff --git a/apps/studio/pages/project/[ref]/database/replication/index.tsx b/apps/studio/pages/project/[ref]/database/replication/index.tsx
index 9fb8b9a2287..b89a4e10a16 100644
--- a/apps/studio/pages/project/[ref]/database/replication/index.tsx
+++ b/apps/studio/pages/project/[ref]/database/replication/index.tsx
@@ -1,15 +1,24 @@
+import { useParams } from 'common'
import { ReplicationComingSoon } from 'components/interfaces/Database/Replication/ComingSoon'
import { Destinations } from 'components/interfaces/Database/Replication/Destinations'
import DatabaseLayout from 'components/layouts/DatabaseLayout/DatabaseLayout'
import DefaultLayout from 'components/layouts/DefaultLayout'
import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold'
import { FormHeader } from 'components/ui/Forms/FormHeader'
+import { UnknownInterface } from 'components/ui/UnknownInterface'
+import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useFlag } from 'hooks/ui/useFlag'
import { PipelineRequestStatusProvider } from 'state/replication-pipeline-request-status'
import type { NextPageWithLayout } from 'types'
const DatabaseReplicationPage: NextPageWithLayout = () => {
+ const { ref } = useParams()
const enablePgReplicate = useFlag('enablePgReplicate')
+ const showPgReplicate = useIsFeatureEnabled('database:replication')
+
+ if (!showPgReplicate) {
+ return <UnknownInterface urlBack={`/project/${ref}/database/schemas`} />
+ }
return (
<>
diff --git a/apps/studio/pages/project/[ref]/database/roles.tsx b/apps/studio/pages/project/[ref]/database/roles.tsx
index 3336d719610..7c5800dfcbd 100644
--- a/apps/studio/pages/project/[ref]/database/roles.tsx
+++ b/apps/studio/pages/project/[ref]/database/roles.tsx
@@ -1,11 +1,21 @@
+import { useParams } from 'common'
import { RolesList } from 'components/interfaces/Database'
import DatabaseLayout from 'components/layouts/DatabaseLayout/DatabaseLayout'
import DefaultLayout from 'components/layouts/DefaultLayout'
import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold'
import { FormHeader } from 'components/ui/Forms/FormHeader'
+import { UnknownInterface } from 'components/ui/UnknownInterface'
+import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import type { NextPageWithLayout } from 'types'
const DatabaseRoles: NextPageWithLayout = () => {
+ const { ref } = useParams()
+ const showRoles = useIsFeatureEnabled('database:roles')
+
+ if (!showRoles) {
+ return <UnknownInterface urlBack={`/project/${ref}/database/schemas`} />
+ }
+
return (
<ScaffoldContainer>
<ScaffoldSection>
diff --git a/packages/common/enabled-features/enabled-features.json b/packages/common/enabled-features/enabled-features.json
index 173dfe94b19..b1a4c051292 100644
--- a/packages/common/enabled-features/enabled-features.json
+++ b/packages/common/enabled-features/enabled-features.json
@@ -8,6 +8,9 @@
"billing:all": true,
+ "database:replication": true,
+ "database:roles": true,
+
"integrations:vercel": true,
"logs:templates": true,
@@ -23,5 +26,7 @@
"project_homepage:show_all_client_libraries": true,
"project_homepage:show_instance_size": true,
- "project_homepage:show_examples": true
+ "project_homepage:show_examples": true,
+
+ "table_editor:enable_rls_toggle": true
}
diff --git a/packages/common/enabled-features/enabled-features.schema.json b/packages/common/enabled-features/enabled-features.schema.json
index 9d39cb94b89..3dd3f367738 100644
--- a/packages/common/enabled-features/enabled-features.schema.json
+++ b/packages/common/enabled-features/enabled-features.schema.json
@@ -28,6 +28,15 @@
"description": "Enable the billing settings page"
},
+ "database:replication": {
+ "type": "boolean",
+ "description": "Enable the database replication page"
+ },
+ "database:roles": {
+ "type": "boolean",
+ "description": "Enable the database roles page"
+ },
+
"integrations:vercel": {
"type": "boolean",
"description": "Enable the vercel integration section in the organization and project settings pages"
@@ -76,6 +85,11 @@
"project_homepage:show_all_client_libraries": {
"type": "boolean",
"description": "Show all client libraries examples in the project homepage. When false, all client library examples will be hidden except the JavaScript client library."
+ },
+
+ "table_editor:enable_rls_toggle": {
+ "type": "boolean",
+ "description": "Show the RLS toggle in the table creation flow and table editor header"
}
},
"required": [
@@ -84,6 +98,8 @@
"ai:opt_in_level_schema_and_log",
"ai:opt_in_level_schema_and_log_and_data",
"billing:all",
+ "database:replication",
+ "database:roles",
"integrations:vercel",
"profile:show_email",
"profile:show_information",
@@ -94,7 +110,8 @@
"project_homepage:show_examples",
"project_homepage:show_all_client_libraries",
"project_connection:javascript_example",
- "project_connection:dart_example"
+ "project_connection:dart_example",
+ "table_editor:enable_rls_toggle"
],
"additionalProperties": false
}