Files
supabase/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
T
Danny WhiteandCursor e67cfc6a6d feat(studio): integrate temporary database access into Team and account surfaces
Move JIT admin UX from Database Settings to Org Team, add member discovery via My access and Connect, and auto-enable PAM on first grant behind the existing preview flag.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 20:27:30 -06:00

123 lines
4.3 KiB
TypeScript

import { LOCAL_STORAGE_KEYS, useFlag } from 'common'
import { useMemo } from 'react'
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
/**
* 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?: (ctx?: { ref?: string; slug?: string }) => string | undefined
}
export const useFeaturePreviews = (): FeaturePreview[] => {
const isUnifiedLogsPreviewAvailable = useFlag('unifiedLogs')
const pgDeltaDiffEnabled = useFlag('pgdeltaDiff')
const platformWebhooksEnabled = useFlag('platformWebhooks')
const jitDbAccessEnabled = useFlag('jitDbAccess')
const isMarketplaceEnabled = useFlag('marketplaceIntegrations')
return useMemo(
() =>
[
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_RLS_TESTER,
name: 'RLS Tester',
discussionsUrl: 'https://github.com/orgs/supabase/discussions/45233',
enabled: true,
isNew: true,
isPlatformOnly: false,
isDefaultOptIn: false,
getRoute: ({ ref } = {}) => (ref ? `/project/${ref}/auth/policies` : undefined),
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS,
name: 'Updated Logs interface',
discussionsUrl: 'https://github.com/orgs/supabase/discussions/37234',
enabled: isUnifiedLogsPreviewAvailable,
isNew: true,
isPlatformOnly: true,
isDefaultOptIn: false,
getRoute: ({ ref } = {}) => (ref ? `/project/${ref}/logs` : undefined),
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_ADVISOR_RULES,
name: 'Disable Advisor rules',
discussionsUrl: undefined,
enabled: true,
isNew: false,
isPlatformOnly: true,
isDefaultOptIn: false,
getRoute: ({ ref } = {}) => (ref ? `/project/${ref}/advisors/rules/security` : undefined),
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_PG_DELTA_DIFF,
name: 'PG Delta Diff',
discussionsUrl: undefined,
isNew: false,
isPlatformOnly: true,
isDefaultOptIn: true,
enabled: pgDeltaDiffEnabled,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_PLATFORM_WEBHOOKS,
name: 'Platform webhooks',
discussionsUrl: undefined,
isNew: true,
isPlatformOnly: true,
isDefaultOptIn: false,
enabled: platformWebhooksEnabled,
getRoute: ({ ref } = {}) => (ref ? `/project/${ref}/settings/webhooks` : undefined),
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_JIT_DB_ACCESS,
name: 'Temporary access',
discussionsUrl: undefined,
isNew: true,
isPlatformOnly: true,
isDefaultOptIn: false,
enabled: jitDbAccessEnabled,
getRoute: ({ slug } = {}) => (slug ? `/org/${slug}/team` : undefined),
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS,
name: 'Column-level privileges',
discussionsUrl: 'https://github.com/orgs/supabase/discussions/20295',
enabled: true,
isNew: false,
isPlatformOnly: false,
isDefaultOptIn: false,
getRoute: ({ ref } = {}) =>
ref ? `/project/${ref}/database/column-privileges` : undefined,
},
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_MARKETPLACE,
name: 'Integrations layout',
discussionsUrl: undefined,
enabled: isMarketplaceEnabled,
isNew: true,
isPlatformOnly: true,
isDefaultOptIn: false,
getRoute: ({ ref } = {}) => (ref ? `/project/${ref}/integrations` : undefined),
},
].sort((a, b) => Number(b.isNew) - Number(a.isNew)),
[
isUnifiedLogsPreviewAvailable,
pgDeltaDiffEnabled,
platformWebhooksEnabled,
jitDbAccessEnabled,
isMarketplaceEnabled,
]
)
}