Skip to content

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

Set up feature preview for explorer (#49602)

Joshen Lim2d1a2ff9a235
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/ExplorerPreview.tsx b/apps/studio/components/interfaces/App/FeaturePreview/ExplorerPreview.tsx
new file mode 100644
index 00000000000..f64d5fef769
--- /dev/null
+++ b/apps/studio/components/interfaces/App/FeaturePreview/ExplorerPreview.tsx
@@ -0,0 +1,55 @@
+import { useParams } from 'common'
+import Image from 'next/image'
+
+import { useIsExplorerEnabled } from './FeaturePreviewContext'
+import { InlineLink } from '@/components/ui/InlineLink'
+import { BASE_PATH } from '@/lib/constants'
+
+export const ExplorerPreview = () => {
+ const { ref } = useParams()
+ const isExplorerEnabled = useIsExplorerEnabled()
+
+ return (
+ <div className="flex flex-col gap-y-4">
+ <p className="text-sm text-foreground-light">
+ The Explorer is a new unified workspace for querying your data and chatting with the
+ Assistant, and is an early preview of where we're heading with the SQL Editor.
+ </p>
+ <p className="text-sm text-foreground-light">
+ Notebooks are the first new feature of the Explorer — mix query cells and markdown notes in
+ a single document, so your queries and context stay together. Use them to write runbooks,
+ document incidents, build reusable reports, and more!
+ </p>
+
+ <Image
+ src={`${BASE_PATH}/img/previews/explorer-preview.png`}
+ width={1296}
+ height={900}
+ alt="explorer-preview"
+ className="rounded-sm border"
+ />
+
+ <div className="space-y-2">
+ <p className="text-sm">Enabling this preview will:</p>
+ <ul className="list-disc pl-6 text-sm text-foreground-light space-y-1">
+ <li>
+ Replace the existing SQL Editor with the new{' '}
+ <InlineLink
+ href={isExplorerEnabled ? `/project/${ref}/explorer` : `/project/${ref}/sql/new`}
+ >
+ Explorer
+ </InlineLink>
+ .
+ <ul className="list-disc pl-6 text-sm text-foreground-light">
+ <li>
+ We're looking to replace the SQL Editor with the Explorer in the long term, but for
+ now it lives alongside the SQL Editor, toggleable via this feature preview.
+ </li>
+ </ul>
+ </li>
+ <li>Enable managing of Notebooks through both the dashboard and the Assistant.</li>
+ </ul>
+ </div>
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
index 2eeb77a318f..739b178761e 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
@@ -165,6 +165,12 @@ export const useIsDatabaseConnectionsEnabled = () => {
}
}
+export const useIsExplorerEnabled = () => {
+ const { flags } = useFeaturePreviewContext()
+ const isExplorerEnabled = useFlag('explorer')
+ return isExplorerEnabled && flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_EXPLORER]
+}
+
export const useFeaturePreviewModal = () => {
const featurePreviews = useFeaturePreviews()
const [featurePreviewModal, setFeaturePreviewModal] = useQueryState('featurePreviewModal')
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
index 24ad9662f92..ff43cc11831 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
@@ -34,6 +34,7 @@ import {
import { AdvisorRulesPreview } from './AdvisorRulesPreview'
import { CLSPreview } from './CLSPreview'
import { DatabaseConnectionsPreview } from './DatabaseConnectionsPreview'
+import { ExplorerPreview } from './ExplorerPreview'
import { useFeaturePreviewContext, useFeaturePreviewModal } from './FeaturePreviewContext'
import { IntegrationsLayoutPreview } from './IntegrationsLayoutPreview'
import { JitDbAccessPreview } from './JitDbAccessPreview'
@@ -59,6 +60,7 @@ const FEATURE_PREVIEW_KEY_TO_CONTENT: {
[LOCAL_STORAGE_KEYS.UI_PREVIEW_SQL_EDITOR_MANUAL_SAVE]: <SqlEditorManualSavePreview />,
[LOCAL_STORAGE_KEYS.UI_PREVIEW_MARKETPLACE]: <IntegrationsLayoutPreview />,
[LOCAL_STORAGE_KEYS.UI_PREVIEW_DATABASE_CONNECTIONS]: <DatabaseConnectionsPreview />,
+ [LOCAL_STORAGE_KEYS.UI_PREVIEW_EXPLORER]: <ExplorerPreview />,
}
export const FeaturePreviewModal = () => {
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts b/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
index 607337c5384..797164a05e7 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
+++ b/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
@@ -21,7 +21,7 @@ export type FeaturePreview = {
*/
isForced?: boolean
/** Optional category that the feature preview falls under, defaults to "Others" in the UI otherwise */
- category?: 'observability' | 'database'
+ category?: 'observability' | 'database' | 'editors'
/**
* Where to send the user after enabling, to try the feature out. Omit if the
* feature has no single destination (e.g. a global layout change).
@@ -35,11 +35,24 @@ export const useFeaturePreviews = (): FeaturePreview[] => {
const jitDbAccessEnabled = useFlag('jitDbAccess')
const isMarketplaceEnabled = useFlag('marketplaceIntegrations')
const isDatabaseConnectionsEnabled = useFlag('topForPostgres')
+ const isExplorerEnabled = useFlag('explorer')
const isSqlEditorManualSaveForced = useFlag('sqlEditorManualSaveForced')
return useMemo(() => {
const previews: FeaturePreview[] = [
+ {
+ key: LOCAL_STORAGE_KEYS.UI_PREVIEW_EXPLORER,
+ name: 'Explorer & Notebooks',
+ category: 'editors',
+ // [Joshen TODO] Update with proper URL once discussion is up
+ discussionsUrl: undefined,
+ enabled: isExplorerEnabled,
+ isNew: true,
+ isPlatformOnly: true,
+ isDefaultOptIn: true,
+ getRoute: (ref?: string) => `/project/${ref}/explorer`,
+ },
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS,
name: 'Updated Logs interface',
@@ -114,6 +127,7 @@ export const useFeaturePreviews = (): FeaturePreview[] => {
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_SQL_EDITOR_MANUAL_SAVE,
+ category: 'editors',
name: 'Disable snippet auto-saving',
discussionsUrl: undefined,
isNew: true,
@@ -146,5 +160,6 @@ export const useFeaturePreviews = (): FeaturePreview[] => {
jitDbAccessEnabled,
isMarketplaceEnabled,
isDatabaseConnectionsEnabled,
+ isExplorerEnabled,
])
}
diff --git a/apps/studio/components/interfaces/Sidebar.tsx b/apps/studio/components/interfaces/Sidebar.tsx
index 3a5ff661715..92ac2fb411f 100644
--- a/apps/studio/components/interfaces/Sidebar.tsx
+++ b/apps/studio/components/interfaces/Sidebar.tsx
@@ -33,8 +33,8 @@ import { Route } from '../ui/ui.types'
import {
generateProductRoutes,
generateSettingsRoutes,
- generateToolRoutes,
useGenerateOtherRoutes,
+ useGenerateToolRoutes,
} from '@/components/layouts/Navigation/NavigationBar/NavigationBar.utils'
import { ProjectIndexPageLink } from '@/data/prefetchers/project.$ref'
import { useHideSidebar } from '@/hooks/misc/useHideSidebar'
@@ -168,6 +168,7 @@ export function SideBarNavLink({
} & ComponentPropsWithoutRef<typeof SidebarMenuButton>) {
const router = useRouter()
const { state: sidebarState } = useSidebar()
+
const [sidebarBehaviour] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.SIDEBAR_BEHAVIOR,
DEFAULT_SIDEBAR_BEHAVIOR
@@ -223,6 +224,7 @@ export function SideBarNavLink({
onTrigger={() => router.push(route.link!)}
side="right"
delayDuration={shortcutPopoverDelay}
+ label={route.key === 'explorer' ? 'Go to Explorer' : undefined}
>
{button}
</Shortcut>
@@ -278,7 +280,7 @@ const ProjectLinks = () => {
const authOverviewPageEnabled = useFlag('authOverviewPage')
const workersEnabled = useFlag('workers')
- const toolRoutes = generateToolRoutes(ref, project)
+ const toolRoutes = useGenerateToolRoutes()
const productRoutes = generateProductRoutes(ref, project, {
auth: authEnabled,
edgeFunctions: edgeFunctionsEnabled,
diff --git a/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.test.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.test.tsx
index 197c4ac5f5b..e7744288a85 100644
--- a/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.test.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.test.tsx
@@ -1,10 +1,11 @@
-import { describe, expect, it } from 'vitest'
+import { renderHook } from '@testing-library/react'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
import {
generateOtherRoutes,
generateProductRoutes,
generateSettingsRoutes,
- generateToolRoutes,
+ useGenerateToolRoutes,
} from './NavigationBar.utils'
import type { Project } from '@/data/projects/project-detail-query'
@@ -16,25 +17,55 @@ const inactiveProject = { status: 'INACTIVE' } as Project
const keys = (routes: { key: string }[]) => routes.map((r) => r.key)
-describe('generateToolRoutes', () => {
+const mockUseParams = vi.fn()
+const mockUseSelectedProjectQuery = vi.fn()
+const mockUseIsExplorerEnabled = vi.fn()
+
+vi.mock('common', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('common')>()),
+ useParams: () => mockUseParams(),
+}))
+
+vi.mock('@/hooks/misc/useSelectedProject', () => ({
+ useSelectedProjectQuery: () => mockUseSelectedProjectQuery(),
+}))
+
+vi.mock('@/components/interfaces/App/FeaturePreview/FeaturePreviewContext', () => ({
+ useIsExplorerEnabled: () => mockUseIsExplorerEnabled(),
+ useUnifiedLogsPreview: () => ({ isEnabled: false }),
+}))
+
+describe('useGenerateToolRoutes', () => {
+ beforeEach(() => {
+ mockUseParams.mockReturnValue({ ref: REF })
+ mockUseSelectedProjectQuery.mockReturnValue({ data: activeProject })
+ mockUseIsExplorerEnabled.mockReturnValue(false)
+ })
+
it('always returns Table Editor and SQL Editor', () => {
- const routes = generateToolRoutes(REF, activeProject)
- expect(keys(routes)).toEqual(['editor', 'sql'])
+ const { result } = renderHook(() => useGenerateToolRoutes())
+ expect(keys(result.current)).toEqual(['editor', 'sql'])
})
it('marks routes as disabled when project is not active', () => {
- const routes = generateToolRoutes(REF, inactiveProject)
- expect(routes.every((r) => r.disabled)).toBe(true)
+ mockUseSelectedProjectQuery.mockReturnValue({ data: inactiveProject })
+
+ const { result } = renderHook(() => useGenerateToolRoutes())
+ expect(result.current.every((r) => r.disabled)).toBe(true)
})
it('points links to the building URL when project is building', () => {
- const routes = generateToolRoutes(REF, buildingProject)
- expect(routes.every((r) => r.link === `/project/${REF}`)).toBe(true)
+ mockUseSelectedProjectQuery.mockReturnValue({ data: buildingProject })
+
+ const { result } = renderHook(() => useGenerateToolRoutes())
+ expect(result.current.every((r) => r.link === `/project/${REF}`)).toBe(true)
})
it('returns links as false when ref is undefined', () => {
- const routes = generateToolRoutes(undefined, activeProject)
- expect(routes.every((r) => r.link === undefined)).toBe(true)
+ mockUseParams.mockReturnValue({ ref: undefined })
+
+ const { result } = renderHook(() => useGenerateToolRoutes())
+ expect(result.current.every((r) => r.link === undefined)).toBe(true)
})
})
diff --git a/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
index fe5a74346a0..f1e81a74fa9 100644
--- a/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
@@ -2,7 +2,10 @@ import { useParams } from 'common'
import { Auth, Database, EdgeFunctions, Realtime, SqlEditor, Storage, TableEditor } from 'icons'
import { Blocks, Box, Lightbulb, List, Settings, Telescope } from 'lucide-react'
-import { useUnifiedLogsPreview } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import {
+ useIsExplorerEnabled,
+ useUnifiedLogsPreview,
+} from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { ICON_SIZE, ICON_STROKE_WIDTH } from '@/components/interfaces/Sidebar'
import type { Route } from '@/components/ui/ui.types'
import { EditorIndexPageLink } from '@/data/prefetchers/project.$ref.editor'
@@ -45,8 +48,12 @@ function getRouteContext(ref?: string, project?: Project): RouteContext {
}
}
-export const generateToolRoutes = (ref?: string, project?: Project): Route[] => {
+export const useGenerateToolRoutes = (): Route[] => {
+ const { ref } = useParams()
+ const { data: project } = useSelectedProjectQuery()
+
const { isProjectActive, isProjectBuilding, buildingUrl } = getRouteContext(ref, project)
+ const isExplorerEnabled = useIsExplorerEnabled()
return [
{
@@ -58,14 +65,27 @@ export const generateToolRoutes = (ref?: string, project?: Project): Route[] =>
linkElement: <EditorIndexPageLink projectRef={ref} />,
shortcutId: SHORTCUT_IDS.NAV_TABLE_EDITOR,
},
- {
- key: 'sql',
- label: 'SQL Editor',
- disabled: !isProjectActive,
- icon: <SqlEditor size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
- link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/sql`),
- shortcutId: SHORTCUT_IDS.NAV_SQL_EDITOR,
- },
+ ...(isExplorerEnabled
+ ? [
+ {
+ key: 'explorer',
+ label: 'Explorer',
+ disabled: !isProjectActive,
+ icon: <SqlEditor size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
+ link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/explorer`),
+ shortcutId: SHORTCUT_IDS.NAV_SQL_EDITOR,
+ },
+ ]
+ : [
+ {
+ key: 'sql',
+ label: 'SQL Editor',
+ disabled: !isProjectActive,
+ icon: <SqlEditor size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
+ link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/sql`),
+ shortcutId: SHORTCUT_IDS.NAV_SQL_EDITOR,
+ },
+ ]),
]
}
diff --git a/apps/studio/components/layouts/Navigation/ProductMenuBar.tsx b/apps/studio/components/layouts/Navigation/ProductMenuBar.tsx
index 53db489bf35..8c7f6070212 100644
--- a/apps/studio/components/layouts/Navigation/ProductMenuBar.tsx
+++ b/apps/studio/components/layouts/Navigation/ProductMenuBar.tsx
@@ -1,7 +1,5 @@
-import { useFlag, useParams } from 'common'
-import Link from 'next/link'
import { PropsWithChildren, ReactNode } from 'react'
-import { Button, cn } from 'ui'
+import { cn } from 'ui'
interface ProductMenuBarProps {
title: string
@@ -15,11 +13,6 @@ export const ProductMenuBar = ({
children,
className,
}: PropsWithChildren<ProductMenuBarProps>) => {
- // [Joshen] Temporary entry point into explorer
- const { ref } = useParams()
- const isExplorerEnabled = useFlag('explorer')
- const showExplorerCTA = isExplorerEnabled && title === 'SQL Editor'
-
return (
<div
/**
@@ -36,11 +29,6 @@ export const ProductMenuBar = ({
<h4 className="text-lg">{title}</h4>
{titleBadge}
</div>
- {showExplorerCTA && (
- <Button asChild variant="default">
- <Link href={`/project/${ref}/explorer`}>Explorer</Link>
- </Button>
- )}
</div>
<div className={cn('grow overflow-y-auto', className)}>{children}</div>
</div>
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/MobileMenuContent/MobileMenuContent.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/MobileMenuContent/MobileMenuContent.tsx
index 89b81308333..30122bf5be7 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/MobileMenuContent/MobileMenuContent.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/MobileMenuContent/MobileMenuContent.tsx
@@ -16,8 +16,8 @@ import { ICON_SIZE, ICON_STROKE_WIDTH } from '@/components/interfaces/Sidebar'
import {
generateProductRoutes,
generateSettingsRoutes,
- generateToolRoutes,
useGenerateOtherRoutes,
+ useGenerateToolRoutes,
} from '@/components/layouts/Navigation/NavigationBar/NavigationBar.utils'
import type { Route } from '@/components/ui/ui.types'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
@@ -64,7 +64,7 @@ export function MobileMenuContent({
const authOverviewPageEnabled = useFlag('authOverviewPage')
const workersEnabled = useFlag('workers')
- const toolRoutes = useMemo(() => generateToolRoutes(ref, project), [ref, project])
+ const toolRoutes = useGenerateToolRoutes()
const productRoutes = useMemo(
() =>
generateProductRoutes(ref, project, {
diff --git a/apps/studio/public/img/previews/explorer-preview.png b/apps/studio/public/img/previews/explorer-preview.png
new file mode 100644
index 00000000000..227cd0909f5
Binary files /dev/null and b/apps/studio/public/img/previews/explorer-preview.png differ
diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.ts
index d159268e6df..cf3e8259db9 100644
--- a/packages/common/constants/local-storage.ts
+++ b/packages/common/constants/local-storage.ts
@@ -28,6 +28,7 @@ export const LOCAL_STORAGE_KEYS = {
UI_PREVIEW_SQL_EDITOR_MANUAL_SAVE: 'supabase-ui-sql-editor-manual-save',
UI_PREVIEW_MARKETPLACE: 'supabase-ui-marketplace',
UI_PREVIEW_DATABASE_CONNECTIONS: 'preview-database-connections',
+ UI_PREVIEW_EXPLORER: 'preview-explorer',
AI_ASSISTANT_MCP_OPT_IN: 'ai-assistant-mcp-opt-in',