diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx index 01ea2ef283f..073ae399e55 100644 --- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx +++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx @@ -46,4 +46,4 @@ export const FEATURE_PREVIEWS = [ isNew: false, isPlatformOnly: false, }, -] +] as const diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx index ceed37c0e4d..4fa0a7dcf67 100644 --- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx +++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx @@ -5,44 +5,7 @@ import { FeatureFlagContext, LOCAL_STORAGE_KEYS } from 'common' import { useFlag } from 'hooks/ui/useFlag' import { IS_PLATFORM } from 'lib/constants' import { EMPTY_OBJ } from 'lib/void' - -export const FEATURE_PREVIEWS = [ - { - key: LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR, - name: 'Directly edit database entities', - discussionsUrl: 'https://github.com/orgs/supabase/discussions/33690', - isNew: true, - isPlatformOnly: false, - }, - { - key: LOCAL_STORAGE_KEYS.UI_TABLE_EDITOR_TABS, - name: 'Table Editor Tabs', - discussionsUrl: 'https://github.com/orgs/supabase/discussions/35636', - isNew: true, - isPlatformOnly: false, - }, - { - key: LOCAL_STORAGE_KEYS.UI_SQL_EDITOR_TABS, - name: 'SQL Editor Tabs', - discussionsUrl: 'https://github.com/orgs/supabase/discussions/35636', - isNew: true, - isPlatformOnly: true, - }, - { - key: LOCAL_STORAGE_KEYS.UI_PREVIEW_API_SIDE_PANEL, - name: 'Project API documentation', - discussionsUrl: 'https://github.com/orgs/supabase/discussions/18038', - isNew: false, - isPlatformOnly: false, - }, - { - key: LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS, - name: 'Column-level privileges', - discussionsUrl: 'https://github.com/orgs/supabase/discussions/20295', - isNew: false, - isPlatformOnly: false, - }, -] +import { FEATURE_PREVIEWS } from './FeaturePreview.constants' type FeaturePreviewContextType = { flags: { [key: string]: boolean } diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx index 653d0a99221..59989e7fdb3 100644 --- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx +++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx @@ -1,6 +1,6 @@ import { ExternalLink, Eye, EyeOff, FlaskConical } from 'lucide-react' import Link from 'next/link' -import { useEffect } from 'react' +import { useEffect, useMemo } from 'react' import { LOCAL_STORAGE_KEYS, useParams } from 'common' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' @@ -9,22 +9,8 @@ import { IS_PLATFORM } from 'lib/constants' import { useAppStateSnapshot } from 'state/app-state' import { removeTabsByEditor } from 'state/tabs' import { Badge, Button, Modal, ScrollArea, cn } from 'ui' -import { APISidePanelPreview } from './APISidePanelPreview' -import { CLSPreview } from './CLSPreview' -import { FEATURE_PREVIEWS, useFeaturePreviewContext } from './FeaturePreviewContext' -import { InlineEditorPreview } from './InlineEditorPreview' -import { SqlEditorTabsPreview } from './SqlEditorTabs' -import { TableEditorTabsPreview } from './TableEditorTabs' - -const FEATURE_PREVIEW_KEY_TO_CONTENT: { - [key: string]: React.ReactNode -} = { - [LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR]: , - [LOCAL_STORAGE_KEYS.UI_TABLE_EDITOR_TABS]: , - [LOCAL_STORAGE_KEYS.UI_SQL_EDITOR_TABS]: , - [LOCAL_STORAGE_KEYS.UI_PREVIEW_API_SIDE_PANEL]: , - [LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS]: , -} +import { FEATURE_PREVIEWS } from './FeaturePreview.constants' +import { useFeaturePreviewContext } from './FeaturePreviewContext' const FeaturePreviewModal = () => { const { ref } = useParams() @@ -83,6 +69,11 @@ const FeaturePreviewModal = () => { } }, [snap.showFeaturePreviewModal]) + const featurePreviewContent = useMemo( + () => FEATURE_PREVIEWS.find((f) => f.key === selectedFeatureKey)?.content, + [selectedFeatureKey] + ) + return ( { - {FEATURE_PREVIEW_KEY_TO_CONTENT[selectedFeatureKey]} + {featurePreviewContent} ) : ( diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx index 8408082c045..3dd175b146d 100644 --- a/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx +++ b/apps/studio/components/interfaces/Integrations/Wrappers/OverviewTab.tsx @@ -18,8 +18,8 @@ import { WarningIcon, } from 'ui' import { IntegrationOverviewTab } from '../Integration/IntegrationOverviewTab' -import { INTEGRATIONS } from '../Landing/Integrations.constants' import { CreateWrapperSheet } from './CreateWrapperSheet' +import { WRAPPERS } from './Wrappers.constants' import { WrapperTable } from './WrapperTable' export const WrapperOverviewTab = () => { @@ -34,13 +34,12 @@ export const WrapperOverviewTab = () => { connectionString: project?.connectionString, }) - const integration = INTEGRATIONS.find((i) => i.id === id) + const wrapperMeta = WRAPPERS.find((w) => w.name === id) - if (integration?.type !== 'wrapper') { + if (!wrapperMeta) { return

Unsupported integration type

} - const wrapperMeta = integration.meta const wrappersExtension = data?.find((ext) => ext.name === 'wrappers') const isWrappersExtensionInstalled = !!wrappersExtension?.installed_version const hasRequiredVersion = @@ -117,7 +116,7 @@ export const WrapperOverviewTab = () => { setisClosingCreateWrapper(true)}> { setCreateWrapperShown(false) setisClosingCreateWrapper(false) diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx index f84bf45a2d9..42b2eee1c13 100644 --- a/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx +++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrappersTab.tsx @@ -7,11 +7,11 @@ import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { FDW, useFDWsQuery } from 'data/fdw/fdws-query' import { useCheckPermissions } from 'hooks/misc/useCheckPermissions' import { Sheet, SheetContent } from 'ui' -import { INTEGRATIONS } from '../Landing/Integrations.constants' import { CreateWrapperSheet } from './CreateWrapperSheet' -import { WrapperTable } from './WrapperTable' import DeleteWrapperModal from './DeleteWrapperModal' +import { WRAPPERS } from './Wrappers.constants' import { wrapperMetaComparator } from './Wrappers.utils' +import { WrapperTable } from './WrapperTable' export const WrappersTab = () => { const { id } = useParams() @@ -27,13 +27,12 @@ export const WrappersTab = () => { }) const wrappers = data ?? [] - const integration = INTEGRATIONS.find((i) => i.id === id) + const wrapperMeta = WRAPPERS.find((w) => w.name === id) // this contains a collection of all wrapper instances for the wrapper type - const createdWrappers = - integration?.type === 'wrapper' - ? wrappers.filter((w) => wrapperMetaComparator(integration.meta, w)) - : [] + const createdWrappers = wrapperMeta + ? wrappers.filter((w) => wrapperMetaComparator(wrapperMeta, w)) + : [] const Container = useCallback( ({ ...props }: { children: ReactNode } & HTMLProps) => ( @@ -41,9 +40,9 @@ export const WrappersTab = () => { {props.children} setisClosingCreateWrapper(true)}> - {integration?.type === 'wrapper' && ( + {wrapperMeta && ( { setCreateWrapperShown(false) setisClosingCreateWrapper(false) @@ -56,10 +55,10 @@ export const WrappersTab = () => { ), - [createWrapperShown, integration, isClosingCreateWrapper] + [createWrapperShown, wrapperMeta, isClosingCreateWrapper] ) - if (!integration || integration.type !== 'wrapper') { + if (!wrapperMeta) { return
Missing integration.
} @@ -69,7 +68,7 @@ export const WrappersTab = () => {

- No {integration.meta.label} wrappers have been installed + No {wrapperMeta.label} wrappers have been installed