Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Getting started step status (#38910)

Saxon Fletcher410d76fff355
diff --git a/apps/studio/components/interfaces/HomeNew/AdvisorSection.tsx b/apps/studio/components/interfaces/HomeNew/AdvisorSection.tsx
index 65858938c26..8d2e466e4b0 100644
--- a/apps/studio/components/interfaces/HomeNew/AdvisorSection.tsx
+++ b/apps/studio/components/interfaces/HomeNew/AdvisorSection.tsx
@@ -2,6 +2,7 @@ import { BarChart, Shield } from 'lucide-react'
import { useCallback, useMemo, useState } from 'react'
import { useParams } from 'common'
+import LintDetail from 'components/interfaces/Linter/LintDetail'
import { LINTER_LEVELS } from 'components/interfaces/Linter/Linter.constants'
import {
createLintSummaryPrompt,
@@ -28,7 +29,6 @@ import {
} from 'ui'
import { Row } from 'ui-patterns'
import ShimmeringLoader from 'ui-patterns/ShimmeringLoader'
-import LintDetail from 'components/interfaces/Linter/LintDetail'
export const AdvisorSection = () => {
const { ref: projectRef } = useParams()
diff --git a/apps/studio/components/interfaces/HomeNew/CustomReportSection.tsx b/apps/studio/components/interfaces/HomeNew/CustomReportSection.tsx
index 8737860d1dd..ad0e12284ad 100644
--- a/apps/studio/components/interfaces/HomeNew/CustomReportSection.tsx
+++ b/apps/studio/components/interfaces/HomeNew/CustomReportSection.tsx
@@ -50,9 +50,11 @@ export function CustomReportSection() {
reportContent
)
- useEffect(() => {
- if (reportContent) setEditableReport(reportContent)
- }, [reportContent])
+ const { can: canCreateReport } = useAsyncCheckPermissions(
+ PermissionAction.CREATE,
+ 'user_content',
+ { resource: { type: 'report', owner_id: profile?.id }, subject: { id: profile?.id } }
+ )
const { can: canUpdateReport } = useAsyncCheckPermissions(
PermissionAction.UPDATE,
@@ -67,12 +69,6 @@ export function CustomReportSection() {
}
)
- const { can: canCreateReport } = useAsyncCheckPermissions(
- PermissionAction.CREATE,
- 'user_content',
- { resource: { type: 'report', owner_id: profile?.id }, subject: { id: profile?.id } }
- )
-
const { mutate: upsertContent } = useContentUpsertMutation()
const persistReport = useCallback(
@@ -275,10 +271,14 @@ export function CustomReportSection() {
const layout = useMemo(() => editableReport?.layout ?? [], [editableReport])
+ useEffect(() => {
+ if (reportContent) setEditableReport(reportContent)
+ }, [reportContent])
+
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
- <h3 className="heading-section">At a glance</h3>
+ <h3 className="heading-section">Reports</h3>
{canUpdateReport || canCreateReport ? (
<SnippetDropdown
projectRef={ref}
@@ -295,66 +295,65 @@ export function CustomReportSection() {
) : null}
</div>
<div className="relative">
- {(() => {
- if (layout.length === 0) {
- return (
- <div className="flex min-h-[270px] items-center justify-center rounded border-2 border-dashed p-16 border-default">
- {canUpdateReport || canCreateReport ? (
- <SnippetDropdown
- projectRef={ref}
- onSelect={addSnippetToReport}
- trigger={
- <Button type="default" iconRight={<Plus size={14} />}>
- Add your first chart
- </Button>
- }
- side="bottom"
- align="center"
- autoFocus
- />
- ) : (
- <p className="text-sm text-foreground-light">No charts set up yet in report</p>
- )}
- </div>
- )
- }
- return (
- <DndContext
- sensors={sensors}
- collisionDetection={closestCenter}
- onDragStart={handleDragStart}
- onDragEnd={handleDragEnd}
+ {layout.length === 0 ? (
+ <div className="h-64 flex flex-col items-center justify-center rounded border-2 border-dashed p-16 border-default">
+ <h4>Build a custom report</h4>
+ <p className="text-sm text-foreground-light mb-4">
+ Keep track of your most important metrics
+ </p>
+ {canUpdateReport || canCreateReport ? (
+ <SnippetDropdown
+ projectRef={ref}
+ onSelect={addSnippetToReport}
+ trigger={
+ <Button type="default" iconRight={<Plus size={14} />}>
+ Add your first block
+ </Button>
+ }
+ side="bottom"
+ align="center"
+ autoFocus
+ />
+ ) : (
+ <p className="text-sm text-foreground-light">No charts set up yet in report</p>
+ )}
+ </div>
+ ) : (
+ <DndContext
+ sensors={sensors}
+ collisionDetection={closestCenter}
+ onDragStart={handleDragStart}
+ onDragEnd={handleDragEnd}
+ >
+ <SortableContext
+ items={(editableReport?.layout ?? []).map((x) => String(x.id))}
+ strategy={rectSortingStrategy}
>
- <SortableContext
- items={(editableReport?.layout ?? []).map((x) => String(x.id))}
- strategy={rectSortingStrategy}
- >
- <Row columns={[3, 2, 1]}>
- {layout.map((item) => (
- <SortableReportBlock key={item.id} id={String(item.id)}>
- <div className="h-64">
- <ReportBlock
- key={item.id}
- item={item}
- startDate={startDate}
- endDate={endDate}
- interval={
- (editableReport?.interval as AnalyticsInterval) ??
- ('1d' as AnalyticsInterval)
- }
- disableUpdate={false}
- isRefreshing={false}
- onRemoveChart={handleRemoveChart}
- onUpdateChart={(config) => handleUpdateChart(item.id, config)}
- />
- </div>
- </SortableReportBlock>
- ))}
- </Row>
- </SortableContext>
- </DndContext>
- )
- })()}
+ <Row columns={[3, 2, 1]}>
+ {layout.map((item) => (
+ <SortableReportBlock key={item.id} id={String(item.id)}>
+ <div className="h-64">
+ <ReportBlock
+ key={item.id}
+ item={item}
+ startDate={startDate}
+ endDate={endDate}
+ interval={
+ (editableReport?.interval as AnalyticsInterval) ??
+ ('1d' as AnalyticsInterval)
+ }
+ disableUpdate={false}
+ isRefreshing={false}
+ onRemoveChart={handleRemoveChart}
+ onUpdateChart={(config) => handleUpdateChart(item.id, config)}
+ />
+ </div>
+ </SortableReportBlock>
+ ))}
+ </Row>
+ </SortableContext>
+ </DndContext>
+ )}
</div>
</div>
)
diff --git a/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.tsx b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.tsx
index b07d0819f56..fbdfe7aa41f 100644
--- a/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.tsx
+++ b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.tsx
@@ -2,10 +2,9 @@ import { Check, ChevronLeft, ChevronRight } from 'lucide-react'
import Image from 'next/image'
import Link from 'next/link'
import { useEffect, useState } from 'react'
-
+import { cn, Button, Card, CardContent, Badge } from 'ui'
+import { GettingStartedStep, GettingStartedAction } from './GettingStarted.types'
import { BASE_PATH } from 'lib/constants'
-import { Badge, Button, Card, CardContent, cn } from 'ui'
-import { GettingStartedAction, GettingStartedStep } from './GettingStartedSection'
// Determine action type for tracking
const getActionType = (action: GettingStartedAction): 'primary' | 'ai_assist' | 'external_link' => {
diff --git a/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.types.ts b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.types.ts
new file mode 100644
index 00000000000..e1a6ca55ea8
--- /dev/null
+++ b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.types.ts
@@ -0,0 +1,24 @@
+import { ComponentProps, ReactNode } from 'react'
+
+import { Button } from 'ui'
+
+export type GettingStartedAction = {
+ label: string
+ href?: string
+ variant?: ComponentProps<typeof Button>['type']
+ icon?: ReactNode
+ component?: ReactNode
+ onClick?: () => void
+}
+
+export type GettingStartedStep = {
+ key: string
+ status: 'complete' | 'incomplete'
+ icon?: ReactNode
+ title: string
+ description: string
+ image?: string
+ actions: GettingStartedAction[]
+}
+
+export type GettingStartedState = 'empty' | 'code' | 'no-code' | 'hidden'
diff --git a/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.utils.tsx b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.utils.tsx
new file mode 100644
index 00000000000..a5eb5272010
--- /dev/null
+++ b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStarted.utils.tsx
@@ -0,0 +1,412 @@
+import {
+ BarChart3,
+ Code,
+ Database,
+ GitBranch,
+ Shield,
+ Table,
+ Upload,
+ User,
+ UserPlus,
+} from 'lucide-react'
+
+import { FRAMEWORKS } from 'components/interfaces/Connect/Connect.constants'
+import { AiIconAnimation, CodeBlock } from 'ui'
+import type { GettingStartedAction, GettingStartedStep } from './GettingStarted.types'
+import type { GettingStartedStatuses } from './useGettingStartedProgress'
+
+type BuildStepsBaseArgs = {
+ ref: string | undefined
+ openAiChat: (name: string, initialInput: string) => void
+ connectActions: GettingStartedAction[]
+ statuses: GettingStartedStatuses
+}
+
+type BuildCodeStepsArgs = BuildStepsBaseArgs
+
+type BuildNoCodeStepsArgs = BuildStepsBaseArgs
+
+export const getCodeWorkflowSteps = ({
+ ref,
+ openAiChat,
+ connectActions,
+ statuses,
+}: BuildCodeStepsArgs): GettingStartedStep[] => {
+ const {
+ hasTables,
+ hasCliSetup,
+ hasSampleData,
+ hasRlsPolicies,
+ hasConfiguredAuth,
+ hasAppConnected,
+ hasFirstUser,
+ hasStorageObjects,
+ hasEdgeFunctions,
+ hasReports,
+ hasGitHubConnection,
+ } = statuses
+
+ return [
+ {
+ key: 'install-cli',
+ status: hasCliSetup ? 'complete' : 'incomplete',
+ title: 'Install the Supabase CLI',
+ icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'To get started, install the Supabase CLI—our command-line toolkit for managing projects locally, handling migrations, and seeding data—using the npm command below to add it to your workspace.',
+ actions: [
+ {
+ label: 'Install via npm',
+ component: (
+ <CodeBlock className="w-full text-xs p-3 !bg" language="bash">
+ npm install supabase --save-dev
+ </CodeBlock>
+ ),
+ },
+ ],
+ },
+ {
+ key: 'design-db',
+ status: hasTables ? 'complete' : 'incomplete',
+ title: 'Design your database schema',
+ icon: <Database strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Next, create a schema file that defines the structure of your database, either following our declarative schema guide or asking the AI assistant to generate one for you.',
+ actions: [
+ {
+ label: 'Create schema file',
+ href: 'https://supabase.com/docs/guides/local-development/declarative-database-schemas',
+ variant: 'default',
+ },
+ {
+ label: 'Generate it',
+ variant: 'default',
+ icon: <AiIconAnimation size={14} />,
+ onClick: () =>
+ openAiChat(
+ 'Design my database',
+ 'Help me create a schema file for my database. We will be using Supabase declarative schemas which you can learn about by searching docs for declarative schema.'
+ ),
+ },
+ ],
+ },
+ {
+ key: 'add-data',
+ status: hasSampleData ? 'complete' : 'incomplete',
+ title: 'Seed your database with data',
+ icon: <Table strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Now, create a seed file to populate your database with initial data, using the docs for guidance or letting the AI assistant draft realistic inserts.',
+ actions: [
+ {
+ label: 'Create a seed file',
+ href: 'https://supabase.com/docs/guides/local-development/seeding-your-database',
+ variant: 'default',
+ },
+ {
+ label: 'Generate data',
+ variant: 'default',
+ icon: <AiIconAnimation size={14} />,
+ onClick: () =>
+ openAiChat(
+ 'Generate seed data',
+ 'Generate SQL INSERT statements for realistic seed data that I can run via the Supabase CLI.'
+ ),
+ },
+ ],
+ },
+ {
+ key: 'add-rls-policies',
+ status: hasRlsPolicies ? 'complete' : 'incomplete',
+ title: 'Secure your data with RLS policies',
+ icon: <Shield strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "Let's secure your data by enabling Row Level Security (per-row access rules that decide who can read or write specific records) and defining policies in a migration file, either configuring them manually or letting the AI assistant draft policies for your tables.",
+ actions: [
+ {
+ label: 'Create a migration file',
+ href: `/project/${ref}/auth/policies`,
+ variant: 'default',
+ },
+ {
+ label: 'Create policies for me',
+ variant: 'default',
+ icon: <AiIconAnimation size={14} />,
+ onClick: () =>
+ openAiChat(
+ 'Generate RLS policies',
+ 'Generate RLS policies for my existing tables in the public schema and guide me through the process of adding them as migration files to my codebase '
+ ),
+ },
+ ],
+ },
+ {
+ key: 'setup-auth',
+ status: hasConfiguredAuth ? 'complete' : 'incomplete',
+ title: 'Allow user signups',
+ icon: <User strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "It's time to configure your authentication providers and settings for Supabase Auth, so jump into the configuration page and tailor the providers you need.",
+ actions: [{ label: 'Configure', href: `/project/${ref}/auth/providers`, variant: 'default' }],
+ },
+ {
+ key: 'connect-app',
+ status: hasAppConnected ? 'complete' : 'incomplete',
+ title: 'Connect your application',
+ icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Your project is ready; use the framework selector to preview starter code and launch the Connect flow with the client library you prefer.',
+ actions: connectActions,
+ },
+ {
+ key: 'signup-first-user',
+ status: hasFirstUser ? 'complete' : 'incomplete',
+ title: 'Sign up your first user',
+ icon: <UserPlus strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Test your authentication setup by creating the first user account, following the docs if you need a step-by-step walkthrough.',
+ actions: [
+ {
+ label: 'Read docs',
+ href: 'https://supabase.com/docs/guides/auth',
+ variant: 'default',
+ },
+ ],
+ },
+ {
+ key: 'upload-file',
+ status: hasStorageObjects ? 'complete' : 'incomplete',
+ title: 'Upload a file',
+ icon: <Upload strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Integrate file storage by creating a bucket via SQL and uploading a file using our client libraries.',
+ actions: [
+ {
+ label: 'Create a bucket via SQL',
+ href: 'https://supabase.com/docs/guides/storage/buckets/creating-buckets?queryGroups=language&language=sql',
+ variant: 'default',
+ },
+ {
+ label: 'Upload a file',
+ href: 'https://supabase.com/docs/guides/storage/uploads/standard-uploads',
+ variant: 'default',
+ },
+ ],
+ },
+ {
+ key: 'create-edge-function',
+ status: hasEdgeFunctions ? 'complete' : 'incomplete',
+ title: 'Deploy an Edge Function',
+ icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Add server-side logic by creating and deploying your first Edge Function—a lightweight TypeScript or JavaScript function that runs close to your users—then revisit the list to monitor and iterate on it.',
+ actions: [
+ {
+ label: 'Create and deploy via CLI',
+ href: `https://supabase.com/docs/guides/functions/quickstart`,
+ variant: 'default',
+ },
+ { label: 'View functions', href: `/project/${ref}/functions`, variant: 'default' },
+ ],
+ },
+ {
+ key: 'monitor-progress',
+ status: hasReports ? 'complete' : 'incomplete',
+ title: "Monitor your project's usage",
+ icon: <BarChart3 strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "Track your project's activity by creating custom reports for API, database, and auth events right from the reports dashboard.",
+ actions: [{ label: 'Reports', href: `/project/${ref}/reports`, variant: 'default' }],
+ },
+ {
+ key: 'connect-github',
+ status: hasGitHubConnection ? 'complete' : 'incomplete',
+ title: 'Connect to GitHub',
+ icon: <GitBranch strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Link this project to a GitHub repository to keep production in sync and spin up preview branches from pull requests.',
+ actions: [
+ {
+ label: 'Connect to GitHub',
+ href: `/project/${ref}/settings/integrations`,
+ variant: 'default',
+ },
+ ],
+ },
+ ]
+}
+
+export const getNoCodeWorkflowSteps = ({
+ ref,
+ openAiChat,
+ connectActions,
+ statuses,
+}: BuildNoCodeStepsArgs): GettingStartedStep[] => {
+ const {
+ hasTables,
+ hasSampleData,
+ hasRlsPolicies,
+ hasConfiguredAuth,
+ hasAppConnected,
+ hasFirstUser,
+ hasStorageObjects,
+ hasEdgeFunctions,
+ hasReports,
+ hasGitHubConnection,
+ } = statuses
+
+ return [
+ {
+ key: 'design-db',
+ status: hasTables ? 'complete' : 'incomplete',
+ title: 'Create your first table',
+ icon: <Database strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "To kick off your new project, let's start by creating your very first database table using either the table editor or the AI assistant to shape the structure for you.",
+ actions: [
+ { label: 'Create a table', href: `/project/${ref}/editor`, variant: 'default' },
+ {
+ label: 'Do it for me',
+ variant: 'default',
+ icon: <AiIconAnimation size={14} />,
+ onClick: () =>
+ openAiChat(
+ 'Design my database',
+ 'I want to design my database schema. Please propose tables, relationships, and SQL to create them for my app. Ask clarifying questions if needed.'
+ ),
+ },
+ ],
+ },
+ {
+ key: 'add-data',
+ status: hasSampleData ? 'complete' : 'incomplete',
+ title: 'Add sample data',
+ icon: <Table strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "Next, let's add some sample data that you can play with once you connect your app, either by inserting rows yourself or letting the AI assistant craft realistic examples.",
+ actions: [
+ { label: 'Add data', href: `/project/${ref}/editor`, variant: 'default' },
+ {
+ label: 'Do it for me',
+ variant: 'default',
+ icon: <AiIconAnimation size={14} />,
+ onClick: () =>
+ openAiChat(
+ 'Generate sample data',
+ 'Generate SQL INSERT statements to add realistic sample data to my existing tables. Use safe defaults and avoid overwriting data.'
+ ),
+ },
+ ],
+ },
+ {
+ key: 'add-rls-policies',
+ status: hasRlsPolicies ? 'complete' : 'incomplete',
+ title: 'Secure your data with Row Level Security',
+ icon: <Shield strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "Now that you have some data, let's secure it by enabling Row Level Security (row-specific access rules that control who can view or modify records) and creating policies yourself or with help from the AI assistant.",
+ actions: [
+ {
+ label: 'Create a policy',
+ href: `/project/${ref}/auth/policies`,
+ variant: 'default',
+ },
+ {
+ label: 'Do it for me',
+ variant: 'default',
+ icon: <AiIconAnimation size={14} />,
+ onClick: () =>
+ openAiChat(
+ 'Generate RLS policies',
+ 'Generate RLS policies for my existing tables in the public schema. '
+ ),
+ },
+ ],
+ },
+ {
+ key: 'setup-auth',
+ status: hasConfiguredAuth ? 'complete' : 'incomplete',
+ title: 'Allow user signups',
+ icon: <User strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "It's time to set up authentication so you can start signing up users, configuring providers and settings from the auth dashboard.",
+ actions: [
+ { label: 'Configure auth', href: `/project/${ref}/auth/providers`, variant: 'default' },
+ ],
+ },
+ {
+ key: 'connect-app',
+ status: hasAppConnected ? 'complete' : 'incomplete',
+ title: 'Connect your application',
+ icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Your project is ready; use the framework selector to preview starter code and launch the Connect flow to wire up your app.',
+ actions: connectActions,
+ },
+ {
+ key: 'signup-first-user',
+ status: hasFirstUser ? 'complete' : 'incomplete',
+ title: 'Sign up your first user',
+ icon: <UserPlus strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Test your authentication by signing up your first user, referencing the docs if you need sample flows or troubleshooting tips.',
+ actions: [
+ {
+ label: 'Read docs',
+ href: 'https://supabase.com/docs/guides/auth',
+ variant: 'default',
+ },
+ ],
+ },
+ {
+ key: 'upload-file',
+ status: hasStorageObjects ? 'complete' : 'incomplete',
+ title: 'Upload a file',
+ icon: <Upload strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "Let's add file storage to your app by creating a bucket and uploading your first file from the buckets dashboard.",
+ actions: [{ label: 'Buckets', href: `/project/${ref}/storage/buckets`, variant: 'default' }],
+ },
+ {
+ key: 'create-edge-function',
+ status: hasEdgeFunctions ? 'complete' : 'incomplete',
+ title: 'Add server-side logic',
+ icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "Extend your app's functionality by creating an Edge Function—a lightweight serverless function that executes close to your users—for server-side logic directly from the functions page.",
+ actions: [
+ {
+ label: 'Create a function',
+ href: `/project/${ref}/functions/new`,
+ variant: 'default',
+ },
+ ],
+ },
+ {
+ key: 'monitor-progress',
+ status: hasReports ? 'complete' : 'incomplete',
+ title: "Monitor your project's health",
+ icon: <BarChart3 strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ "Keep an eye on your project's performance and usage by setting up custom reports from the reports dashboard.",
+ actions: [{ label: 'Create a report', href: `/project/${ref}/reports`, variant: 'default' }],
+ },
+ {
+ key: 'connect-github',
+ status: hasGitHubConnection ? 'complete' : 'incomplete',
+ title: 'Connect to GitHub',
+ icon: <GitBranch strokeWidth={1} className="text-foreground-muted" size={16} />,
+ description:
+ 'Connect your project to GitHub to automatically create preview branches and sync production changes.',
+ actions: [
+ {
+ label: 'Connect to GitHub',
+ href: `/project/${ref}/settings/integrations`,
+ variant: 'default',
+ },
+ ],
+ },
+ ]
+}
+
+export const DEFAULT_FRAMEWORK_KEY = FRAMEWORKS[0]?.key ?? 'nextjs'
diff --git a/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStartedSection.tsx b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStartedSection.tsx
index 4771b751fb6..ba121daa170 100644
--- a/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStartedSection.tsx
+++ b/apps/studio/components/interfaces/HomeNew/GettingStarted/GettingStartedSection.tsx
@@ -1,99 +1,48 @@
-import {
- BarChart3,
- Code,
- Database,
- GitBranch,
- Shield,
- Table,
- Table2,
- Upload,
- User,
- UserPlus,
-} from 'lucide-react'
+import { Code, Table2 } from 'lucide-react'
import { useRouter } from 'next/router'
import { useCallback, useMemo, useState } from 'react'
import { useParams } from 'common'
import { FRAMEWORKS } from 'components/interfaces/Connect/Connect.constants'
-import { useBranchesQuery } from 'data/branches/branches-query'
-import { useTablesQuery } from 'data/tables/tables-query'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
-import { BASE_PATH, DOCS_URL } from 'lib/constants'
+import { BASE_PATH } from 'lib/constants'
import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state'
-import {
- AiIconAnimation,
- Button,
- Card,
- CardContent,
- CodeBlock,
- ToggleGroup,
- ToggleGroupItem,
-} from 'ui'
+import { Button, Card, CardContent, ToggleGroup, ToggleGroupItem } from 'ui'
import { FrameworkSelector } from './FrameworkSelector'
import { GettingStarted } from './GettingStarted'
+import {
+ GettingStartedAction,
+ GettingStartedState,
+ GettingStartedStep,
+} from './GettingStarted.types'
+import {
+ DEFAULT_FRAMEWORK_KEY,
+ getCodeWorkflowSteps,
+ getNoCodeWorkflowSteps,
+} from './GettingStarted.utils'
+import { useGettingStartedProgress } from './useGettingStartedProgress'
-export type GettingStartedAction = {
- label: string
- href?: string
- onClick?: () => void
- variant?: React.ComponentProps<typeof Button>['type']
- icon?: React.ReactNode
- component?: React.ReactNode
-}
-
-export type GettingStartedStep = {
- key: string
- status: 'complete' | 'incomplete'
- icon?: React.ReactNode
- title: string
- description: string
- image?: string
- actions: GettingStartedAction[]
-}
-
-export type GettingStartedState = 'empty' | 'code' | 'no-code' | 'hidden'
-
-export function GettingStartedSection({
- value,
- onChange,
-}: {
+interface GettingStartedSectionProps {
value: GettingStartedState
onChange: (v: GettingStartedState) => void
-}) {
+}
+
+export function GettingStartedSection({ value, onChange }: GettingStartedSectionProps) {
+ const router = useRouter()
+ const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
const { data: organization } = useSelectedOrganizationQuery()
- const { ref } = useParams()
- const aiSnap = useAiAssistantStateSnapshot()
- const router = useRouter()
const { mutate: sendEvent } = useSendEventMutation()
+ const aiSnap = useAiAssistantStateSnapshot()
- // Local state for framework selector preview
- const [selectedFramework, setSelectedFramework] = useState<string>(FRAMEWORKS[0]?.key ?? 'nextjs')
+ const [selectedFramework, setSelectedFramework] = useState<string>(DEFAULT_FRAMEWORK_KEY)
const workflow: 'no-code' | 'code' | null = value === 'code' || value === 'no-code' ? value : null
const [previousWorkflow, setPreviousWorkflow] = useState<'no-code' | 'code' | null>(null)
- const { data: tablesData } = useTablesQuery({
- projectRef: project?.ref,
- connectionString: project?.connectionString,
- schema: 'public',
- })
-
- const tablesCount = Math.max(0, tablesData?.length ?? 0)
- const { data: branchesData } = useBranchesQuery({
- projectRef: project?.parent_project_ref ?? project?.ref,
- })
- const isDefaultProject = project?.parent_project_ref === undefined
- const hasNonDefaultBranch =
- (branchesData ?? []).some((b) => !b.is_default) || isDefaultProject === false
+ const statuses = useGettingStartedProgress()
- const selectedFrameworkMeta = useMemo(
- () => FRAMEWORKS.find((item) => item.key === selectedFramework),
- [selectedFramework]
- )
-
- // Helpers
const openAiChat = useCallback(
(name: string, initialInput: string) => aiSnap.newChat({ name, open: true, initialInput }),
[aiSnap]
@@ -133,354 +82,29 @@ export function GettingStartedSection({
onClick: openConnect,
},
],
- [openConnect, openAiChat, selectedFramework, selectedFrameworkMeta?.label]
+ [openConnect, selectedFramework]
)
const codeSteps: GettingStartedStep[] = useMemo(
- () => [
- {
- key: 'install-cli',
- status: 'incomplete',
- title: 'Install the Supabase CLI',
- icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'To get started, install the Supabase CLI—our command-line toolkit for managing projects locally, handling migrations, and seeding data—using the npm command below to add it to your workspace.',
- actions: [
- {
- label: 'Install via npm',
- component: (
- <CodeBlock className="w-full text-xs p-3 !bg" language="bash">
- npm install supabase --save-dev
- </CodeBlock>
- ),
- },
- ],
- },
- {
- key: 'design-db',
- status: tablesCount > 0 ? 'complete' : 'incomplete',
- title: 'Design your database schema',
- icon: <Database strokeWidth={1} className="text-foreground-muted" size={16} />,
- image: `${BASE_PATH}/img/getting-started/declarative-schemas.png`,
- description:
- 'Next, create a schema file that defines the structure of your database, either following our declarative schema guide or asking the AI assistant to generate one for you.',
- actions: [
- {
- label: 'Create schema file',
- href: `${DOCS_URL}/guides/local-development/declarative-database-schemas`,
- variant: 'default',
- },
- {
- label: 'Generate it',
- variant: 'default',
- icon: <AiIconAnimation size={14} />,
- onClick: () =>
- openAiChat(
- 'Design my database',
- 'Help me create a schema file for my database. We will be using Supabase declarative schemas which you can learn about by searching docs for declarative schema.'
- ),
- },
- ],
- },
- {
- key: 'add-data',
- status: 'incomplete',
- title: 'Seed your database with data',
- icon: <Table strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'Now, create a seed file to populate your database with initial data, using the docs for guidance or letting the AI assistant draft realistic inserts.',
- actions: [
- {
- label: 'Create a seed file',
- href: `${DOCS_URL}/guides/local-development/seeding-your-database`,
- variant: 'default',
- },
- {
- label: 'Generate data',
- variant: 'default',
- icon: <AiIconAnimation size={14} />,
- onClick: () =>
- openAiChat(
- 'Generate seed data',
- 'Generate SQL INSERT statements for realistic seed data that I can run via the Supabase CLI.'
- ),
- },
- ],
- },
- {
- key: 'add-rls-policies',
- status: 'incomplete',
- title: 'Secure your data with RLS policies',
- icon: <Shield strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- "Let's secure your data by enabling Row Level Security (per-row access rules that decide who can read or write specific records) and defining policies in a migration file, either configuring them manually or letting the AI assistant draft policies for your tables.",
- actions: [
- {
- label: 'Create a migration file',
- href: `/project/${ref}/auth/policies`,
- variant: 'default',
- },
- {
- label: 'Create policies for me',
- variant: 'default',
- icon: <AiIconAnimation size={14} />,
- onClick: () =>
- openAiChat(
- 'Generate RLS policies',
- 'Generate RLS policies for my existing tables in the public schema and guide me through the process of adding them as migration files to my codebase '
- ),
- },
- ],
- },
- {
- key: 'setup-auth',
- status: 'incomplete',
- title: 'Configure authentication',
- icon: <User strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- "It's time to configure your authentication providers and settings for Supabase Auth, so jump into the configuration page and tailor the providers you need.",
- actions: [
- { label: 'Configure', href: `/project/${ref}/auth/providers`, variant: 'default' },
- ],
- },
- {
- key: 'connect-app',
- status: 'incomplete',
- title: 'Connect your application',
- icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'Your project is ready; use the framework selector to preview starter code and launch the Connect flow with the client library you prefer.',
- actions: connectActions,
- },
- {
- key: 'signup-first-user',
- status: 'incomplete',
- title: 'Sign up your first user',
- icon: <UserPlus strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'Test your authentication setup by creating the first user account, following the docs if you need a step-by-step walkthrough.',
- actions: [
- {
- label: 'Read docs',
- href: `${DOCS_URL}/guides/auth`,
- variant: 'default',
- },
- ],
- },
- {
- key: 'upload-file',
- status: 'incomplete',
- title: 'Upload a file',
- icon: <Upload strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'Integrate file storage by creating a bucket and uploading a file, starting from the buckets dashboard linked below.',
- actions: [
- { label: 'Buckets', href: `/project/${ref}/storage/buckets`, variant: 'default' },
- ],
- },
- {
- key: 'create-edge-function',
- status: 'incomplete',
- title: 'Deploy an Edge Function',
- icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'Add server-side logic by creating and deploying your first Edge Function—a lightweight TypeScript or JavaScript function that runs close to your users—then revisit the list to monitor and iterate on it.',
- actions: [
- {
- label: 'Create a function',
- href: `/project/${ref}/functions/new`,
- variant: 'default',
- },
- { label: 'View functions', href: `/project/${ref}/functions`, variant: 'default' },
- ],
- },
- {
- key: 'monitor-progress',
- status: 'incomplete',
- title: "Monitor your project's usage",
- icon: <BarChart3 strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- "Track your project's activity by creating custom reports for API, database, and auth events right from the reports dashboard.",
- actions: [{ label: 'Reports', href: `/project/${ref}/reports`, variant: 'default' }],
- },
- {
- key: 'create-first-branch',
- status: hasNonDefaultBranch ? 'complete' : 'incomplete',
- title: 'Connect to GitHub',
- icon: <GitBranch strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'Streamline your development workflow by connecting your project to GitHub, using the integrations page to automate branch management.',
- actions: [
- {
- label: 'Connect to GitHub',
- href: `/project/${ref}/settings/integrations`,
- variant: 'default',
- },
- ],
- },
- ],
- [tablesCount, ref, openAiChat, connectActions, hasNonDefaultBranch]
+ () =>
+ getCodeWorkflowSteps({
+ ref,
+ openAiChat,
+ connectActions,
+ statuses,
+ }),
+ [connectActions, openAiChat, ref, statuses]
)
const noCodeSteps: GettingStartedStep[] = useMemo(
- () => [
- {
- key: 'design-db',
- status: tablesCount > 0 ? 'complete' : 'incomplete',
- title: 'Create your first table',
- icon: <Database strokeWidth={1} className="text-foreground-muted" size={16} />,
- image: `${BASE_PATH}/img/getting-started/sample.png`,
- description:
- "To kick off your new project, let's start by creating your very first database table using either the table editor or the AI assistant to shape the structure for you.",
- actions: [
- { label: 'Create a table', href: `/project/${ref}/editor`, variant: 'default' },
- {
- label: 'Do it for me',
- variant: 'default',
- icon: <AiIconAnimation size={14} />,
- onClick: () =>
- openAiChat(
- 'Design my database',
- 'I want to design my database schema. Please propose tables, relationships, and SQL to create them for my app. Ask clarifying questions if needed.'
- ),
- },
- ],
- },
- {
- key: 'add-data',
- status: 'incomplete',
- title: 'Add sample data',
- icon: <Table strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- "Next, let's add some sample data that you can play with once you connect your app, either by inserting rows yourself or letting the AI assistant craft realistic examples.",
- actions: [
- { label: 'Add data', href: `/project/${ref}/editor`, variant: 'default' },
- {
- label: 'Do it for me',
- variant: 'default',
- icon: <AiIconAnimation size={14} />,
- onClick: () =>
- openAiChat(
- 'Generate sample data',
- 'Generate SQL INSERT statements to add realistic sample data to my existing tables. Use safe defaults and avoid overwriting data.'
- ),
- },
- ],
- },
- {
- key: 'add-rls-policies',
- status: 'incomplete',
- title: 'Secure your data with Row Level Security',
- icon: <Shield strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- "Now that you have some data, let's secure it by enabling Row Level Security (row-specific access rules that control who can view or modify records) and creating policies yourself or with help from the AI assistant.",
- actions: [
- {
- label: 'Create a policy',
- href: `/project/${ref}/auth/policies`,
- variant: 'default',
- },
- {
- label: 'Do it for me',
- variant: 'default',
- icon: <AiIconAnimation size={14} />,
- onClick: () =>
- openAiChat(
- 'Generate RLS policies',
- 'Generate RLS policies for my existing tables in the public schema. '
- ),
- },
- ],
- },
- {
- key: 'setup-auth',
- status: 'incomplete',
- title: 'Set up authentication',
- icon: <User strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- "It's time to set up authentication so you can start signing up users, configuring providers and settings from the auth dashboard.",
- actions: [
- {
- label: 'Configure auth',
- href: `/project/${ref}/auth/providers`,
- variant: 'default',
- },
- ],
- },
- {
- key: 'connect-app',
- status: 'incomplete',
- title: 'Connect your application',
- icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'Your project is ready; use the framework selector to preview starter code and launch the Connect flow to wire up your app.',
- actions: connectActions,
- },
- {
- key: 'signup-first-user',
- status: 'incomplete',
- title: 'Sign up your first user',
- icon: <UserPlus strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'Test your authentication by signing up your first user, referencing the docs if you need sample flows or troubleshooting tips.',
- actions: [
- {
- label: 'Read docs',
- href: `${DOCS_URL}/guides/auth`,
- variant: 'default',
- },
- ],
- },
- {
- key: 'upload-file',
- status: 'incomplete',
- title: 'Upload a file',
- icon: <Upload strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- "Let's add file storage to your app by creating a bucket and uploading your first file from the buckets dashboard.",
- actions: [
- { label: 'Buckets', href: `/project/${ref}/storage/buckets`, variant: 'default' },
- ],
- },
- {
- key: 'create-edge-function',
- status: 'incomplete',
- title: 'Add server-side logic',
- icon: <Code strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- "Extend your app's functionality by creating an Edge Function—a lightweight serverless function that executes close to your users—for server-side logic directly from the functions page.",
- actions: [
- {
- label: 'Create a function',
- href: `/project/${ref}/functions/new`,
- variant: 'default',
- },
- ],
- },
- {
- key: 'monitor-progress',
- status: 'incomplete',
- title: "Monitor your project's health",
- icon: <BarChart3 strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- "Keep an eye on your project's performance and usage by setting up custom reports from the reports dashboard.",
- actions: [
- { label: 'Create a report', href: `/project/${ref}/reports`, variant: 'default' },
- ],
- },
- {
- key: 'create-first-branch',
- status: hasNonDefaultBranch ? 'complete' : 'incomplete',
- title: 'Create a branch to test changes',
- icon: <GitBranch strokeWidth={1} className="text-foreground-muted" size={16} />,
- description:
- 'Safely test changes by creating a preview branch before deploying to production, using the branches view to spin one up.',
- actions: [
- { label: 'Create a branch', href: `/project/${ref}/branches`, variant: 'default' },
- ],
- },
- ],
- [tablesCount, ref, openAiChat, connectActions, hasNonDefaultBranch]
+ () =>
+ getNoCodeWorkflowSteps({
+ ref,
+ openAiChat,
+ connectActions,
+ statuses,
+ }),
+ [connectActions, openAiChat, ref, statuses]
)
const steps = workflow === 'code' ? codeSteps : workflow === 'no-code' ? noCodeSteps : []
@@ -519,7 +143,7 @@ export function GettingStartedSection({
className="text-xs gap-2 h-auto"
>
<Table2 size={16} strokeWidth={1.5} />
- Code
+ No-code
</ToggleGroupItem>
<ToggleGroupItem
value="code"
@@ -528,7 +152,7 @@ export function GettingStartedSection({
className="text-xs gap-2 h-auto"
>
<Code size={16} strokeWidth={1.5} />
- No-code
+ Code
</ToggleGroupItem>
</ToggleGroup>
<Button
diff --git a/apps/studio/components/interfaces/HomeNew/GettingStarted/useGettingStartedProgress.ts b/apps/studio/components/interfaces/HomeNew/GettingStarted/useGettingStartedProgress.ts
new file mode 100644
index 00000000000..51bef8978cc
--- /dev/null
+++ b/apps/studio/components/interfaces/HomeNew/GettingStarted/useGettingStartedProgress.ts
@@ -0,0 +1,147 @@
+import { useMemo } from 'react'
+
+import { useProjectLogStatsQuery } from 'data/analytics/project-log-stats-query'
+import { useAuthConfigQuery } from 'data/auth/auth-config-query'
+import { useUsersCountQuery } from 'data/auth/users-count-query'
+import { useContentInfiniteQuery } from 'data/content/content-infinite-query'
+import { useDatabasePoliciesQuery } from 'data/database-policies/database-policies-query'
+import { useMigrationsQuery } from 'data/database/migrations-query'
+import { useEdgeFunctionsQuery } from 'data/edge-functions/edge-functions-query'
+import { useGitHubConnectionsQuery } from 'data/integrations/github-connections-query'
+import { useTablesQuery } from 'data/tables/tables-query'
+import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import { PROJECT_STATUS } from 'lib/constants'
+
+type GettingStartedStatuses = {
+ hasTables: boolean
+ hasCliSetup: boolean
+ hasSampleData: boolean
+ hasRlsPolicies: boolean
+ hasConfiguredAuth: boolean
+ hasAppConnected: boolean
+ hasFirstUser: boolean
+ hasStorageObjects: boolean
+ hasEdgeFunctions: boolean
+ hasReports: boolean
+ hasGitHubConnection: boolean
+}
+
+export const useGettingStartedProgress = (): GettingStartedStatuses => {
+ const { data: project } = useSelectedProjectQuery()
+ const { data: organization } = useSelectedOrganizationQuery()
+
+ const projectRef = project?.ref
+ const connectionString = project?.connectionString
+ const isProjectActive = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
+
+ const { data: tablesData } = useTablesQuery(
+ { projectRef, connectionString, schema: 'public' },
+ { enabled: !!projectRef && isProjectActive }
+ )
+
+ const { data: storageTablesData } = useTablesQuery(
+ { projectRef, connectionString, schema: 'storage' },
+ { enabled: !!projectRef && isProjectActive }
+ )
+
+ const { data: policiesData } = useDatabasePoliciesQuery(
+ { projectRef, connectionString, schema: 'public' },
+ { enabled: !!projectRef && !!connectionString && isProjectActive }
+ )
+
+ const { data: authConfig } = useAuthConfigQuery(
+ { projectRef },
+ { enabled: !!projectRef && isProjectActive }
+ )
+
+ const { data: usersCountData } = useUsersCountQuery(
+ { projectRef, connectionString },
+ { enabled: !!projectRef && !!connectionString && isProjectActive }
+ )
+
+ const { data: edgeFunctionsData } = useEdgeFunctionsQuery(
+ { projectRef },
+ { enabled: !!projectRef && isProjectActive }
+ )
+
+ const { data: reportsData } = useContentInfiniteQuery(
+ { projectRef, type: 'report', limit: 1 },
+ { enabled: !!projectRef && isProjectActive }
+ )
+
+ const { data: migrationsData } = useMigrationsQuery(
+ { projectRef, connectionString },
+ { enabled: !!projectRef && !!connectionString && isProjectActive }
+ )
+
+ const { data: usageStatsData } = useProjectLogStatsQuery(
+ { projectRef, interval: '1day' },
+ { enabled: !!projectRef && isProjectActive }
+ )
+
+ const { data: githubConnections } = useGitHubConnectionsQuery(
+ { organizationId: organization?.id },
+ { enabled: !!projectRef && !!organization?.id }
+ )
+
+ const statuses = useMemo<GettingStartedStatuses>(() => {
+ const hasTables = (tablesData?.length ?? 0) > 0
+ const hasCliSetup = (migrationsData?.length ?? 0) > 0
+ const hasSampleData = (tablesData ?? []).some(
+ (table) => Number(table?.live_rows_estimate ?? 0) > 0
+ )
+ const hasRlsPolicies = (policiesData?.length ?? 0) > 0
+ const allowSignupsEnabled = authConfig ? !authConfig.DISABLE_SIGNUP : false
+ const emailProviderEnabled = !!authConfig?.EXTERNAL_EMAIL_ENABLED
+ const hasConfiguredAuth = allowSignupsEnabled && emailProviderEnabled
+ const hasFirstUser = !!usersCountData && !usersCountData.is_estimate && usersCountData.count > 0
+ const hasStorageObjects = (storageTablesData ?? []).some(
+ (table) => table.name === 'objects' && Number(table?.live_rows_estimate ?? 0) > 0
+ )
+ const hasEdgeFunctions = (edgeFunctionsData?.length ?? 0) > 0
+ const hasReports = (reportsData?.pages?.[0]?.content?.length ?? 0) > 0
+ const hasGitHubConnection =
+ githubConnections?.some((connection) => connection.project.ref === projectRef) ?? false
+ const hasAppConnected =
+ usageStatsData?.result?.some((row) => {
+ const totals = [
+ row.total_auth_requests,
+ row.total_storage_requests,
+ row.total_rest_requests,
+ row.total_realtime_requests,
+ ]
+ return totals.some((value) => (value ?? 0) > 0)
+ }) ?? false
+
+ return {
+ hasTables,
+ hasCliSetup,
+ hasSampleData,
+ hasRlsPolicies,
+ hasConfiguredAuth,
+ hasAppConnected,
+ hasFirstUser,
+ hasStorageObjects,
+ hasEdgeFunctions,
+ hasReports,
+ hasGitHubConnection,
+ }
+ }, [
+ authConfig,
+ edgeFunctionsData,
+ githubConnections,
+ migrationsData,
+ policiesData,
+ reportsData,
+ storageTablesData,
+ tablesData,
+ usageStatsData,
+ usersCountData,
+ projectRef,
+ ])
+
+ return statuses
+}
+
+export type { GettingStartedStatuses }
diff --git a/apps/studio/components/interfaces/HomeNew/Home.tsx b/apps/studio/components/interfaces/HomeNew/Home.tsx
index 4e2baa81de5..9e5632507ed 100644
--- a/apps/studio/components/interfaces/HomeNew/Home.tsx
+++ b/apps/studio/components/interfaces/HomeNew/Home.tsx
@@ -6,49 +6,29 @@ import { IS_PLATFORM, useParams } from 'common'
import { SortableSection } from 'components/interfaces/HomeNew/SortableSection'
import { TopSection } from 'components/interfaces/HomeNew/TopSection'
import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold'
-import { useBranchesQuery } from 'data/branches/branches-query'
-import { useProjectDetailQuery } from 'data/projects/project-detail-query'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useLocalStorage } from 'hooks/misc/useLocalStorage'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
-import { useIsOrioleDb, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { PROJECT_STATUS } from 'lib/constants'
import { useAppStateSnapshot } from 'state/app-state'
+import { cn } from 'ui'
import { AdvisorSection } from './AdvisorSection'
import { CustomReportSection } from './CustomReportSection'
-import {
- GettingStartedSection,
- type GettingStartedState,
-} from './GettingStarted/GettingStartedSection'
+import { type GettingStartedState } from './GettingStarted/GettingStarted.types'
+import { GettingStartedSection } from './GettingStarted/GettingStartedSection'
import { ProjectUsageSection } from './ProjectUsageSection'
export const HomeV2 = () => {
- const { ref, enableBranching } = useParams()
- const isOrioleDb = useIsOrioleDb()
+ const { enableBranching } = useParams()
const snap = useAppStateSnapshot()
const { data: project } = useSelectedProjectQuery()
const { data: organization } = useSelectedOrganizationQuery()
- const { data: parentProject } = useProjectDetailQuery({ ref: project?.parent_project_ref })
const { mutate: sendEvent } = useSendEventMutation()
const hasShownEnableBranchingModalRef = useRef(false)
const isPaused = project?.status === PROJECT_STATUS.INACTIVE
- 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
-
- const projectName =
- currentBranch && !isMainBranch
- ? currentBranch.name
- : project?.name
- ? project.name
- : 'Welcome to your project'
-
const [sectionOrder, setSectionOrder] = useLocalStorage<string[]>(
`home-section-order-${project?.ref || 'default'}`,
['getting-started', 'usage', 'advisor', 'custom-report']
@@ -96,19 +76,13 @@ export const HomeV2 = () => {
}, [enableBranching, snap])
return (
- <div className="w-full">
- <ScaffoldContainer size="large">
- <ScaffoldSection isFullWidth className="pt-16 pb-0">
- <TopSection
- projectName={projectName}
- isMainBranch={isMainBranch}
- parentProject={parentProject}
- isOrioleDb={!!isOrioleDb}
- project={project}
- organization={organization}
- projectRef={ref}
- isPaused={isPaused}
- />
+ <div className="w-full h-full">
+ <ScaffoldContainer size="large" className={cn(isPaused && 'h-full')}>
+ <ScaffoldSection
+ isFullWidth
+ className={cn(isPaused ? 'h-full flex justify-center !p-0' : 'pt-16 pb-0')}
+ >
+ <TopSection />
</ScaffoldSection>
</ScaffoldContainer>
diff --git a/apps/studio/components/interfaces/HomeNew/SnippetDropdown.tsx b/apps/studio/components/interfaces/HomeNew/SnippetDropdown.tsx
index 70b475dc949..0f46fe195f4 100644
--- a/apps/studio/components/interfaces/HomeNew/SnippetDropdown.tsx
+++ b/apps/studio/components/interfaces/HomeNew/SnippetDropdown.tsx
@@ -1,4 +1,7 @@
-import { useIntersectionObserver } from '@uidotdev/usehooks'
+import { useDebounce, useIntersectionObserver } from '@uidotdev/usehooks'
+import { Plus } from 'lucide-react'
+import Link from 'next/link'
+import { useRouter } from 'next/router'
import { ReactNode, useEffect, useMemo, useRef, useState } from 'react'
import { useContentInfiniteQuery } from 'data/content/content-infinite-query'
@@ -6,7 +9,6 @@ import type { Content } from 'data/content/content-query'
import { SNIPPET_PAGE_LIMIT } from 'data/content/sql-folders-query'
import {
Command_Shadcn_,
- CommandEmpty_Shadcn_,
CommandGroup_Shadcn_,
CommandInput_Shadcn_,
CommandItem_Shadcn_,
@@ -14,7 +16,9 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuTrigger,
+ ScrollArea,
} from 'ui'
+import ShimmeringLoader from 'ui-patterns/ShimmeringLoader'
type SnippetDropdownProps = {
projectRef?: string
@@ -37,16 +41,20 @@ export const SnippetDropdown = ({
autoFocus = false,
onSelect,
}: SnippetDropdownProps) => {
- const [snippetSearch, setSnippetSearch] = useState('')
+ const router = useRouter()
const scrollRootRef = useRef<HTMLDivElement | null>(null)
+ const [open, setOpen] = useState(false)
+ const [search, setSearch] = useState('')
+ const debouncedSearch = useDebounce(search, 500)
+
const { data, isLoading, hasNextPage, fetchNextPage, isFetchingNextPage } =
useContentInfiniteQuery(
{
projectRef,
type: 'sql',
limit: SNIPPET_PAGE_LIMIT,
- name: snippetSearch.length === 0 ? undefined : snippetSearch,
+ name: search.length === 0 ? search : debouncedSearch,
},
{ keepPreviousData: true }
)
@@ -69,7 +77,7 @@ export const SnippetDropdown = ({
}, [entry?.isIntersecting, hasNextPage, isFetchingNextPage, isLoading, fetchNextPage])
return (
- <DropdownMenu>
+ <DropdownMenu open={open} onOpenChange={setOpen}>
<DropdownMenuTrigger asChild>{trigger}</DropdownMenuTrigger>
<DropdownMenuContent
side={side}
@@ -78,27 +86,62 @@ export const SnippetDropdown = ({
>
<Command_Shadcn_ shouldFilter={false}>
<CommandInput_Shadcn_
+ showResetIcon
autoFocus={autoFocus}
placeholder="Search snippets..."
- value={snippetSearch}
- onValueChange={setSnippetSearch}
+ value={search}
+ onValueChange={setSearch}
+ handleReset={() => setSearch('')}
/>
<CommandList_Shadcn_ ref={scrollRootRef}>
{isLoading ? (
- <CommandEmpty_Shadcn_>Loading...</CommandEmpty_Shadcn_>
- ) : snippets.length === 0 ? (
- <CommandEmpty_Shadcn_>No snippets found</CommandEmpty_Shadcn_>
- ) : null}
+ <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_>
- {snippets.map((snippet) => (
- <CommandItem_Shadcn_
- key={snippet.id}
- onSelect={() => onSelect({ id: snippet.id, name: snippet.name })}
+ <CommandItem_Shadcn_
+ className="cursor-pointer w-full"
+ onSelect={() => {
+ setOpen(false)
+ router.push(`/project/${projectRef}/sql/new`)
+ }}
+ onClick={() => setOpen(false)}
+ >
+ <Link
+ href={`/project/${projectRef}/sql/new`}
+ onClick={() => {
+ setOpen(false)
+ }}
+ className="w-full flex items-center gap-2"
>
- {snippet.name}
- </CommandItem_Shadcn_>
- ))}
- <div ref={sentinelRef} className="h-1" />
+ <Plus size={14} strokeWidth={1.5} />
+ <p>Create a report block with SQL</p>
+ </Link>
+ </CommandItem_Shadcn_>
</CommandGroup_Shadcn_>
</CommandList_Shadcn_>
</Command_Shadcn_>
diff --git a/apps/studio/components/interfaces/HomeNew/TopSection.tsx b/apps/studio/components/interfaces/HomeNew/TopSection.tsx
index ecdc0167b66..3df5ef0064b 100644
--- a/apps/studio/components/interfaces/HomeNew/TopSection.tsx
+++ b/apps/studio/components/interfaces/HomeNew/TopSection.tsx
@@ -1,35 +1,57 @@
import Link from 'next/link'
+import { ReactFlowProvider } from 'reactflow'
import { ActivityStats } from 'components/interfaces/HomeNew/ActivityStats'
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 { DOCS_URL } from 'lib/constants'
-import { ReactFlowProvider } from 'reactflow'
+import { useBranchesQuery } from 'data/branches/branches-query'
+import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
+import { useIsOrioleDb, useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import { DOCS_URL, PROJECT_STATUS } from 'lib/constants'
import { Badge, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { InstanceConfiguration } from '../Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration'
+import { useProjectDetailQuery } from 'data/projects/project-detail-query'
-interface TopSectionProps {
- projectName: string
- isMainBranch?: boolean
- parentProject?: { ref?: string; name?: string } | null
- isOrioleDb?: boolean
- project: any
- organization: any
- projectRef?: string
- isPaused: boolean
-}
+export const TopSection = () => {
+ const isOrioleDb = useIsOrioleDb()
+ const { data: project } = useSelectedProjectQuery()
+ const { data: organization } = useSelectedOrganizationQuery()
+ const { data: parentProject } = useProjectDetailQuery({ ref: project?.parent_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
+
+ const isPaused = project?.status === PROJECT_STATUS.INACTIVE
+ const projectName =
+ currentBranch && !isMainBranch
+ ? currentBranch.name
+ : project?.name
+ ? project.name
+ : 'Welcome to your project'
+
+ if (isPaused) {
+ return (
+ <div className="w-full">
+ <div className="mb-8">
+ {!isMainBranch && (
+ <Link href={`/project/${parentProject?.ref}`} className="text-sm text-foreground-light">
+ {parentProject?.name}
+ </Link>
+ )}
+ <h1 className="text-3xl">{projectName}</h1>
+ </div>
+ <ProjectPausedState />
+ </div>
+ )
+ }
-export const TopSection = ({
- projectName,
- isMainBranch,
- parentProject,
- isOrioleDb,
- project,
- organization,
- isPaused,
-}: TopSectionProps) => {
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">
@@ -89,7 +111,6 @@ export const TopSection = ({
</div>
</div>
<ProjectUpgradeFailedBanner />
- {isPaused && <ProjectPausedState />}
</div>
)
}
diff --git a/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx b/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx
index 4daecfa61bc..88db43e166b 100644
--- a/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/PausedState/ProjectPausedState.tsx
@@ -139,9 +139,9 @@ export const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {
return (
<>
<div className="space-y-4">
- <div className="w-full mx-auto mb-8 md:mb-16 max-w-7xl">
+ <div className="w-full mx-auto mb-8 md:mb-16">
<div className="flex md:h-[500px] items-center justify-center rounded border border-overlay bg-surface-100 p-4 md:p-8">
- <div className="grid w-[550px] gap-4">
+ <div className="grid max-w-2xl gap-4">
<div className="mx-auto flex max-w-[300px] items-center justify-center space-x-4 lg:space-x-8">
<PauseCircle className="text-foreground-light" size={50} strokeWidth={1.5} />
</div>
diff --git a/packages/ui-patterns/src/Row/index.tsx b/packages/ui-patterns/src/Row/index.tsx
index 76a8922ec87..f609c3cd8e9 100644
--- a/packages/ui-patterns/src/Row/index.tsx
+++ b/packages/ui-patterns/src/Row/index.tsx
@@ -1,10 +1,10 @@
'use client'
+import { ChevronLeft, ChevronRight } from 'lucide-react'
import type React from 'react'
+import type { ReactNode } from 'react'
import { forwardRef, useEffect, useMemo, useRef, useState } from 'react'
import { Button, cn } from 'ui'
-import type { ReactNode } from 'react'
-import { ChevronLeft, ChevronRight } from 'lucide-react'
import { useMeasuredWidth } from './Row.utils'
interface RowProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -40,7 +40,7 @@ export const Row = forwardRef<HTMLDivElement, RowProps>(function Row(
return smCols
}
- const renderColumns = useMemo(
+ const numberOfColumns = useMemo(
() => resolveColumnsForWidth(measuredWidth ?? 0),
[measuredWidth, columns]
)
@@ -49,7 +49,7 @@ export const Row = forwardRef<HTMLDivElement, RowProps>(function Row(
const el = containerRef.current
if (!el) return
const widthLocal = measuredWidth ?? el.getBoundingClientRect().width
- const colsLocal = renderColumns
+ const colsLocal = numberOfColumns
const columnWidth = (widthLocal - (colsLocal - 1) * gap) / colsLocal
const scrollAmount = columnWidth + gap
setScrollPosition((prev) => {
@@ -63,15 +63,17 @@ export const Row = forwardRef<HTMLDivElement, RowProps>(function Row(
const maxScroll = useMemo(() => {
if (measuredWidth == null) return -1
- const colsLocal = renderColumns
+ const colsLocal = numberOfColumns
const columnWidth = (measuredWidth - (colsLocal - 1) * gap) / colsLocal
const totalWidth = childrenArray.length * columnWidth + (childrenArray.length - 1) * gap
return Math.max(0, totalWidth - measuredWidth)
- }, [measuredWidth, renderColumns, childrenArray.length, gap])
+ }, [measuredWidth, numberOfColumns, childrenArray.length, gap])
const canScrollLeft = scrollPosition > 0
const canScrollRight = scrollPosition < maxScroll
+ const hasContentToScroll = childrenArray.length > numberOfColumns
+
const rafIdRef = useRef(0 as number)
const pendingDeltaRef = useRef(0)
@@ -125,7 +127,7 @@ export const Row = forwardRef<HTMLDivElement, RowProps>(function Row(
</Button>
)}
- {showArrows && canScrollRight && (
+ {showArrows && canScrollRight && hasContentToScroll && (
<Button
type="default"
onClick={scrollRight}
@@ -152,7 +154,7 @@ export const Row = forwardRef<HTMLDivElement, RowProps>(function Row(
style={
{
gap: `${gap}px`,
- '--column-width': `calc((100% - ${(renderColumns - 1) * gap}px) / ${renderColumns})`,
+ '--column-width': `calc((100% - ${(numberOfColumns - 1) * gap}px) / ${numberOfColumns})`,
transform: `translateX(-${scrollPosition}px)`,
willChange: 'transform',
} as React.CSSProperties