The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(self-hosted): update project home for self-hosted and cli (#46544)
Andrey A.0c8b71de6489
diff --git a/apps/studio/.github/eslint-rule-baselines.json b/apps/studio/.github/eslint-rule-baselines.jsonindex 5d73ab0d01b..8ce74e19536 100644--- a/apps/studio/.github/eslint-rule-baselines.json+++ b/apps/studio/.github/eslint-rule-baselines.json@@ -287,7 +287,6 @@"components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.utils.tsx": 3,"components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionTesterSheet.tsx": 1,"components/interfaces/Functions/FunctionsNav.tsx": 1,- "components/interfaces/Home/Home.tsx": 6,"components/interfaces/Home/ProjectList/ProjectList.tsx": 1,"components/interfaces/Home/ProjectUsage.tsx": 1,"components/interfaces/Home/ServiceStatus.tsx": 1,diff --git a/apps/studio/components/interfaces/Home/AdvisorWidget.tsx b/apps/studio/components/interfaces/Home/AdvisorWidget.tsxdeleted file mode 100644index 607359a290d..00000000000--- a/apps/studio/components/interfaces/Home/AdvisorWidget.tsx+++ /dev/null@@ -1,358 +0,0 @@-import { useParams } from 'common'-import { Activity, ExternalLink, Shield } from 'lucide-react'-import Link from 'next/link'-import { useCallback, useMemo, useState } from 'react'-import {- Card,- CardContent,- CardHeader,- CardTitle,- Table,- TableBody,- TableCell,- TableHead,- TableHeader,- TableRow,- Tabs_Shadcn_ as Tabs,- TabsContent_Shadcn_ as TabsContent,- TabsList_Shadcn_ as TabsList,- TabsTrigger_Shadcn_ as TabsTrigger,-} from 'ui'-import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'--import { useQueryPerformanceQuery } from '../QueryPerformance/useQueryPerformanceQuery'-import { LINTER_LEVELS } from '@/components/interfaces/Linter/Linter.constants'-import {- createLintSummaryPrompt,- EntityTypeIcon,-} from '@/components/interfaces/Linter/Linter.utils'-import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'-import { AiAssistantDropdown } from '@/components/ui/AiAssistantDropdown'-import { ButtonTooltip } from '@/components/ui/ButtonTooltip'-import { Lint, useProjectLintsQuery } from '@/data/lint/lint-query'-import { useTrack } from '@/lib/telemetry/track'-import { useAdvisorStateSnapshot } from '@/state/advisor-state'-import { useAiAssistantStateSnapshot } from '@/state/ai-assistant-state'-import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'--interface SlowQuery {- rolname: string- mean_time: number- calls: number- query: string-}--export const AdvisorWidget = () => {- const { ref: projectRef } = useParams()- const [selectedTab, setSelectedTab] = useState<'security' | 'performance'>('security')- const { data: lints, isPending: isLoadingLints } = useProjectLintsQuery({ projectRef })- const { data: slowestQueriesData, isLoading: isLoadingSlowestQueries } = useQueryPerformanceQuery(- { preset: 'slowestExecutionTime' }- )- const snap = useAiAssistantStateSnapshot()- const { openSidebar } = useSidebarManagerSnapshot()- const { setSelectedItem } = useAdvisorStateSnapshot()- const track = useTrack()-- const securityLints = useMemo(- () => (lints ?? []).filter((lint: Lint) => lint.categories.includes('SECURITY')),- [lints]- )- const performanceLints = useMemo(- () => (lints ?? []).filter((lint: Lint) => lint.categories.includes('PERFORMANCE')),- [lints]- )-- const securityErrorCount = securityLints.filter(- (lint: Lint) => lint.level === LINTER_LEVELS.ERROR- ).length- const securityWarningCount = securityLints.filter(- (lint: Lint) => lint.level === LINTER_LEVELS.WARN- ).length- const performanceErrorCount = performanceLints.filter(- (lint: Lint) => lint.level === LINTER_LEVELS.ERROR- ).length- const performanceWarningCount = performanceLints.filter(- (lint: Lint) => lint.level === LINTER_LEVELS.WARN- ).length-- const top5SlowestQueries = useMemo(- () => ((slowestQueriesData ?? []) as SlowQuery[]).slice(0, 5),- [slowestQueriesData]- )-- const handleLintClick = useCallback(- (lint: Lint) => {- setSelectedItem(lint.cache_key, 'lint')- openSidebar(SIDEBAR_KEYS.ADVISOR_PANEL)- },- [setSelectedItem, openSidebar]- )-- const totalIssues =- securityErrorCount + securityWarningCount + performanceErrorCount + performanceWarningCount- const hasErrors = securityErrorCount > 0 || performanceErrorCount > 0- const hasWarnings = securityWarningCount > 0 || performanceWarningCount > 0-- let titleContent: React.ReactNode-- if (totalIssues === 0) {- titleContent = <h2>No issues available</h2>- } else {- const issuesText = totalIssues === 1 ? 'issue' : 'issues'- const numberDisplay = totalIssues.toString()-- let attentionClassName = ''- if (hasErrors) {- attentionClassName = 'text-destructive'- } else if (hasWarnings) {- attentionClassName = 'text-warning'- }-- titleContent = (- <h2>- {numberDisplay} {issuesText} need- {totalIssues === 1 ? 's' : ''} <span className={attentionClassName}>attention</span>- </h2>- )- }-- const renderLintTabContent = (- title: string,- lints: Lint[],- errorCount: number,- warningCount: number,- isLoading: boolean- ) => {- const topIssues = lints- .filter((lint) => lint.level === LINTER_LEVELS.ERROR || lint.level === LINTER_LEVELS.WARN)- .sort((a, _b) => (a.level === LINTER_LEVELS.ERROR ? -1 : 1))-- return (- <div className="h-full">- {isLoading && (- <div className="flex flex-col p-4 gap-2">- <ShimmeringLoader />- <ShimmeringLoader className="w-3/4" />- <ShimmeringLoader className="w-1/2" />- </div>- )}- {!isLoading && (errorCount > 0 || warningCount > 0) && (- <ul>- {topIssues.map((lint) => {- const lintText = lint.detail ? lint.detail : lint.title- return (- <li- key={lint.cache_key}- className="text-sm w-full border-b my-0 last:border-b-0 group px-4 "- >- <div className="flex items-center justify-between w-full group">- <button- onClick={() => handleLintClick(lint)}- className="flex items-center gap-2 transition truncate flex-1 min-w-0 py-3 text-left"- >- <EntityTypeIcon type={lint.metadata?.type} />- <p className="flex-1 font-mono text-xs leading-6 text-xs text-foreground-light group-hover:text-foreground truncate">- {lintText.replace(/\\`/g, '`')}- </p>- </button>- <div- onClick={(e) => {- e.stopPropagation()- e.preventDefault()- }}- className="opacity-0 group-hover:opacity-100"- >- <AiAssistantDropdown- label="Ask Assistant"- iconOnly- tooltip="Help me fix this issue"- buildPrompt={() => createLintSummaryPrompt(lint)}- onOpenAssistant={() => {- openSidebar(SIDEBAR_KEYS.AI_ASSISTANT)- snap.newChat({- name: 'Summarize lint',- initialInput: createLintSummaryPrompt(lint),- })- track('advisor_assistant_button_clicked', {- origin: 'homepage',- advisorCategory: lint.categories[0],- advisorType: lint.name,- advisorLevel: lint.level,- })- }}- telemetrySource="advisor_widget"- type="text"- className="px-1 w-7"- />- </div>- </div>- </li>- )- })}- </ul>- )}- {!isLoading && errorCount === 0 && warningCount === 0 && (- <div className="flex-1 flex flex-col h-full items-center justify-center gap-2">- <Shield size={20} strokeWidth={1.5} className="text-foreground-muted" />- <p className="text-sm text-foreground-light">No {title.toLowerCase()} issues found</p>- </div>- )}- </div>- )- }-- return (- <div className="@container">- {isLoadingLints ? (- <ShimmeringLoader className="w-96 mb-6" />- ) : (- <div className="flex justify-between items-center mb-6">{titleContent}</div>- )}- <div className="grid grid-cols-1 @xl:grid-cols-2 gap-4">- <Card className="h-80">- <Tabs value={selectedTab} className="h-full flex flex-col">- <CardHeader className="h-10 py-0 pl-4 pr-2 flex flex-row items-center justify-between flex-0">- <TabsList className="flex justify-start rounded-none gap-x-4 border-b-0 mt-0! pt-0">- <TabsTrigger- value="security"- onClick={() => setSelectedTab('security')}- className="flex items-center gap-2 text-xs py-3 border-b font-mono uppercase"- >- Security{' '}- {securityErrorCount + securityWarningCount > 0 && (- <div className="rounded-sm bg-warning text-warning-100 px-1">- {securityErrorCount + securityWarningCount}- </div>- )}- </TabsTrigger>- <TabsTrigger- value="performance"- onClick={() => setSelectedTab('performance')}- className="flex items-center gap-2 text-xs py-3 border-b font-mono uppercase"- >- Performance{' '}- {performanceErrorCount + performanceWarningCount > 0 && (- <div className="rounded-sm bg-warning text-warning-100 px-1">- {performanceErrorCount + performanceWarningCount}- </div>- )}- </TabsTrigger>- </TabsList>- <ButtonTooltip- asChild- type="text"- className="mt-0! w-7"- icon={<ExternalLink />}- tooltip={{- content: {- side: 'bottom',- text: `Open ${selectedTab} Advisor`,- className: 'capitalize',- },- }}- >- <Link- href={`/project/${projectRef}/advisors/${selectedTab}`}- aria-label={`Open ${selectedTab} advisor`}- />- </ButtonTooltip>- </CardHeader>- <CardContent className="p-0! mt-0 flex-1 overflow-y-auto">- <TabsContent value="security" className="p-0 mt-0 h-full">- {renderLintTabContent(- 'Security',- securityLints,- securityErrorCount,- securityWarningCount,- isLoadingLints- )}- </TabsContent>- <TabsContent value="performance" className="p-0 mt-0 h-full">- {renderLintTabContent(- 'Performance',- performanceLints,- performanceErrorCount,- performanceWarningCount,- isLoadingLints- )}- </TabsContent>- </CardContent>- </Tabs>- </Card>-- <Card className="h-80 flex flex-col">- <CardHeader className="h-10 flex-row items-center justify-between py-0 pl-4 pr-2">- <CardTitle>Slow Queries</CardTitle>- <ButtonTooltip- asChild- type="text"- className="mt-0! w-7"- icon={<ExternalLink />}- tooltip={{- content: {- side: 'bottom',- text: `Open Query Performance Advisor`,- },- }}- >- <Link- href={`/project/${projectRef}/reports/query-performance`}- aria-label="Open Query Performance Advisor"- />- </ButtonTooltip>- </CardHeader>- <CardContent className="p-0! flex-1 overflow-y-auto">- {isLoadingSlowestQueries ? (- <div className="space-y-2 p-4">- <ShimmeringLoader />- <ShimmeringLoader className="w-3/4" />- <ShimmeringLoader className="w-1/2" />- <ShimmeringLoader className="w-3/4" />- <ShimmeringLoader className="w-1/2" />- </div>- ) : top5SlowestQueries.length === 0 ? (- <div className="flex-1 flex flex-col h-full items-center justify-center gap-2">- <Activity strokeWidth={1.5} size={20} className="text-foreground-muted" />- <p className="text-sm text-foreground-light">- No slow queries found in the selected period- </p>- </div>- ) : (- <Table className="text-xs font-mono max-w-full">- <TableHeader>- <TableRow>- <TableHead className="text-foreground-lighter truncate py-2 h-auto">- Query- </TableHead>- <TableHead className="text-foreground-lighter truncate py-2 h-auto">- Avg time- </TableHead>- <TableHead className="text-foreground-lighter truncate py-2 h-auto">- Calls- </TableHead>- </TableRow>- </TableHeader>- <TableBody>- {/* Added explicit types for map parameters */}- {top5SlowestQueries.map((query: SlowQuery, i: number) => (- <TableRow key={i} className="py-2">- <TableCell className="font-mono truncate max-w-xs">{query.query}</TableCell>-- <TableCell className="font-mono truncate max-w-xs">- {typeof query.mean_time === 'number'- ? `${(query.mean_time / 1000).toFixed(2)}s`- : 'N/A'}- </TableCell>- <TableCell className="font-mono truncate max-w-xs">{query.calls}</TableCell>- </TableRow>- ))}- </TableBody>- </Table>- )}- </CardContent>- </Card>- </div>- </div>- )-}diff --git a/apps/studio/components/interfaces/Home/Home.tsx b/apps/studio/components/interfaces/Home/Home.tsxdeleted file mode 100644index eabd814ca5e..00000000000--- a/apps/studio/components/interfaces/Home/Home.tsx+++ /dev/null@@ -1,286 +0,0 @@-import { useParams } from 'common'-import dayjs from 'dayjs'-import Link from 'next/link'-import { useEffect, useRef } from 'react'-import {- Badge,- cn,- Tabs_Shadcn_,- TabsContent_Shadcn_,- TabsList_Shadcn_,- TabsTrigger_Shadcn_,- Tooltip,- TooltipContent,- TooltipTrigger,-} from 'ui'-import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'--import { AdvisorWidget } from '@/components/interfaces/Home/AdvisorWidget'-import { ClientLibrary } from '@/components/interfaces/Home/ClientLibrary'-import { ExampleProject } from '@/components/interfaces/Home/ExampleProject'-import { EXAMPLE_PROJECTS } from '@/components/interfaces/Home/Home.constants'-import { NewProjectPanel } from '@/components/interfaces/Home/NewProjectPanel/NewProjectPanel'-import { ProjectUsageSection } from '@/components/interfaces/Home/ProjectUsageSection'-import { ServiceStatus } from '@/components/interfaces/Home/ServiceStatus'-import { ProjectPausedState } from '@/components/layouts/ProjectLayout/PausedState/ProjectPausedState'-import { ComputeBadgeWrapper } from '@/components/ui/ComputeBadgeWrapper'-import { InlineLink } from '@/components/ui/InlineLink'-import { ProjectUpgradeFailedBanner } from '@/components/ui/ProjectUpgradeFailedBanner'-import { useBranchesQuery } from '@/data/branches/branches-query'-import { useEdgeFunctionsQuery } from '@/data/edge-functions/edge-functions-query'-import { useProjectDetailQuery } from '@/data/projects/project-detail-query'-import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'-import { useTablesQuery } from '@/data/tables/tables-query'-import { useCustomContent } from '@/hooks/custom-content/useCustomContent'-import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'-import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'-import { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'-import { DOCS_URL, IS_PLATFORM, PROJECT_STATUS } from '@/lib/constants'-import { useAppStateSnapshot } from '@/state/app-state'--export const Home = () => {- const { data: project } = useSelectedProjectQuery()- const { data: organization } = useSelectedOrganizationQuery()- const { data: parentProject } = useProjectDetailQuery({ ref: project?.parent_project_ref })- const isOrioleDb = useIsOrioleDb()- const snap = useAppStateSnapshot()- const { ref, enableBranching } = useParams()-- const { projectHomepageExampleProjects, projectHomepageClientLibraries: clientLibraries } =- useCustomContent(['project_homepage:example_projects', 'project_homepage:client_libraries'])-- const {- projectHomepageShowInstanceSize: showInstanceSize,- projectHomepageShowExamples: showExamples,- } = useIsFeatureEnabled(['project_homepage:show_instance_size', 'project_homepage:show_examples'])-- const hasShownEnableBranchingModalRef = useRef(false)- const isPaused = project?.status === PROJECT_STATUS.INACTIVE- const isNewProject = dayjs(project?.inserted_at).isAfter(dayjs().subtract(2, 'day'))-- useEffect(() => {- if (enableBranching && !hasShownEnableBranchingModalRef.current) {- hasShownEnableBranchingModalRef.current = true- snap.setShowCreateBranchModal(true)- }- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [enableBranching])-- const { data: tablesData, isPending: isLoadingTables } = useTablesQuery({- projectRef: project?.ref,- connectionString: project?.connectionString,- schema: 'public',- })- const { data: functionsData, isPending: isLoadingFunctions } = useEdgeFunctionsQuery({- projectRef: project?.ref,- })- const { data: replicasData, isPending: isLoadingReplicas } = useReadReplicasQuery({- projectRef: project?.ref,- })-- const { data: branches } = useBranchesQuery({- projectRef: project?.parent_project_ref ?? project?.ref,- })-- const mainBranch = branches?.find((branch) => branch.is_default)- const currentBranch = branches?.find((branch) => branch.project_ref === project?.ref)- const isMainBranch = currentBranch?.name === mainBranch?.name- let projectName = 'Welcome to your project'-- if (currentBranch && !isMainBranch) {- projectName = currentBranch?.name- } else if (project?.name) {- projectName = project?.name- }-- const tablesCount = Math.max(0, tablesData?.length ?? 0)- const functionsCount = Math.max(0, functionsData?.length ?? 0)- // [Joshen] JFYI minus 1 as the replicas endpoint returns the primary DB minimally- const replicasCount = Math.max(0, (replicasData?.length ?? 1) - 1)-- if (isPaused) {- return (- <div className="w-full h-full flex items-center justify-center px-4">- <ProjectPausedState />- </div>- )- }-- return (- <div className="w-full px-4">- <div className={cn('py-16 ', !isPaused && 'border-b border-muted ')}>- <div className="mx-auto max-w-7xl flex flex-col gap-y-4">- <div className="flex flex-col md:flex-row md:items-center gap-6 justify-between w-full">- <div className="flex flex-col md:flex-row md:items-end gap-3 w-full">- <div>- {!isMainBranch && (- <Link- href={`/project/${parentProject?.ref}`}- className="text-sm text-foreground-light"- >- {parentProject?.name}- </Link>- )}- <h1 className="text-3xl">{projectName}</h1>- </div>- <div className="flex items-center gap-x-2 mb-1">- {isOrioleDb && (- <Tooltip>- <TooltipTrigger asChild>- <Badge variant="warning">OrioleDB</Badge>- </TooltipTrigger>- <TooltipContent side="bottom" align="start" className="max-w-80 text-center">- This project is using Postgres with OrioleDB which is currently in preview and- not suitable for production workloads. View our{' '}- <InlineLink href={`${DOCS_URL}/guides/database/orioledb`}>- documentation- </InlineLink>{' '}- for all limitations.- </TooltipContent>- </Tooltip>- )}- {showInstanceSize && (- <ComputeBadgeWrapper- projectRef={project?.ref}- slug={organization?.slug}- cloudProvider={project?.cloud_provider}- computeSize={project?.infra_compute_size}- />- )}- </div>- </div>- <div className="flex items-center">- {project?.status === PROJECT_STATUS.ACTIVE_HEALTHY && (- <div className="flex items-center gap-x-6">- <div className="flex flex-col gap-y-1">- <Link- href={`/project/${ref}/editor`}- className="transition text-foreground-light hover:text-foreground text-sm"- >- Tables- </Link>-- {isLoadingTables ? (- <ShimmeringLoader className="w-full h-[32px] w-6 p-0" />- ) : (- <p className="text-2xl tabular-nums">{tablesCount}</p>- )}- </div>-- <div className="flex flex-col gap-y-1">- <Link- href={`/project/${ref}/functions`}- className="transition text-foreground-light hover:text-foreground text-sm"- >- Functions- </Link>- {isLoadingFunctions ? (- <ShimmeringLoader className="w-full h-[32px] w-6 p-0" />- ) : (- <p className="text-2xl tabular-nums">{functionsCount}</p>- )}- </div>-- {IS_PLATFORM && (- <div className="flex flex-col gap-y-1">- <Link- href={`/project/${ref}/settings/infrastructure`}- className="transition text-foreground-light hover:text-foreground text-sm"- >- Replicas- </Link>- {isLoadingReplicas ? (- <ShimmeringLoader className="w-full h-[32px] w-6 p-0" />- ) : (- <p className="text-2xl tabular-nums">{replicasCount}</p>- )}- </div>- )}- </div>- )}- {IS_PLATFORM && project?.status === PROJECT_STATUS.ACTIVE_HEALTHY && (- <div className="ml-6 border-l flex items-center w-[145px] justify-end">- <ServiceStatus />- </div>- )}- </div>- </div>- <ProjectUpgradeFailedBanner />- </div>- </div>-- <>- <div className="py-16 border-b border-muted">- <div className="mx-auto max-w-7xl space-y-16 @container">- {IS_PLATFORM && project?.status !== PROJECT_STATUS.INACTIVE && (- <>{isNewProject ? <NewProjectPanel /> : <ProjectUsageSection />}</>- )}- {!isNewProject && project?.status !== PROJECT_STATUS.INACTIVE && <AdvisorWidget />}- </div>- </div>-- <div className="bg-surface-100/5 py-16">- <div className="mx-auto max-w-7xl space-y-16 @container">- {project?.status !== PROJECT_STATUS.INACTIVE && (- <>- <div className="space-y-8">- <h2 className="text-lg">Client libraries</h2>- <div className="grid grid-cols-2 gap-x-8 gap-y-8 md:gap-12 mb-12 md:grid-cols-3">- {clientLibraries!.map((library) => (- // [Alaister]: Looks like the useCustomContent has wonky types. I'll look at a fix later.- <ClientLibrary key={(library as any).language} {...(library as any)} />- ))}- </div>- </div>- {showExamples && (- <div className="flex flex-col gap-y-8">- <h4 className="text-lg">Example projects</h4>- {!!projectHomepageExampleProjects ? (- <div className="grid gap-2 md:gap-8 md:grid-cols-2 lg:grid-cols-3">- {/* [Alaister]: Looks like the useCustomContent has wonky types. I'll look at a fix later. */}- {(projectHomepageExampleProjects as any)- .sort((a: any, b: any) => a.title.localeCompare(b.title))- .map((project: any) => (- <ExampleProject key={project.url} {...project} />- ))}- </div>- ) : (- <div className="flex justify-center">- <Tabs_Shadcn_ defaultValue="app" className="w-full">- <TabsList_Shadcn_ className="flex gap-4 mb-8">- <TabsTrigger_Shadcn_ value="app">App Frameworks</TabsTrigger_Shadcn_>- <TabsTrigger_Shadcn_ value="mobile">- Mobile Frameworks- </TabsTrigger_Shadcn_>- </TabsList_Shadcn_>- <TabsContent_Shadcn_ value="app">- <div className="grid gap-2 md:gap-8 md:grid-cols-2 lg:grid-cols-3">- {EXAMPLE_PROJECTS.filter((project) => project.type === 'app')- .sort((a, b) => a.title.localeCompare(b.title))- .map((project) => (- <ExampleProject key={project.url} {...project} />- ))}- </div>- </TabsContent_Shadcn_>- <TabsContent_Shadcn_ value="mobile">- <div className="grid gap-2 md:gap-8 md:grid-cols-2 lg:grid-cols-3">- {EXAMPLE_PROJECTS.filter((project) => project.type === 'mobile')- .sort((a, b) => a.title.localeCompare(b.title))- .map((project) => (- <ExampleProject key={project.url} {...project} />- ))}- </div>- </TabsContent_Shadcn_>- </Tabs_Shadcn_>- </div>- )}- </div>- )}- </>- )}- </div>- </div>- </>- </div>- )-}diff --git a/apps/studio/components/interfaces/ProjectHome/ConnectSection.tsx b/apps/studio/components/interfaces/ProjectHome/ConnectSection.tsxindex 6c1be4c4250..37af9a33482 100644--- a/apps/studio/components/interfaces/ProjectHome/ConnectSection.tsx+++ b/apps/studio/components/interfaces/ProjectHome/ConnectSection.tsx@@ -1,4 +1,3 @@-import { IS_PLATFORM } from 'common'import { ChevronRight } from 'lucide-react'import { useRouter } from 'next/router'import { parseAsBoolean, parseAsString, useQueryState } from 'nuqs'@@ -8,7 +7,7 @@ import { Card, CardContent, cn } from 'ui'import { useAvailableConnectModes } from '../ConnectSheet/useAvailableConnectModes'import { CONNECT_ACTIONS } from './ConnectSection.config'import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'-import { BASE_PATH, PROJECT_STATUS } from '@/lib/constants'+import { BASE_PATH, IS_PLATFORM, PROJECT_STATUS } from '@/lib/constants'import { useTrack } from '@/lib/telemetry/track'import { useAppStateSnapshot } from '@/state/app-state'diff --git a/apps/studio/components/interfaces/ProjectHome/Home.tsx b/apps/studio/components/interfaces/ProjectHome/Home.tsxindex 442a0a27686..bf906404a4e 100644--- a/apps/studio/components/interfaces/ProjectHome/Home.tsx+++ b/apps/studio/components/interfaces/ProjectHome/Home.tsx@@ -1,6 +1,6 @@import { DndContext, DragEndEvent, PointerSensor, useSensor, useSensors } from '@dnd-kit/core'import { arrayMove, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'-import { IS_PLATFORM, useFlag, useParams } from 'common'+import { useFlag, useParams } from 'common'import dayjs from 'dayjs'import { useEffect, useRef } from 'react'import { cn } from 'ui'@@ -17,7 +17,7 @@ import { ProjectNeedsSecuring } from '@/components/layouts/ProjectNeedsSecuring/import { ScaffoldContainer, ScaffoldSection } from '@/components/layouts/Scaffold'import { useLocalStorage } from '@/hooks/misc/useLocalStorage'import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'-import { PROJECT_STATUS } from '@/lib/constants'+import { IS_PLATFORM, PROJECT_STATUS } from '@/lib/constants'import { useTrack } from '@/lib/telemetry/track'import { useAppStateSnapshot } from '@/state/app-state'@@ -73,10 +73,15 @@ export const ProjectHome = () => {setSectionOrder(mergeSectionOrder)}, [setSectionOrder])- const showConnectSection = !isMatureProject && !!project+ // On self-hosted the project's `inserted_at` is hard-coded to a past date+ // (so it always looks "mature"), and the home page is otherwise sparse —+ // always surface the Get Connected pane there. Platform keeps the+ // maturity gate so long-running projects don't see it forever.+ const showConnectSection = !!project && (!IS_PLATFORM || !isMatureProject)const renderOrder = mergeSectionOrder(sectionOrder).filter((id) => {if (id === 'connect') return showConnectSection+ if (id === 'usage' || id === 'custom-report') return IS_PLATFORMreturn true})@@ -128,7 +133,7 @@ export const ProjectHome = () => {</div>)}- if (id === 'custom-report') {+ if (IS_PLATFORM && id === 'custom-report') {return (<divkey={id}diff --git a/apps/studio/components/interfaces/ProjectHome/ProjectConnectionPopover.tsx b/apps/studio/components/interfaces/ProjectHome/ProjectConnectionPopover.tsxindex bf6de426342..b126619052b 100644--- a/apps/studio/components/interfaces/ProjectHome/ProjectConnectionPopover.tsx+++ b/apps/studio/components/interfaces/ProjectHome/ProjectConnectionPopover.tsx@@ -19,6 +19,7 @@ import { getKeys, useAPIKeysQuery } from '@/data/api-keys/api-keys-query'import { useProjectApiUrl } from '@/data/config/project-endpoint-query'import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'+import { IS_PLATFORM } from '@/lib/constants'import { pluckObjectFields } from '@/lib/helpers'const DB_FIELDS = ['db_host', 'db_name', 'db_port', 'db_user'] as const@@ -54,7 +55,7 @@ export const ProjectConnectionPopover = ({ projectRef }: ProjectConnectionPopoveconst { data: databases, isLoading: isLoadingDatabases } = useReadReplicasQuery({ projectRef },- { enabled: open && !!projectRef }+ { enabled: IS_PLATFORM && open && !!projectRef })const primaryDatabase = databases?.find((db) => db.identifier === projectRef)@@ -84,6 +85,12 @@ export const ProjectConnectionPopover = ({ projectRef }: ProjectConnectionPopove[projectRef])+ // Self-hosted projects may not have a publishable key configured. Rather+ // than show a permanently-disabled "Publishable key unavailable" row, hide+ // the entry entirely on !IS_PLATFORM when the key isn't available. Platform+ // behavior is unchanged.+ const showPublishableKey = IS_PLATFORM || !!publishableKey?.api_key+const menuItems = useMemo(() => [{@@ -95,35 +102,46 @@ export const ProjectConnectionPopover = ({ projectRef }: ProjectConnectionPopovedisabled: isLoadingApiUrl || !projectUrl,icon: Link2,},- {- label: 'Publishable key',- value: publishableKey?.api_key ?? '',- displayValue:- isLoadingPermissions || isLoadingKeys- ? 'Loading publishable key...'- : canReadAPIKeys- ? (publishableKey?.api_key ?? 'Publishable key unavailable')- : "You don't have permission to view API keys.",- disabled:- isLoadingPermissions || isLoadingKeys || !canReadAPIKeys || !publishableKey?.api_key,- icon: KeyRound,- },- {- label: 'Direct connection string',- value: directConnectionString,- displayValue: isLoadingDatabases- ? 'Loading connection string...'- : directConnectionString || 'Connection string unavailable',- disabled: isLoadingDatabases || !directConnectionString,- icon: Database,- },- {- label: 'CLI setup commands',- value: cliCommands,- displayValue: cliCommands.replace(/\n/g, ' - '),- disabled: !projectRef,- icon: Terminal,- },+ ...(showPublishableKey+ ? [+ {+ label: 'Publishable key',+ value: publishableKey?.api_key ?? '',+ displayValue:+ isLoadingPermissions || isLoadingKeys+ ? 'Loading publishable key...'+ : canReadAPIKeys+ ? (publishableKey?.api_key ?? 'Publishable key unavailable')+ : "You don't have permission to view API keys.",+ disabled:+ isLoadingPermissions ||+ isLoadingKeys ||+ !canReadAPIKeys ||+ !publishableKey?.api_key,+ icon: KeyRound,+ },+ ]+ : []),+ ...(IS_PLATFORM+ ? [+ {+ label: 'Direct connection string',+ value: directConnectionString,+ displayValue: isLoadingDatabases+ ? 'Loading connection string...'+ : directConnectionString || 'Connection string unavailable',+ disabled: isLoadingDatabases || !directConnectionString,+ icon: Database,+ },+ {+ label: 'CLI setup commands',+ value: cliCommands,+ displayValue: cliCommands.replace(/\n/g, ' - '),+ disabled: !projectRef,+ icon: Terminal,+ },+ ]+ : []),],[canReadAPIKeys,@@ -136,6 +154,7 @@ export const ProjectConnectionPopover = ({ projectRef }: ProjectConnectionPopoveprojectRef,projectUrl,publishableKey?.api_key,+ showPublishableKey,])diff --git a/apps/studio/components/interfaces/ProjectHome/TopSection.tsx b/apps/studio/components/interfaces/ProjectHome/TopSection.tsxindex 0d97223c53b..368c8d367b1 100644--- a/apps/studio/components/interfaces/ProjectHome/TopSection.tsx+++ b/apps/studio/components/interfaces/ProjectHome/TopSection.tsx@@ -11,7 +11,7 @@ import { ProjectUpgradeFailedBanner } from '@/components/ui/ProjectUpgradeFailedimport { useBranchesQuery } from '@/data/branches/branches-query'import { useProjectDetailQuery } from '@/data/projects/project-detail-query'import { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'-import { DOCS_URL, PROJECT_STATUS } from '@/lib/constants'+import { DOCS_URL, IS_PLATFORM, PROJECT_STATUS } from '@/lib/constants'export const TopSection = () => {const isOrioleDb = useIsOrioleDb()@@ -40,7 +40,12 @@ export const TopSection = () => {return (<div className="flex flex-col gap-y-4">- <div className="grid grid-cols-1 md:grid-cols-2 gap-8 py-0 w-full items-center">+ <div+ className={cn(+ 'grid grid-cols-1 gap-8 py-0 w-full items-center',+ IS_PLATFORM && 'md:grid-cols-2'+ )}+ ><div className="flex flex-col"><div className="flex flex-row flex-wrap items-center gap-4 w-full"><div>@@ -73,21 +78,25 @@ export const TopSection = () => {<ProjectConnectionPopover projectRef={project?.ref} /></div></div>- <div className="mt-8">- <ActivityStats />- </div>+ {IS_PLATFORM && (+ <div className="mt-8">+ <ActivityStats />+ </div>+ )}</div>- <div>- <div- className={cn(- 'w-full h-[400px] md:h-[500px] border border-muted rounded-md overflow-hidden flex flex-col relative'- )}- >- <ReactFlowProvider>- <InstanceConfiguration diagramOnly />- </ReactFlowProvider>+ {IS_PLATFORM && (+ <div>+ <div+ className={cn(+ 'w-full h-[400px] md:h-[500px] border border-muted rounded-md overflow-hidden flex flex-col relative'+ )}+ >+ <ReactFlowProvider>+ <InstanceConfiguration diagramOnly />+ </ReactFlowProvider>+ </div></div>- </div>+ )}</div><ProjectUpgradeFailedBanner /></div>diff --git a/apps/studio/pages/project/[ref]/index.tsx b/apps/studio/pages/project/[ref]/index.tsxindex 8e1b42dd292..428d2974266 100644--- a/apps/studio/pages/project/[ref]/index.tsx+++ b/apps/studio/pages/project/[ref]/index.tsx@@ -1,13 +1,10 @@-import { IS_PLATFORM } from 'common'--import { Home } from '@/components/interfaces/Home/Home'import { ProjectHome } from '@/components/interfaces/ProjectHome/Home'import DefaultLayout from '@/components/layouts/DefaultLayout'import { ProjectLayoutWithAuth } from '@/components/layouts/ProjectLayout'import type { NextPageWithLayout } from '@/types'const HomePage: NextPageWithLayout = () => {- return IS_PLATFORM ? <ProjectHome /> : <Home />+ return <ProjectHome />}HomePage.getLayout = (page) => (diff --git a/apps/studio/tests/pages/project/[ref]/index.test.tsx b/apps/studio/tests/pages/project/[ref]/index.test.tsxindex 795489ab779..26e5bfd32b0 100644--- a/apps/studio/tests/pages/project/[ref]/index.test.tsx+++ b/apps/studio/tests/pages/project/[ref]/index.test.tsx@@ -1,12 +1,8 @@import { screen } from '@testing-library/react'-import { beforeAll, describe, expect, test, vi } from 'vitest'+import { describe, expect, test, vi } from 'vitest'import { customRender as render } from '@/tests/lib/custom-render'-vi.mock('@/components/interfaces/Home/Home', () => ({- Home: () => <div data-testid="old-home" />,-}))-vi.mock('@/components/interfaces/ProjectHome/Home', () => ({ProjectHome: () => <div data-testid="project-home" />,}))@@ -23,35 +19,10 @@ vi.mock('@/lib/gotrue', () => ({auth: { onAuthStateChange: vi.fn() },}))-describe('when IS_PLATFORM is true', () => {- beforeAll(() => {- vi.doMock('common', async (importOriginal: () => Promise<any>) => {- const mod = await importOriginal()- return { ...mod, IS_PLATFORM: true }- })- })-+describe('project home page', () => {test('renders ProjectHome', async () => {const { default: HomePage } = await import('@/pages/project/[ref]/index')render(<HomePage dehydratedState={undefined} />)expect(screen.getByTestId('project-home')).toBeInTheDocument()- expect(screen.queryByTestId('old-home')).not.toBeInTheDocument()- })-})--describe('when IS_PLATFORM is false', () => {- beforeAll(() => {- vi.resetModules()- vi.doMock('common', async (importOriginal: () => Promise<any>) => {- const mod = await importOriginal()- return { ...mod, IS_PLATFORM: false }- })- })-- test('renders Home', async () => {- const { default: HomePage } = await import('@/pages/project/[ref]/index')- render(<HomePage dehydratedState={undefined} />)- expect(screen.getByTestId('old-home')).toBeInTheDocument()- expect(screen.queryByTestId('project-home')).not.toBeInTheDocument()})})diff --git a/e2e/studio/features/connect.spec.ts b/e2e/studio/features/connect.spec.tsindex 0cb908f7740..50d8be1e8c9 100644--- a/e2e/studio/features/connect.spec.ts+++ b/e2e/studio/features/connect.spec.ts@@ -43,7 +43,7 @@ test.describe('Connect', async () => {await expect(page.getByRole('heading', { level: 1 })).toBeVisible({ timeout: 30000 })// Click the Connect button in the header- await page.getByRole('button', { name: 'Connect' }).click()+ await page.getByRole('button', { name: 'Connect', exact: true }).click()// Verify the ConnectSheet opensawait expect(page.getByRole('heading', { name: 'Connect to your project' })).toBeVisible({@@ -58,9 +58,7 @@ test.describe('Connect', async () => {test.describe('Connect Sheet deep linking', async () => {test('pre-selects framework and variant from URL params', async ({ page, ref }) => {await page.goto(- toUrl(- `/project/${ref}?showConnect=true&connectTab=framework&framework=nextjs&using=pages`- )+ toUrl(`/project/${ref}?showConnect=true&connectTab=framework&framework=nextjs&using=pages`))await expect(@@ -125,9 +123,7 @@ test.describe('Connect Sheet deep linking', async () => {})test('pre-selects direct connection method from URL params', async ({ page, ref }) => {- await page.goto(- toUrl(`/project/${ref}?showConnect=true&connectTab=direct&method=transaction`)- )+ await page.goto(toUrl(`/project/${ref}?showConnect=true&connectTab=direct&method=transaction`))await expect(page.getByRole('heading', { name: 'Connect to your project' }),@@ -142,9 +138,7 @@ test.describe('Connect Sheet deep linking', async () => {test('closing the sheet clears all deep-link params from URL', async ({ page, ref }) => {await page.goto(- toUrl(- `/project/${ref}?showConnect=true&connectTab=framework&framework=nextjs&using=pages`- )+ toUrl(`/project/${ref}?showConnect=true&connectTab=framework&framework=nextjs&using=pages`))await expect(@@ -165,9 +159,7 @@ test.describe('Connect Sheet deep linking', async () => {})test('changing mode clears previous mode params from URL', async ({ page, ref }) => {- await page.goto(- toUrl(`/project/${ref}?showConnect=true&connectTab=framework&framework=nextjs`)- )+ await page.goto(toUrl(`/project/${ref}?showConnect=true&connectTab=framework&framework=nextjs`))await expect(page.getByRole('heading', { name: 'Connect to your project' }),