The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Set up to default opt in tabs interface (#35549)
Joshen Lim2066e1c652d0
diff --git a/apps/studio/components/interfaces/App/AppBannerWrapper.tsx b/apps/studio/components/interfaces/App/AppBannerWrapper.tsxindex 40252ee3e7d..d661e01a25c 100644--- a/apps/studio/components/interfaces/App/AppBannerWrapper.tsx+++ b/apps/studio/components/interfaces/App/AppBannerWrapper.tsx@@ -4,12 +4,9 @@ import { ClockSkewBanner } from 'components/layouts/AppLayout/ClockSkewBanner'import IncidentBanner from 'components/layouts/AppLayout/IncidentBanner'import { NoticeBanner } from 'components/layouts/AppLayout/NoticeBanner'import { useFlag } from 'hooks/ui/useFlag'-import { useProfile } from 'lib/profile'import { OrganizationResourceBanner } from '../Organization/HeaderBanner'const AppBannerWrapper = ({ children }: PropsWithChildren<{}>) => {- const { profile } = useProfile()-const ongoingIncident = useFlag('ongoingIncident')const showNoticeBanner = useFlag('showNoticeBanner')const clockSkewBanner = useFlag('clockSkewBanner')diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsxindex 9a5ef8e64fe..28bdcbfaafe 100644--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx@@ -2,6 +2,7 @@ import { noop } from 'lodash'import { PropsWithChildren, createContext, useContext, useEffect, useState } from 'react'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'import { APISidePanelPreview } from './APISidePanelPreview'@@ -23,6 +24,7 @@ export const FEATURE_PREVIEWS = [key: LOCAL_STORAGE_KEYS.UI_TABLE_EDITOR_TABS,name: 'Table Editor Tabs',content: <TableEditorTabsPreview />,+ discussionsUrl: 'https://github.com/orgs/supabase/discussions/35636',isNew: true,isPlatformOnly: false,},@@ -30,6 +32,7 @@ export const FEATURE_PREVIEWS = [key: LOCAL_STORAGE_KEYS.UI_SQL_EDITOR_TABS,name: 'SQL Editor Tabs',content: <SqlEditorTabsPreview />,+ discussionsUrl: 'https://github.com/orgs/supabase/discussions/35636',isNew: true,isPlatformOnly: true,},@@ -65,10 +68,15 @@ export const useFeaturePreviewContext = () => useContext(FeaturePreviewContext)export const FeaturePreviewContextProvider = ({ children }: PropsWithChildren<{}>) => {const { hasLoaded } = useContext(FeatureFlagContext)+ const enableTabsInterface = useFlag('tabsInterface')// [Joshen] Similar logic to feature flagging previews, we can use flags to default opt in previewsconst isDefaultOptIn = (feature: (typeof FEATURE_PREVIEWS)[number]) => {switch (feature.key) {+ case LOCAL_STORAGE_KEYS.UI_SQL_EDITOR_TABS:+ return enableTabsInterface+ case LOCAL_STORAGE_KEYS.UI_TABLE_EDITOR_TABS:+ return enableTabsInterfacedefault:return false}diff --git a/apps/studio/components/interfaces/App/FeaturePreview/TableEditorTabs.tsx b/apps/studio/components/interfaces/App/FeaturePreview/TableEditorTabs.tsxindex f16de5e442f..1a83d1e70dd 100644--- a/apps/studio/components/interfaces/App/FeaturePreview/TableEditorTabs.tsx+++ b/apps/studio/components/interfaces/App/FeaturePreview/TableEditorTabs.tsx@@ -1,6 +1,26 @@-import { BASE_PATH } from 'lib/constants'+import { ExternalLink, X } from 'lucide-react'import Image from 'next/image'+import { LOCAL_STORAGE_KEYS } from 'common'+import { useEditorType } from 'components/layouts/editors/EditorsLayout.hooks'+import { ButtonTooltip } from 'components/ui/ButtonTooltip'+import { InlineLinkClassName } from 'components/ui/InlineLink'+import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'+import { BASE_PATH } from 'lib/constants'+import { useAppStateSnapshot } from 'state/app-state'+import {+ Alert_Shadcn_,+ AlertDescription_Shadcn_,+ AlertTitle_Shadcn_,+ Badge,+ Button,+ cn,+ HoverCard,+ HoverCardContent_Shadcn_,+ HoverCardTrigger_Shadcn_,+} from 'ui'+import { useIsSQLEditorTabsEnabled, useIsTableEditorTabsEnabled } from './FeaturePreviewContext'+export const TableEditorTabsPreview = () => {return (<div className="space-y-2">@@ -26,3 +46,147 @@ export const TableEditorTabsPreview = () => {</div>)}++export const TabsUpdateCallout = () => {+ const editor = useEditorType()+ const appSnap = useAppStateSnapshot()++ const isTableEditorTabsEnabled = useIsTableEditorTabsEnabled()+ const isSQLEditorTabsEnabled = useIsSQLEditorTabsEnabled()+ const isTabsEnabled = isTableEditorTabsEnabled || isSQLEditorTabsEnabled++ const [tableEditorTabsPreviewState] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.UI_TABLE_EDITOR_TABS,+ ''+ )+ const [sqlEditorTabsPreviewState] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.UI_SQL_EDITOR_TABS,+ ''+ )++ const [tabsInterfaceAcknowledge, setTabsInterfaceAcknowledge] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.TABS_INTERFACE_ACKNOWLEDGED,+ false+ )+ const isDefaultOptedInTabs =+ isTabsEnabled && tableEditorTabsPreviewState === '' && sqlEditorTabsPreviewState === ''++ if (!isDefaultOptedInTabs || tabsInterfaceAcknowledge) return null++ return (+ <Alert_Shadcn_ className="mb-4 relative">+ <AlertTitle_Shadcn_>+ <Badge variant="brand" className="mr-2">+ NEW+ </Badge>+ Tabs Interface for Editors+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ The Table and SQL Editors now feature tabs for improved navigation and organization! Check+ out our{' '}+ <span+ className={cn(InlineLinkClassName, 'cursor-pointer')}+ onClick={() => {+ appSnap.setSelectedFeaturePreview(+ editor === 'table'+ ? LOCAL_STORAGE_KEYS.UI_TABLE_EDITOR_TABS+ : LOCAL_STORAGE_KEYS.UI_SQL_EDITOR_TABS+ )+ appSnap.setShowFeaturePreviewModal(true)+ }}+ >+ feature previews+ </span>{' '}+ for more information.+ </AlertDescription_Shadcn_>+ <AlertDescription_Shadcn_ className="mt-4 flex items-center gap-x-2">+ <Button asChild type="default" icon={<ExternalLink />}>+ <a+ target="_blank"+ rel="noreferrer noopener"+ href="https://github.com/orgs/supabase/discussions/35636"+ >+ View announcement+ </a>+ </Button>+ </AlertDescription_Shadcn_>+ <ButtonTooltip+ type="text"+ icon={<X />}+ className="absolute top-2 right-2 px-1"+ onClick={() => setTabsInterfaceAcknowledge(true)}+ tooltip={{ content: { side: 'bottom', text: 'Dismiss' } }}+ />+ </Alert_Shadcn_>+ )+}++export const TabsUpdateTooltip = () => {+ const editor = useEditorType()+ const appSnap = useAppStateSnapshot()++ const isTableEditorTabsEnabled = useIsTableEditorTabsEnabled()+ const isSQLEditorTabsEnabled = useIsSQLEditorTabsEnabled()+ const isTabsEnabled = isTableEditorTabsEnabled || isSQLEditorTabsEnabled++ const [tableEditorTabsPreviewState] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.UI_TABLE_EDITOR_TABS,+ ''+ )+ const [sqlEditorTabsPreviewState] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.UI_SQL_EDITOR_TABS,+ ''+ )+ const [tabsInterfaceAcknowledge, setTabsInterfaceAcknowledge] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.TABS_INTERFACE_ACKNOWLEDGED,+ false+ )++ const isDefaultOptedInTabs =+ isTabsEnabled && tableEditorTabsPreviewState === '' && sqlEditorTabsPreviewState === ''++ if (!isDefaultOptedInTabs || tabsInterfaceAcknowledge) return null++ return (+ <HoverCard openDelay={150}>+ <HoverCardTrigger_Shadcn_ asChild>+ <div+ className={cn(+ 'flex items-center justify-center px-2 h-10 shrink-0',+ 'border-b border-b-default gap-x-2'+ )}+ >+ <Badge variant="brand" className="rounded">+ <span>NEW</span>+ </Badge>+ </div>+ </HoverCardTrigger_Shadcn_>+ <HoverCardContent_Shadcn_ className="p-3 w-72">+ <div className="flex flex-col gap-y-1">+ <p className="text-sm">Tabs Interface for Editors</p>+ <p className="text-xs text-foreground-light">+ The Table and SQL Editors now feature tabs for improved navigation and organization!+ Check out our{' '}+ <span+ className={cn(InlineLinkClassName, 'cursor-pointer')}+ onClick={() => {+ appSnap.setSelectedFeaturePreview(+ editor === 'table'+ ? LOCAL_STORAGE_KEYS.UI_TABLE_EDITOR_TABS+ : LOCAL_STORAGE_KEYS.UI_SQL_EDITOR_TABS+ )+ appSnap.setShowFeaturePreviewModal(true)+ }}+ >+ feature previews+ </span>{' '}+ for more information.+ </p>+ </div>+ <Button type="default" className="mt-2" onClick={() => setTabsInterfaceAcknowledge(true)}>+ Dismiss+ </Button>+ </HoverCardContent_Shadcn_>+ </HoverCard>+ )+}diff --git a/apps/studio/components/layouts/ProjectLayout/PausedState/PauseDisabledState.tsx b/apps/studio/components/layouts/ProjectLayout/PausedState/PauseDisabledState.tsxindex 21aa5ffcbeb..2dad37213c7 100644--- a/apps/studio/components/layouts/ProjectLayout/PausedState/PauseDisabledState.tsx+++ b/apps/studio/components/layouts/ProjectLayout/PausedState/PauseDisabledState.tsx@@ -8,7 +8,6 @@ import { useBackupDownloadMutation } from 'data/database/backup-download-mutatioimport { useProjectPauseStatusQuery } from 'data/projects/project-pause-status-query'import { useStorageArchiveCreateMutation } from 'data/storage/storage-archive-create-mutation'import { useStorageArchiveQuery } from 'data/storage/storage-archive-query'-import { useFlag } from 'hooks/ui/useFlag'import { Database, Storage } from 'icons'import { PROJECT_STATUS } from 'lib/constants'import {@@ -18,6 +17,7 @@ import {Button,DropdownMenu,DropdownMenuContent,+ DropdownMenuItem,DropdownMenuTrigger,WarningIcon,} from 'ui'@@ -30,14 +30,10 @@ export const PauseDisabledState = () => {const [refetchInterval, setRefetchInterval] = useState<number | false>(false)const dbVersion = project?.dbVersion?.replace('supabase-postgres-', '')- const enforceNinetyDayUnpauseExpiry = useFlag('enforceNinetyDayUnpauseExpiry')- const allowStorageObjectsDownload = useFlag('enableNinetyDayStorageDownload')const { data: pauseStatus } = useProjectPauseStatusQuery({ ref },- {- enabled: project?.status === PROJECT_STATUS.INACTIVE && enforceNinetyDayUnpauseExpiry,- }+ { enabled: project?.status === PROJECT_STATUS.INACTIVE })const latestBackup = pauseStatus?.latest_downloadable_backup_id@@ -153,20 +149,10 @@ export const PauseDisabledState = () => {<Database size={16} />Database backup (PG: {dbVersion})</DropdownMenuItemTooltip>- <DropdownMenuItemTooltip- className="gap-x-2"- disabled={!allowStorageObjectsDownload}- onClick={() => onSelectDownloadStorageArchive()}- tooltip={{- content: {- side: 'right',- text: 'This feature is not available yet, please reach out to support for assistance',- },- }}- >+ <DropdownMenuItem className="gap-x-2" onClick={() => onSelectDownloadStorageArchive()}><Storage size={16} />Storage objects- </DropdownMenuItemTooltip>+ </DropdownMenuItem>{/* [Joshen] Once storage object download is supported, can just use the below component */}{/* <DropdownMenuItem className="gap-x-2" onClick={() => onSelectDownloadStorageArchive()}><Storage size={16} />diff --git a/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx b/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsxindex b7308c20d0e..c3f7c1bfe94 100644--- a/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx+++ b/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx@@ -56,7 +56,6 @@ export const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {const queryClient = useQueryClient()const { project } = useProjectContext()const selectedOrganization = useSelectedOrganization()- const enforceNinetyDayUnpauseExpiry = useFlag('enforceNinetyDayUnpauseExpiry')const showPostgresVersionSelector = useFlag('showPostgresVersionSelector')const enableProBenefitWording = usePHFlag('proBenefitWording')@@ -69,12 +68,7 @@ export const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {isError,isSuccess,isLoading,- } = useProjectPauseStatusQuery(- { ref },- {- enabled: project?.status === PROJECT_STATUS.INACTIVE && enforceNinetyDayUnpauseExpiry,- }- )+ } = useProjectPauseStatusQuery({ ref }, { enabled: project?.status === PROJECT_STATUS.INACTIVE })const finalDaysRemainingBeforeRestoreDisabled =pauseStatus?.remaining_days_till_restore_disabled ??@@ -82,7 +76,7 @@ export const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {0const isFreePlan = selectedOrganization?.plan?.id === 'free'- const isRestoreDisabled = enforceNinetyDayUnpauseExpiry && isSuccess && !pauseStatus.can_restore+ const isRestoreDisabled = isSuccess && !pauseStatus.can_restoreconst { data: membersExceededLimit } = useFreeProjectLimitCheckQuery({ slug: orgSlug },@@ -171,76 +165,64 @@ export const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {</p></div>- {enforceNinetyDayUnpauseExpiry && (+ {isLoading && <GenericSkeletonLoader />}+ {isError && (+ <AlertError error={pauseStatusError} subject="Failed to retrieve pause status" />+ )}+ {isSuccess && (<>- {isLoading && <GenericSkeletonLoader />}- {isError && (- <AlertError- error={pauseStatusError}- subject="Failed to retrieve pause status"- />- )}- {isSuccess && (+ {isRestoreDisabled ? (+ <PauseDisabledState />+ ) : isFreePlan ? (<>- {isRestoreDisabled ? (- <PauseDisabledState />- ) : isFreePlan ? (- <>- <p className="text-sm text-foreground-light text-center">- {enableProBenefitWording === 'variant-a'- ? 'Upgrade to Pro plan to prevent future pauses and use Pro features like branching, compute upgrades, and daily backups.'- : 'To prevent future pauses, consider upgrading to Pro.'}- </p>- <Alert_Shadcn_>- <AlertTitle_Shadcn_>- Project can be restored through the dashboard within the next{' '}- {finalDaysRemainingBeforeRestoreDisabled} day- {finalDaysRemainingBeforeRestoreDisabled > 1 ? 's' : ''}- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- Free projects cannot be restored through the dashboard if they are- paused for more than{' '}- <span className="text-foreground">- {pauseStatus?.max_days_till_restore_disabled} days- </span>- . The latest that your project can be restored is by{' '}- <span className="text-foreground">- {dayjs()- .utc()- .add(- pauseStatus.remaining_days_till_restore_disabled ?? 0,- 'day'- )- .format('DD MMM YYYY')}- </span>- . However, your database backup and Storage objects will still be- available for download thereafter.- </AlertDescription_Shadcn_>- <AlertDescription_Shadcn_ className="mt-3">- <Button asChild type="default" icon={<ExternalLink />}>- <a- target="_blank"- rel="noreferrer"- href="https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#time-limits"- >- More information- </a>- </Button>- </AlertDescription_Shadcn_>- </Alert_Shadcn_>- </>- ) : (- <RestorePaidPlanProjectNotice />- )}+ <p className="text-sm text-foreground-light text-center">+ {enableProBenefitWording === 'variant-a'+ ? 'Upgrade to Pro plan to prevent future pauses and use Pro features like branching, compute upgrades, and daily backups.'+ : 'To prevent future pauses, consider upgrading to Pro.'}+ </p>+ <Alert_Shadcn_>+ <AlertTitle_Shadcn_>+ Project can be restored through the dashboard within the next{' '}+ {finalDaysRemainingBeforeRestoreDisabled} day+ {finalDaysRemainingBeforeRestoreDisabled > 1 ? 's' : ''}+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ Free projects cannot be restored through the dashboard if they are+ paused for more than{' '}+ <span className="text-foreground">+ {pauseStatus?.max_days_till_restore_disabled} days+ </span>+ . The latest that your project can be restored is by{' '}+ <span className="text-foreground">+ {dayjs()+ .utc()+ .add(pauseStatus.remaining_days_till_restore_disabled ?? 0, 'day')+ .format('DD MMM YYYY')}+ </span>+ . However, your database backup and Storage objects will still be+ available for download thereafter.+ </AlertDescription_Shadcn_>+ <AlertDescription_Shadcn_ className="mt-3">+ <Button asChild type="default" icon={<ExternalLink />}>+ <a+ target="_blank"+ rel="noreferrer"+ href="https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects#time-limits"+ >+ More information+ </a>+ </Button>+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_></>+ ) : (+ <RestorePaidPlanProjectNotice />)}</>)}-- {!enforceNinetyDayUnpauseExpiry && !isFreePlan && <RestorePaidPlanProjectNotice />}</div>- {(!enforceNinetyDayUnpauseExpiry || (isSuccess && !isRestoreDisabled)) && (+ {isSuccess && !isRestoreDisabled && (<div className="flex items-center justify-center gap-4"><ButtonTooltipsize="tiny"diff --git a/apps/studio/components/layouts/Tabs/NewTab.tsx b/apps/studio/components/layouts/Tabs/NewTab.tsxindex 25718d60ba1..3617b770a0d 100644--- a/apps/studio/components/layouts/Tabs/NewTab.tsx+++ b/apps/studio/components/layouts/Tabs/NewTab.tsx@@ -6,6 +6,7 @@ import { useRouter } from 'next/router'import { toast } from 'sonner'import { useParams } from 'common'+import { TabsUpdateCallout } from 'components/interfaces/App/FeaturePreview/TableEditorTabs'import { SQL_TEMPLATES } from 'components/interfaces/SQLEditor/SQLEditor.queries'import { createSqlSnippetSkeletonV2 } from 'components/interfaces/SQLEditor/SQLEditor.utils'import { useSendEventMutation } from 'data/telemetry/send-event-mutation'@@ -34,14 +35,17 @@ export function NewTab() {const router = useRouter()const { ref } = useParams()const editor = useEditorType()- const snap = useTableEditorStateSnapshot()const { profile } = useProfile()+ const org = useSelectedOrganization()+ const { project } = useProjectContext()++ const snap = useTableEditorStateSnapshot()+ const snapV2 = useSqlEditorV2StateSnapshot()+const [templates] = partition(SQL_TEMPLATES, { type: 'template' })const [quickstarts] = partition(SQL_TEMPLATES, { type: 'quickstart' })+const { mutate: sendEvent } = useSendEventMutation()- const snapV2 = useSqlEditorV2StateSnapshot()- const { project } = useProjectContext()- const org = useSelectedOrganization()const canCreateSQLSnippet = useCheckPermissions(PermissionAction.CREATE, 'user_content', {resource: { type: 'sql', owner_id: profile?.id },@@ -112,6 +116,7 @@ export function NewTab() {return (<div className="bg-surface-100 h-full overflow-y-auto py-12"><div className="mx-auto max-w-2xl flex flex-col gap-10 px-10">+ <TabsUpdateCallout /><div className="grid grid-cols-2 gap-4">{actions.map((item, i) => (<ActionCard key={`action-card-${i}`} {...item} />diff --git a/apps/studio/components/layouts/Tabs/Tabs.tsx b/apps/studio/components/layouts/Tabs/Tabs.tsxindex 8c9c79b1e87..ef65b70fce2 100644--- a/apps/studio/components/layouts/Tabs/Tabs.tsx+++ b/apps/studio/components/layouts/Tabs/Tabs.tsx@@ -11,7 +11,9 @@ import { AnimatePresence, motion } from 'framer-motion'import { Plus, X } from 'lucide-react'import { useRouter } from 'next/router'-import { useParams } from 'common'+import { LOCAL_STORAGE_KEYS, useParams } from 'common'+import { TabsUpdateTooltip } from 'components/interfaces/App/FeaturePreview/TableEditorTabs'+import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'import { useAppStateSnapshot } from 'state/app-state'import {editorEntityTypes,@@ -42,6 +44,11 @@ export const EditorTabs = () => {}))+ const [tabsInterfaceAcknowledge, setTabsInterfaceAcknowledge] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.TABS_INTERFACE_ACKNOWLEDGED,+ false+ )+const openTabs = tabs.openTabs.map((id) => tabs.tabsMap[id]).filter((tab) => tab !== undefined) as Tab[]@@ -166,7 +173,10 @@ export const EditorTabs = () => {</AnimatePresence><div className="grow h-full border-b pr-6" /></TabsList_Shadcn_>++ <TabsUpdateTooltip /></Tabs_Shadcn_>+<DragOverlay dropAnimation={null}>{tabs.activeTab ? <TabPreview tab={tabs.activeTab} /> : null}</DragOverlay>diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.tsindex 8ccb89eeee2..93b23767dd8 100644--- a/packages/common/constants/local-storage.ts+++ b/packages/common/constants/local-storage.ts@@ -15,6 +15,7 @@ export const LOCAL_STORAGE_KEYS = {UI_SQL_EDITOR_TABS: 'supabase-ui-sql-editor-tabs',UI_NEW_LAYOUT_PREVIEW: 'supabase-ui-new-layout-preview',NEW_LAYOUT_NOTICE_ACKNOWLEDGED: 'new-layout-notice-acknowledge',+ TABS_INTERFACE_ACKNOWLEDGED: 'tabs-interface-acknowledge',DASHBOARD_HISTORY: (ref: string) => `dashboard-history-${ref}`,STORAGE_PREFERENCE: (ref: string) => `storage-explorer-${ref}`,