Skip to content

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

chore: add realtime to disabled features (#18652)

Alaister Younge61be627bb45
diff --git a/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx b/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
index a306c1de5b2..a45f3645e32 100644
--- a/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
+++ b/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx
@@ -5,12 +5,12 @@ import { useParams } from 'common'
import { MousePointer2 } from 'lucide-react'
import Link from 'next/link'
import { useEffect, useRef, useState } from 'react'
-import { Button, IconAlertCircle, IconCode, IconLock, Modal } from 'ui'
+import { Button, IconAlertCircle, IconLock, Modal } from 'ui'
import { rlsAcknowledgedKey } from 'components/grid/constants'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import ConfirmationModal from 'components/ui/ConfirmationModal'
-import { useCheckPermissions, useStore } from 'hooks'
+import { useCheckPermissions, useStore, useIsFeatureEnabled } from 'hooks'
import APIDocsButton from 'components/ui/APIDocsButton'
export interface GridHeaderActionsProps {
@@ -21,6 +21,8 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
const { ref } = useParams()
const { meta, ui } = useStore()
const { project } = useProjectContext()
+ const realtimeEnabled = useIsFeatureEnabled('realtime:all')
+ console.log({ realtimeEnabled })
const [isTogglingRealtime, setIsTogglingRealtime] = useState(false)
const [showEnableRealtime, setShowEnableRealtime] = useState(false)
@@ -39,7 +41,7 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
const canSqlWriteColumns = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'columns')
const isReadOnly = !canSqlWriteTables && !canSqlWriteColumns
// This will change when we allow autogenerated API docs for schemas other than `public`
- const doesHaveAutoGeneratedAPIdocs = table.schema === 'public'
+ const doesHaveAutoGeneratedAPIDocs = table.schema === 'public'
const rlsKey = rlsAcknowledgedKey(table.id.toString())
const rlsAcknowledgedChannel = useRef(new BroadcastChannel(rlsKey))
@@ -140,20 +142,23 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {
</Link>
</Button>
)}
- <Button
- type="default"
- icon={
- <MousePointer2
- size={14}
- className={isRealtimeEnabled ? 'text-brand' : 'text-foreground-lighter'}
- />
- }
- onClick={() => setShowEnableRealtime(true)}
- >
- Realtime {isRealtimeEnabled ? 'on' : 'off'}
- </Button>
-
- {doesHaveAutoGeneratedAPIdocs && (
+
+ {realtimeEnabled && (
+ <Button
+ type="default"
+ icon={
+ <MousePointer2
+ size={14}
+ className={isRealtimeEnabled ? 'text-brand' : 'text-lighter'}
+ />
+ }
+ onClick={() => setShowEnableRealtime(true)}
+ >
+ Realtime {isRealtimeEnabled ? 'on' : 'off'}
+ </Button>
+ )}
+
+ {doesHaveAutoGeneratedAPIDocs && (
<div className="mt-[1px]">
<APIDocsButton section={['entities', table.name]} />
</div>
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index e6d5e4d8649..35d05e2f264 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -6,7 +6,7 @@ import { useEffect, useState } from 'react'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import ConfirmationModal from 'components/ui/ConfirmationModal'
import { useForeignKeyConstraintsQuery } from 'data/database/foreign-key-constraints-query'
-import { useStore } from 'hooks'
+import { useIsFeatureEnabled, useStore } from 'hooks'
import { EXCLUDED_SCHEMAS } from 'lib/constants/schemas'
import { useTableEditorStateSnapshot } from 'state/table-editor'
import { Alert, Badge, Button, Checkbox, IconBookOpen, Input, Modal, SidePanel } from 'ui'
@@ -59,6 +59,8 @@ const TableEditor = ({
const { project } = useProjectContext()
const isNewRecord = isUndefined(table)
+ const realtimeEnabled = useIsFeatureEnabled('realtime:all')
+
const enumTypes = meta.types.list((type: PostgresType) => !EXCLUDED_SCHEMAS.includes(type.schema))
const publications = meta.publications.list()
@@ -286,14 +288,18 @@ const TableEditor = ({
</p>
</Alert>
)}
- <Checkbox
- id="enable-realtime"
- label="Enable Realtime"
- description="Broadcast changes on this table to authorized subscribers"
- checked={tableFields.isRealtimeEnabled}
- onChange={() => onUpdateField({ isRealtimeEnabled: !tableFields.isRealtimeEnabled })}
- size="medium"
- />
+ {realtimeEnabled && (
+ <Checkbox
+ id="enable-realtime"
+ label="Enable Realtime"
+ description="Broadcast changes on this table to authorized subscribers"
+ checked={tableFields.isRealtimeEnabled}
+ onChange={() =>
+ onUpdateField({ isRealtimeEnabled: !tableFields.isRealtimeEnabled })
+ }
+ size="medium"
+ />
+ )}
</div>
</SidePanel.Content>
<SidePanel.Separator />
diff --git a/studio/components/layouts/DocsLayout/DocsLayout.tsx b/studio/components/layouts/DocsLayout/DocsLayout.tsx
deleted file mode 100644
index 7882550e18d..00000000000
--- a/studio/components/layouts/DocsLayout/DocsLayout.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { observer } from 'mobx-react-lite'
-import { useRouter } from 'next/router'
-import { ReactElement, useEffect } from 'react'
-
-import Error from 'components/ui/Error'
-import ProductMenu from 'components/ui/ProductMenu'
-import { useSelectedProject, useStore, withAuth } from 'hooks'
-import { PROJECT_STATUS } from 'lib/constants'
-import ProjectLayout from '../'
-import { generateDocsMenu } from './DocsLayout.utils'
-
-function DocsLayout({ title, children }: { title: string; children: ReactElement }) {
- const router = useRouter()
- const { ui, meta } = useStore()
- const { data, isLoading, error } = meta.openApi
- const selectedProject = useSelectedProject()
- const isPaused = selectedProject?.status === PROJECT_STATUS.INACTIVE
-
- const getPage = () => {
- if (router.pathname.endsWith('graphiql')) return 'graphiql'
-
- const { page, resource } = router.query
- if (!page && !resource) return 'introduction'
- return (page || resource || '') as string
- }
-
- useEffect(() => {
- if (ui.selectedProjectRef && !isPaused) {
- meta.openApi.load()
- }
- }, [ui.selectedProjectRef, isPaused])
-
- if (error) {
- return (
- <ProjectLayout product="API Docs">
- <Error error={error} />
- </ProjectLayout>
- )
- }
-
- const projectRef = selectedProject?.ref ?? 'default'
- const tableNames = (data?.tables ?? []).map((table: any) => table.name)
- const functionNames = (data?.functions ?? []).map((fn: any) => fn.name)
-
- return (
- <ProjectLayout
- title={title || 'API Docs'}
- isLoading={isLoading}
- product="API Docs"
- productMenu={
- <ProductMenu
- page={getPage()}
- menu={generateDocsMenu(projectRef, tableNames, functionNames)}
- />
- }
- >
- {children}
- </ProjectLayout>
- )
-}
-
-export default withAuth(observer(DocsLayout))
diff --git a/studio/components/layouts/DocsLayout/DocsLayout.utils.tsx b/studio/components/layouts/DocsLayout/DocsLayout.utils.tsx
deleted file mode 100644
index 8ee2bb07119..00000000000
--- a/studio/components/layouts/DocsLayout/DocsLayout.utils.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-import SVG from 'react-inlinesvg'
-import { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'
-import { IconBook, IconBookOpen } from 'ui'
-import { BASE_PATH } from 'lib/constants'
-
-export const generateDocsMenu = (
- ref: string,
- tables: string[],
- functions: string[]
-): ProductMenuGroup[] => {
- return [
- {
- title: 'Getting Started',
- items: [
- { name: 'Introduction', key: 'introduction', url: `/project/${ref}/api`, items: [] },
- {
- name: 'Authentication',
- key: 'auth',
- url: `/project/${ref}/api?page=auth`,
- items: [],
- },
- {
- name: 'User Management',
- key: 'users',
- url: `/project/${ref}/api?page=users`,
- items: [],
- },
- ],
- },
- {
- title: 'Tables and Views',
- items: [
- {
- name: 'Introduction',
- key: 'tables-intro',
- url: `/project/${ref}/api?page=tables-intro`,
- items: [],
- },
- ...tables.sort().map((table) => {
- return {
- name: table,
- key: table,
- url: `/project/${ref}/api?resource=${table}`,
- items: [],
- }
- }),
- ],
- },
- {
- title: 'Stored Procedures',
- items: [
- {
- name: 'Introduction',
- key: 'rpc-intro',
- url: `/project/${ref}/api?page=rpc-intro`,
- items: [],
- },
- ...functions.map((fn) => {
- return { name: fn, key: fn, url: `/project/${ref}/api?rpc=${fn}`, items: [] }
- }),
- ],
- },
- {
- title: 'GraphQL',
- items: [
- {
- name: 'GraphiQL',
- key: 'graphiql',
- url: `/project/${ref}/api/graphiql`,
- icon: (
- <SVG
- src={`${BASE_PATH}/img/graphql.svg`}
- style={{ width: `${16}px`, height: `${16}px` }}
- className="text-foreground"
- preProcessor={(code) => code.replace(/svg/, 'svg class="m-auto text-color-inherit"')}
- />
- ),
- items: [],
- },
- ],
- },
- {
- title: 'More Resources',
- items: [
- {
- name: 'Guides',
- key: 'guides',
- url: `https://supabase.com/docs`,
- icon: <IconBook size={14} strokeWidth={2} />,
- items: [],
- isExternal: true,
- },
- {
- name: 'API Reference',
- key: 'api-reference',
- url: `https://supabase.com/docs/guides/api`,
- icon: <IconBookOpen size={14} strokeWidth={2} />,
- items: [],
- isExternal: true,
- },
- ],
- },
- ]
-}
diff --git a/studio/components/layouts/LogsLayout/LogsLayout.tsx b/studio/components/layouts/LogsLayout/LogsLayout.tsx
index 424e2f165be..ee599471dff 100644
--- a/studio/components/layouts/LogsLayout/LogsLayout.tsx
+++ b/studio/components/layouts/LogsLayout/LogsLayout.tsx
@@ -17,10 +17,11 @@ const LogsLayout = ({ title, children }: PropsWithChildren<LogsLayoutProps>) =>
const pathArr = router.pathname.split('/')
const page = pathArr[pathArr.length - 1]
- const { projectAuthAll: authEnabled, projectStorageAll: storageEnabled } = useIsFeatureEnabled([
- 'project_storage:all',
- 'project_auth:all',
- ])
+ const {
+ projectAuthAll: authEnabled,
+ projectStorageAll: storageEnabled,
+ realtimeAll: realtimeEnabled,
+ } = useIsFeatureEnabled(['project_storage:all', 'project_auth:all', 'realtime:all'])
const project = useSelectedProject()
@@ -46,6 +47,7 @@ const LogsLayout = ({ title, children }: PropsWithChildren<LogsLayoutProps>) =>
menu={generateLogsMenu(project, {
auth: authEnabled,
storage: storageEnabled,
+ realtime: realtimeEnabled,
})}
/>
}
diff --git a/studio/components/layouts/LogsLayout/LogsMenu.utils.ts b/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
index 2401d6190a1..da2903945c9 100644
--- a/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
+++ b/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
@@ -4,12 +4,13 @@ import { IS_PLATFORM } from 'lib/constants'
export const generateLogsMenu = (
project?: Project,
- features?: { auth?: boolean; storage?: boolean }
+ features?: { auth?: boolean; storage?: boolean; realtime?: boolean }
): ProductMenuGroup[] => {
const ref = project?.ref ?? 'default'
const authEnabled = features?.auth ?? true
const storageEnabled = features?.storage ?? true
+ const realtimeEnabled = features?.realtime ?? true
return [
{
@@ -73,12 +74,14 @@ export const generateLogsMenu = (
items: [],
}
: null,
- {
- name: 'Realtime',
- key: 'realtime-logs',
- url: `/project/${ref}/logs/realtime-logs`,
- items: [],
- },
+ realtimeEnabled
+ ? {
+ name: 'Realtime',
+ key: 'realtime-logs',
+ url: `/project/${ref}/logs/realtime-logs`,
+ items: [],
+ }
+ : null,
].filter((item) => item) as ProductMenuGroupItem[],
},
]
diff --git a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
index 91f0484751f..2ef5eba751a 100644
--- a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
+++ b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
@@ -55,8 +55,14 @@ const NavigationBar = () => {
projectAuthAll: authEnabled,
projectEdgeFunctionAll: edgeFunctionsEnabled,
projectStorageAll: storageEnabled,
- } = useIsFeatureEnabled(['project_auth:all', 'project_edge_function:all', 'project_storage:all'])
- const realtimeEnabled = useFlag('realtimeDashboard')
+ realtimeAll: realtimeEnabled,
+ } = useIsFeatureEnabled([
+ 'project_auth:all',
+ 'project_edge_function:all',
+ 'project_storage:all',
+ 'realtime:all',
+ ])
+ const realtimeFlagEnabled = useFlag('realtimeDashboard')
const activeRoute = router.pathname.split('/')[3]
const toolRoutes = generateToolRoutes(projectRef, project, supabaseAIEnabled)
@@ -64,7 +70,7 @@ const NavigationBar = () => {
auth: authEnabled,
edgeFunctions: edgeFunctionsEnabled,
storage: storageEnabled,
- realtime: realtimeEnabled,
+ realtime: realtimeEnabled && realtimeFlagEnabled,
})
const otherRoutes = generateOtherRoutes(projectRef, project)
diff --git a/studio/components/layouts/index.ts b/studio/components/layouts/index.ts
index 3213ebfbf7e..4357b8a770d 100644
--- a/studio/components/layouts/index.ts
+++ b/studio/components/layouts/index.ts
@@ -8,7 +8,6 @@ import ProjectLayout, {
import TableEditorLayout from './TableEditorLayout/TableEditorLayout'
import SQLEditorLayout from './SQLEditorLayout/SQLEditorLayout'
import DatabaseLayout from './DatabaseLayout/DatabaseLayout'
-import DocsLayout from './DocsLayout/DocsLayout'
import SettingsLayout from './ProjectSettingsLayout/SettingsLayout'
import StorageLayout from './StorageLayout/StorageLayout'
import AccountLayout from './AccountLayout/AccountLayout'
@@ -28,7 +27,6 @@ export {
SignInLayout,
ForgotPasswordLayout,
DatabaseLayout,
- DocsLayout,
TableEditorLayout,
SQLEditorLayout,
SettingsLayout,