mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
## Summary
The `homeNew` PostHog experiment has concluded. This PR graduates it by
making the new homepage (`ProjectHome`, formerly `HomeV2`) the permanent
default for all users, and removes all dead code from the old
experiment.
## Changes
- Remove `homeNew` PostHog feature flag checks and `home_new` experiment
exposure tracking from 3 files
- Rename `HomeNew/` → `ProjectHome/` directory and `HomeV2` →
`ProjectHome` export
- Delete old `Home/Home.tsx` component (shared components like
`ProjectList/` are kept — still used by org pages)
- Delete `pages/project/[ref]/building.tsx` and add a server-side
redirect from `/project/:ref/building` → `/project/:ref` to prevent 404s
during rollout (old cached JS bundles may still route to `/building`)
- Simplify `ContentWrapper` building-state logic in `ProjectLayout` —
always redirect building projects to home, always suppress building
interstitial on home page
- Always route to `/project/{ref}` after project creation (remove
`/building` path)
- Update all Observability imports from `HomeNew` → `ProjectHome`
## Self-hosted behavior change
Self-hosted Studio previously showed the old `Home` component (client
libraries + example projects) since PostHog flags don't load. This PR
changes self-hosted to show `ProjectHome` (TopSection with service
status + instance diagram, advisor, custom reports). All sections query
backend APIs that exist on self-hosted. E2E tests pass against the
self-hosted build.
## Testing
- [x] `pnpm turbo run build --filter=studio` passes
- [x] No remaining references to `homeNew`, `home_new`, or `HomeNew` in
codebase
- [x] No broken imports to deleted files
- [x] Self-hosted E2E tests pass (145 passed, 1 flaky, 4 skipped)
- [x] `/building` redirect added to both platform and self-hosted config
blocks
**Quick test:**
1. Navigate to any project homepage — should render the ProjectHome
component
2. Create a new project — should redirect to `/project/{ref}` (not
`/building`)
3. Visit a project in `COMING_UP` state on a non-home route — should
redirect to home
4. Visit `/project/{ref}/building` directly — should 302 redirect to
`/project/{ref}`
## Linear
- fixes GROWTH-671
152 lines
5.0 KiB
TypeScript
152 lines
5.0 KiB
TypeScript
import { keepPreviousData } from '@tanstack/react-query'
|
|
import { useDebounce, useIntersectionObserver } from '@uidotdev/usehooks'
|
|
import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
|
|
import { useContentInfiniteQuery } from 'data/content/content-infinite-query'
|
|
import type { Content } from 'data/content/content-query'
|
|
import { SNIPPET_PAGE_LIMIT } from 'data/content/sql-folders-query'
|
|
import { Plus } from 'lucide-react'
|
|
import { ReactNode, useEffect, useMemo, useRef, useState } from 'react'
|
|
import { editorPanelState } from 'state/editor-panel-state'
|
|
import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
|
|
import {
|
|
Command_Shadcn_,
|
|
CommandGroup_Shadcn_,
|
|
CommandInput_Shadcn_,
|
|
CommandItem_Shadcn_,
|
|
CommandList_Shadcn_,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuTrigger,
|
|
ScrollArea,
|
|
} from 'ui'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
type SnippetDropdownProps = {
|
|
projectRef?: string
|
|
trigger: ReactNode
|
|
side?: 'top' | 'bottom' | 'left' | 'right'
|
|
align?: 'start' | 'center' | 'end'
|
|
className?: string
|
|
autoFocus?: boolean
|
|
onSelect: (snippet: { id: string; name: string }) => void
|
|
}
|
|
|
|
type SqlContentItem = Extract<Content, { type: 'sql' }>
|
|
|
|
export const SnippetDropdown = ({
|
|
projectRef,
|
|
trigger,
|
|
side = 'bottom',
|
|
align = 'end',
|
|
className,
|
|
autoFocus = false,
|
|
onSelect,
|
|
}: SnippetDropdownProps) => {
|
|
const { openSidebar } = useSidebarManagerSnapshot()
|
|
const scrollRootRef = useRef<HTMLDivElement | null>(null)
|
|
|
|
const [open, setOpen] = useState(false)
|
|
const [search, setSearch] = useState('')
|
|
const debouncedSearch = useDebounce(search, 500)
|
|
|
|
const {
|
|
data,
|
|
isPending: isLoading,
|
|
hasNextPage,
|
|
fetchNextPage,
|
|
isFetchingNextPage,
|
|
} = useContentInfiniteQuery(
|
|
{
|
|
projectRef,
|
|
type: 'sql',
|
|
limit: SNIPPET_PAGE_LIMIT,
|
|
name: search.length === 0 ? search : debouncedSearch,
|
|
},
|
|
{ placeholderData: keepPreviousData }
|
|
)
|
|
|
|
const snippets = useMemo(() => {
|
|
const items = data?.pages.flatMap((page) => page.content) ?? []
|
|
return items as SqlContentItem[]
|
|
}, [data?.pages])
|
|
|
|
const [sentinelRef, entry] = useIntersectionObserver({
|
|
root: scrollRootRef.current,
|
|
threshold: 0,
|
|
rootMargin: '0px',
|
|
})
|
|
|
|
useEffect(() => {
|
|
if (entry?.isIntersecting && hasNextPage && !isFetchingNextPage && !isLoading) {
|
|
fetchNextPage()
|
|
}
|
|
}, [entry?.isIntersecting, hasNextPage, isFetchingNextPage, isLoading, fetchNextPage])
|
|
|
|
return (
|
|
<DropdownMenu open={open} onOpenChange={setOpen}>
|
|
<DropdownMenuTrigger asChild>{trigger}</DropdownMenuTrigger>
|
|
<DropdownMenuContent
|
|
side={side}
|
|
align={align}
|
|
className={['w-80 p-0', className].filter(Boolean).join(' ')}
|
|
>
|
|
<Command_Shadcn_ shouldFilter={false}>
|
|
<CommandInput_Shadcn_
|
|
showResetIcon
|
|
autoFocus={autoFocus}
|
|
placeholder="Search snippets..."
|
|
value={search}
|
|
onValueChange={setSearch}
|
|
handleReset={() => setSearch('')}
|
|
/>
|
|
<CommandList_Shadcn_ ref={scrollRootRef}>
|
|
{isLoading ? (
|
|
<p className="text-xs text-center text-foreground-lighter py-3">Loading...</p>
|
|
) : search.length > 0 && snippets.length === 0 ? (
|
|
<p className="text-xs text-center text-foreground-lighter py-3">No snippets found</p>
|
|
) : (
|
|
<CommandGroup_Shadcn_>
|
|
<ScrollArea className={snippets.length > 7 ? 'h-[210px]' : ''}>
|
|
{snippets.map((snippet) => (
|
|
<CommandItem_Shadcn_
|
|
key={snippet.id}
|
|
value={snippet.id}
|
|
onSelect={() => onSelect({ id: snippet.id, name: snippet.name })}
|
|
>
|
|
{snippet.name}
|
|
</CommandItem_Shadcn_>
|
|
))}
|
|
<div ref={sentinelRef} className="h-1 -mt-1" />
|
|
{hasNextPage && (
|
|
<div className="px-2 py-1">
|
|
<ShimmeringLoader className="py-2" />
|
|
</div>
|
|
)}
|
|
</ScrollArea>
|
|
</CommandGroup_Shadcn_>
|
|
)}
|
|
|
|
<div className="h-px bg-border-overlay -mx-1" />
|
|
|
|
<CommandGroup_Shadcn_>
|
|
<CommandItem_Shadcn_
|
|
className="cursor-pointer w-full"
|
|
onSelect={() => {
|
|
setOpen(false)
|
|
editorPanelState.openAsNew()
|
|
openSidebar(SIDEBAR_KEYS.EDITOR_PANEL)
|
|
}}
|
|
>
|
|
<div className="w-full flex items-center gap-2">
|
|
<Plus size={14} strokeWidth={1.5} />
|
|
<p>Create snippet</p>
|
|
</div>
|
|
</CommandItem_Shadcn_>
|
|
</CommandGroup_Shadcn_>
|
|
</CommandList_Shadcn_>
|
|
</Command_Shadcn_>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|