Files
supabase/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
Joshen Lim db0e6b761b Joshenlim/fe 4304 bring database connections out of feature preview (#50107)
## Context

As per PR title - we're bringing Database Connections out of feature
preview and it'll live on the dashboard by default 🙂
Also deprecating the existing Ongoing queries panel which Database
Connections now supercedes.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Database Connections is now available without feature-preview
activation.
* The SQL editor’s “View running queries” option now links directly to
Database Connections.

* **Bug Fixes**
* Query cancellation and session termination now refresh database
activity data.

* **Removed**
* Removed the in-editor ongoing queries panel and its termination
controls.
* Removed the Database Connections promotional banner, preview
messaging, settings, and related telemetry.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-08 17:26:24 +08:00

163 lines
5.6 KiB
TypeScript

import { LOCAL_STORAGE_KEYS, useFlag } from 'common'
import { useMemo } from 'react'
import { type BannerId } from '@/components/ui/BannerStack/BannerStackProvider'
export type FeaturePreview = {
key: string
name: string
discussionsUrl?: string
isNew: boolean
/** If feature flag is only relevant for the hosted platform */
isPlatformOnly: boolean
/** If feature flag should be enabled by default for users, if not yet toggled before */
isDefaultOptIn: boolean
/** Visibility in the feature preview modal (For feature flagging a feature preview) */
enabled: boolean
/**
* Forces the preview on for this user, whatever they previously chose — for a
* preview that has become the default behavior. Overrides both `isDefaultOptIn`
* and a stored opt-out, and takes away the ability to turn the preview back off.
*/
isForced?: boolean
/** Optional category that the feature preview falls under, defaults to "Others" in the UI otherwise */
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).
*/
getRoute?: (ref?: string) => string
bannerId?: BannerId
}
export const useFeaturePreviews = (): FeaturePreview[] => {
const isPlatformWebhooksEnabled = useFlag('platformWebhooks')
const jitDbAccessEnabled = useFlag('jitDbAccess')
const isMarketplaceEnabled = useFlag('marketplaceIntegrations')
const isExplorerEnabled = useFlag('explorer')
const isStorageVersioningEnabled = useFlag('storageVersioningPrivateAlpha')
const isSqlEditorManualSaveForced = useFlag('sqlEditorManualSaveForced')
return useMemo(() => {
const previews: FeaturePreview[] = [
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_EXPLORER,
name: 'Explorer & Notebooks',
category: 'editors',
discussionsUrl: 'https://github.com/orgs/supabase/discussions/49916',
enabled: isExplorerEnabled,
isNew: true,
isPlatformOnly: true,
isDefaultOptIn: false,
getRoute: (ref?: string) => `/project/${ref}/explorer`,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS,
name: 'Updated Logs interface',
category: 'observability',
discussionsUrl: 'https://github.com/orgs/supabase/discussions/37234',
enabled: true,
isNew: true,
isPlatformOnly: true,
isDefaultOptIn: true,
getRoute: (ref?: string) => `/project/${ref}/logs`,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_ADVISOR_RULES,
name: 'Disable Advisor rules',
discussionsUrl: undefined,
enabled: true,
isNew: false,
isPlatformOnly: true,
isDefaultOptIn: false,
getRoute: (ref?: string) => `/project/${ref}/advisors/rules/security`,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_PG_DELTA_DIFF,
name: 'PG Delta Diff',
discussionsUrl: undefined,
isNew: false,
isPlatformOnly: true,
isDefaultOptIn: true,
enabled: true,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_PLATFORM_WEBHOOKS,
name: 'Platform webhooks',
discussionsUrl: undefined,
isNew: false,
isPlatformOnly: true,
isDefaultOptIn: false,
enabled: isPlatformWebhooksEnabled,
getRoute: (ref?: string) => `/project/${ref}/settings/webhooks`,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_JIT_DB_ACCESS,
name: 'Temporary database access',
category: 'database',
discussionsUrl: undefined,
isNew: false,
isPlatformOnly: true,
isDefaultOptIn: false,
enabled: jitDbAccessEnabled,
getRoute: (ref?: string) => `/project/${ref}/database/settings`,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS,
name: 'Column-level privileges',
category: 'database',
discussionsUrl: 'https://github.com/orgs/supabase/discussions/20295',
enabled: true,
isNew: false,
isPlatformOnly: false,
isDefaultOptIn: false,
getRoute: (ref?: string) => `/project/${ref}/database/column-privileges`,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_MARKETPLACE,
name: 'One-Click Integrations',
discussionsUrl: undefined,
enabled: isMarketplaceEnabled,
isNew: true,
isPlatformOnly: false,
isDefaultOptIn: true,
getRoute: (ref?: string) => `/project/${ref}/integrations`,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_SQL_EDITOR_MANUAL_SAVE,
category: 'editors',
name: 'Disable snippet auto-saving',
discussionsUrl: undefined,
isNew: true,
isPlatformOnly: true,
isDefaultOptIn: false,
enabled: true,
// Manual saving is becoming the default for the SQL Editor. The preview
// stays listed so users who lose their local storage can opt back in
// before the rollout reaches them.
isForced: isSqlEditorManualSaveForced,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_STORAGE_VERSIONING,
name: 'Storage versioning',
discussionsUrl: undefined,
isNew: true,
isPlatformOnly: true,
isDefaultOptIn: true,
enabled: isStorageVersioningEnabled,
getRoute: (ref?: string) => `/project/${ref}/storage/files`,
},
]
return previews.sort((a, b) => Number(b.isNew) - Number(a.isNew))
}, [
isSqlEditorManualSaveForced,
isPlatformWebhooksEnabled,
jitDbAccessEnabled,
isMarketplaceEnabled,
isExplorerEnabled,
isStorageVersioningEnabled,
])
}