Skip to content

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

clean: remove old command menu code (#28491)

Charis097e26813045
diff --git a/packages/ui-patterns/Cmdk/APIKeys.tsx b/packages/ui-patterns/Cmdk/APIKeys.tsx
deleted file mode 100644
index 87e117432e1..00000000000
--- a/packages/ui-patterns/Cmdk/APIKeys.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { CommandGroup } from 'cmdk'
-import { useCommandMenu } from './CommandMenuContext'
-import { Badge } from 'ui/src/components/shadcn/ui/badge'
-import { CommandItem, copyToClipboard } from './Command.utils'
-import { IconAlertCircle } from 'ui/src/components/Icon/icons/IconAlertCircle'
-import ChildItem from './ChildItem'
-
-const APIKeys = ({ isSubItem = false }) => {
- const { setIsOpen, project } = useCommandMenu()
- const { apiKeys } = project ?? {}
-
- return (
- <CommandGroup>
- {apiKeys?.anon !== undefined && (
- <ChildItem
- isSubItem={isSubItem}
- onSelect={() => {
- copyToClipboard(apiKeys?.anon ?? '')
- setIsOpen(false)
- }}
- className="space-x-2"
- >
- <p>Copy anonymous key</p>
- <Badge>Public</Badge>
- </ChildItem>
- )}
- {apiKeys?.service !== undefined && (
- <ChildItem
- isSubItem={isSubItem}
- onSelect={() => {
- copyToClipboard(apiKeys?.service ?? '')
- setIsOpen(false)
- }}
- className="space-x-2"
- >
- <p>Copy service key</p>
- <Badge variant="destructive">Secret</Badge>
- </ChildItem>
- )}
- {apiKeys?.anon === undefined && apiKeys?.service === undefined && (
- <CommandItem type="link" className="items-start">
- <IconAlertCircle strokeWidth={1.5} className="text-foreground-light" />
- <div>
- <p>No API keys available</p>
- <p className="text-foreground-lighter">
- You may not have the necessary permissions to view the project's API keys
- </p>
- </div>
- </CommandItem>
- )}
- </CommandGroup>
- )
-}
-
-export default APIKeys
diff --git a/packages/ui-patterns/Cmdk/AiCommand.tsx b/packages/ui-patterns/Cmdk/AiCommand.tsx
deleted file mode 100644
index 3f49cfd288b..00000000000
--- a/packages/ui-patterns/Cmdk/AiCommand.tsx
+++ /dev/null
@@ -1,530 +0,0 @@
-'use client'
-
-import type OpenAI from 'openai'
-import {
- Dispatch,
- SetStateAction,
- useCallback,
- useEffect,
- useReducer,
- useRef,
- useState,
-} from 'react'
-import ReactMarkdown from 'react-markdown'
-import remarkGfm from 'remark-gfm'
-import { SSE } from 'sse.js'
-
-import { isBrowser } from 'common'
-import {
- AiIconAnimation,
- Button,
- cn,
- IconCornerDownLeft,
- IconUser,
- Input,
- markdownComponents,
- StatusIcon,
-} from 'ui'
-import { AiWarning } from './Command.alerts'
-import { AiIconChat } from './Command.icons'
-import { CommandGroup, CommandItem, useAutoInputFocus, useHistoryKeys } from './Command.utils'
-import { useCommandMenu } from './CommandMenuContext'
-
-const questions = [
- 'How do I get started with Supabase?',
- 'How do I run Supabase locally?',
- 'How do I connect to my database?',
- 'How do I run migrations? ',
- 'How do I listen to changes in a table?',
- 'How do I set up authentication?',
-]
-
-export const BASE_PATH = process.env.NEXT_PUBLIC_BASE_PATH ?? ''
-
-export enum MessageRole {
- User = 'user',
- Assistant = 'assistant',
-}
-
-export enum MessageStatus {
- Pending = 'pending',
- InProgress = 'in-progress',
- Complete = 'complete',
-}
-
-export interface Message {
- role: MessageRole
- content: string
- status: MessageStatus
-}
-
-interface NewMessageAction {
- type: 'new'
- message: Message
-}
-
-interface UpdateMessageAction {
- type: 'update'
- index: number
- message: Partial<Message>
-}
-
-interface AppendContentAction {
- type: 'append-content'
- index: number
- content: string
-}
-
-interface ResetAction {
- type: 'reset'
-}
-
-type MessageAction = NewMessageAction | UpdateMessageAction | AppendContentAction | ResetAction
-
-function messageReducer(state: Message[], messageAction: MessageAction) {
- let current = [...state]
- const { type } = messageAction
-
- switch (type) {
- case 'new': {
- const { message } = messageAction
- current.push(message)
- break
- }
- case 'update': {
- const { index, message } = messageAction
- if (current[index]) {
- Object.assign(current[index], message)
- }
- break
- }
- case 'append-content': {
- const { index, content } = messageAction
- if (current[index]) {
- current[index].content += content
- }
- break
- }
- case 'reset': {
- current = []
- break
- }
- default: {
- throw new Error(`Unknown message action '${type}'`)
- }
- }
-
- return current
-}
-
-export interface UseAiChatOptions {
- messageTemplate?: (message: string) => string
- setIsLoading?: Dispatch<SetStateAction<boolean>>
-}
-
-export function useAiChat({
- messageTemplate = (message) => message,
- setIsLoading,
-}: UseAiChatOptions) {
- const eventSourceRef = useRef<SSE>()
-
- const [isResponding, setIsResponding] = useState(false)
- const [hasError, setHasError] = useState(false)
-
- const [currentMessageIndex, setCurrentMessageIndex] = useState(1)
- const [messages, dispatchMessage] = useReducer(messageReducer, [])
-
- const submit = useCallback(
- async (query: string) => {
- dispatchMessage({
- type: 'new',
- message: {
- status: MessageStatus.Complete,
- role: MessageRole.User,
- content: query,
- },
- })
- dispatchMessage({
- type: 'new',
- message: {
- status: MessageStatus.Pending,
- role: MessageRole.Assistant,
- content: '',
- },
- })
- setIsResponding(false)
- setHasError(false)
- setIsLoading?.(true)
-
- const eventSource = new SSE(`${BASE_PATH}/api/ai/docs`, {
- headers: {
- apikey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY ?? '',
- Authorization: `Bearer ${process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY}`,
- 'Content-Type': 'application/json',
- },
- payload: JSON.stringify({
- messages: messages
- .filter(({ status }) => status === MessageStatus.Complete)
- .map(({ role, content }) => ({ role, content }))
- .concat({ role: MessageRole.User, content: messageTemplate(query) }),
- }),
- })
-
- function handleError<T>(err: T) {
- setIsLoading?.(false)
- setIsResponding(false)
- setHasError(true)
- console.error(err)
- }
-
- eventSource.addEventListener('error', handleError)
- eventSource.addEventListener('message', (e: MessageEvent) => {
- try {
- setIsLoading?.(false)
-
- if (e.data === '[DONE]') {
- setIsResponding(false)
- dispatchMessage({
- type: 'update',
- index: currentMessageIndex,
- message: {
- status: MessageStatus.Complete,
- },
- })
- setCurrentMessageIndex((x) => x + 2)
- return
- }
-
- dispatchMessage({
- type: 'update',
- index: currentMessageIndex,
- message: {
- status: MessageStatus.InProgress,
- },
- })
-
- setIsResponding(true)
-
- const completionChunk: OpenAI.Chat.Completions.ChatCompletionChunk = JSON.parse(e.data)
- const [
- {
- delta: { content },
- },
- ] = completionChunk.choices
-
- if (content) {
- dispatchMessage({
- type: 'append-content',
- index: currentMessageIndex,
- content,
- })
- }
- } catch (err) {
- handleError(err)
- }
- })
-
- eventSource.stream()
-
- eventSourceRef.current = eventSource
-
- setIsLoading?.(true)
- },
- [currentMessageIndex, messages, messageTemplate]
- )
-
- function reset() {
- eventSourceRef.current?.close()
- eventSourceRef.current = undefined
- setIsResponding(false)
- setHasError(false)
- dispatchMessage({
- type: 'reset',
- })
- }
-
- return {
- submit,
- reset,
- messages,
- isResponding,
- hasError,
- }
-}
-
-/**
- * Perform a one-off query to AI based on a snapshot of messages
- */
-export function queryAi(messages: Message[], timeout = 0) {
- return new Promise<string>((resolve, reject) => {
- const eventSource = new SSE(`${BASE_PATH}/api/ai/docs`, {
- headers: {
- apikey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY ?? '',
- Authorization: `Bearer ${process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY}`,
- 'Content-Type': 'application/json',
- },
- payload: JSON.stringify({
- messages: messages.map(({ role, content }) => ({ role, content })),
- }),
- })
-
- let timeoutId: number | undefined
-
- function handleError<T>(err: T) {
- if (timeoutId) {
- clearTimeout(timeoutId)
- }
- console.error(err)
- reject(err)
- }
-
- if (timeout > 0) {
- timeoutId = window.setTimeout(() => {
- handleError(new Error('AI query timed out'))
- }, timeout)
- }
-
- let answer = ''
-
- eventSource.addEventListener('error', handleError)
- eventSource.addEventListener('message', (e: MessageEvent) => {
- try {
- if (e.data === '[DONE]') {
- if (timeoutId) {
- clearTimeout(timeoutId)
- }
- resolve(answer)
- return
- }
-
- const completionChunk: OpenAI.Chat.Completions.ChatCompletionChunk = JSON.parse(e.data)
- const [
- {
- delta: { content },
- },
- ] = completionChunk.choices
-
- if (content) {
- answer += content
- }
- } catch (err) {
- handleError(err)
- }
- })
-
- eventSource.stream()
- })
-}
-
-const AiCommand = () => {
- const { isLoading, setIsLoading, search, setSearch } = useCommandMenu()
- const isMobile = isBrowser && window.screen.width <= 640
-
- const { submit, reset, messages, isResponding, hasError } = useAiChat({
- setIsLoading,
- })
-
- /**
- * Disable autofocusing on the input on mobile
- * since it messes up with the dialog height and positioning
- * */
- const inputRef = useAutoInputFocus(!isMobile)
-
- useHistoryKeys({
- enable: !isResponding,
- messages: messages
- .filter(({ role }) => role === MessageRole.User)
- .map(({ content }) => content),
- setPrompt: setSearch,
- })
-
- const handleSubmit = useCallback(
- (message: string) => {
- setSearch('')
- submit(message)
- },
- [submit]
- )
-
- const handleReset = useCallback(() => {
- setSearch('')
- reset()
- }, [reset])
-
- useEffect(() => {
- if (search) {
- handleSubmit(search)
- }
- }, [])
- // Detect an IME composition (so that we can ignore Enter keypress)
- const [isImeComposing, setIsImeComposing] = useState(false)
- const showSubmitButton = !isLoading && !isResponding && search
-
- return (
- <div onClick={(e) => e.stopPropagation()}>
- <div className="absolute z-10 top-[45px] md:top-auto md:bottom-0 w-full bg-background pt-2 md:pt-0 md:pb-2">
- <Input
- className={cn(
- 'bg-alternative rounded mx-3 [&_input]:text-base [&_input]:placeholder:text-sm',
- showSubmitButton && '[&_input]:pr-32 md:[&_input]:pr-40'
- )}
- inputRef={inputRef}
- autoFocus={!isMobile}
- placeholder={
- isLoading || isResponding ? 'Waiting on an answer...' : 'Ask Supabase AI a question...'
- }
- value={search}
- actions={
- <>
- {showSubmitButton ? (
- <Button
- onClick={() => {
- if (!search || isLoading || isResponding || isImeComposing) {
- return
- }
- return handleSubmit(search)
- }}
- className={`flex items-center mr-3 ${search ? 'opacity-100' : 'opacity-0'}`}
- iconRight={
- <div className="hidden md:flex">
- <IconCornerDownLeft size={12} strokeWidth={1.5} />
- </div>
- }
- >
- Submit message
- </Button>
- ) : null}
- </>
- }
- onChange={(e) => {
- if (!isLoading || !isResponding) {
- setSearch(e.target.value)
- }
- }}
- onCompositionStart={() => setIsImeComposing(true)}
- onCompositionEnd={() => setIsImeComposing(false)}
- onKeyDown={(e) => {
- switch (e.key) {
- case 'Enter':
- if (!search || isLoading || isResponding || isImeComposing) {
- return
- }
- return handleSubmit(search)
- default:
- return
- }
- }}
- />
- </div>
- <div className="pt-14 md:pt-0">
- {messages.length > 0 && !hasError && <AiWarning className="mt-2 mx-3 px-3" />}
- <div className={cn('relative py-3')}>
- {!hasError &&
- messages.map((message, index) => {
- switch (message.role) {
- case MessageRole.User:
- return (
- <div key={index} className="flex gap-3 mx-4 [overflow-anchor:none] mb-6">
- <div
- className="
- w-7 h-7 bg-background rounded-full border border-muted flex items-center justify-center text-foreground-lighter first-letter:
- ring-background
- ring-1
- shadow-sm
- "
- >
- <IconUser strokeWidth={1.5} size={16} />
- </div>
- <div className="prose text-foreground-lighter">{message.content}</div>
- </div>
- )
- case MessageRole.Assistant:
- return (
- <div key={index} className="px-4 pb-8 [overflow-anchor:none] mb-[25px]">
- <div className="flex gap-4 [overflow-anchor:none] mb-6">
- <AiIconChat
- loading={
- message.status === MessageStatus.Pending ||
- message.status === MessageStatus.InProgress
- }
- />
- <>
- {message.status === MessageStatus.Pending ? (
- <div className="bg-border-strong h-[21px] w-[13px] mt-1 animate-pulse"></div>
- ) : (
- <ReactMarkdown
- remarkPlugins={[remarkGfm]}
- components={{
- ...markdownComponents,
- a: (props) => (
- <a {...props} target="_blank" rel="noopener noreferrer" />
- ),
- }}
- className="prose dark:prose-dark"
- urlTransform={(href: string) => {
- const supabaseUrl = new URL('https://supabase.com')
- const linkUrl = new URL(href, 'https://supabase.com')
-
- if (linkUrl.origin === supabaseUrl.origin) {
- return linkUrl.toString()
- }
-
- return href
- }}
- >
- {message.content}
- </ReactMarkdown>
- )}
- </>
- </div>
- </div>
- )
- }
- })}
-
- {messages.length === 0 && !hasError && (
- <CommandGroup heading="Examples">
- {questions.map((question) => {
- const key = question.replace(/\s+/g, '_')
- return (
- <CommandItem
- type="command"
- onSelect={() => {
- if (!search) {
- handleSubmit(question)
- }
- }}
- key={key}
- >
- <AiIconAnimation />
- {question}
- </CommandItem>
- )
- })}
- </CommandGroup>
- )}
- {hasError && (
- <div className="p-6 flex flex-col items-center gap-2 mt-4">
- <StatusIcon variant="warning" />
- <div>
- <p className="text-sm text-foreground text-center">
- Sorry, looks like Supabase AI is having a hard time!
- </p>
- <p className="text-sm text-foreground-lighter text-center">
- Please try again in a bit.
- </p>
- </div>
- <Button size="tiny" type="default" onClick={handleReset}>
- Try again?
- </Button>
- </div>
- )}
-
- <div className="[overflow-anchor:auto] h-px w-full"></div>
- </div>
- </div>
- </div>
- )
-}
-
-export default AiCommand
diff --git a/packages/ui-patterns/Cmdk/ChildItem.tsx b/packages/ui-patterns/Cmdk/ChildItem.tsx
deleted file mode 100644
index 53e29cbb68e..00000000000
--- a/packages/ui-patterns/Cmdk/ChildItem.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { useCommandState } from 'cmdk'
-import { CommandItem } from './Command.utils'
-import React from 'react'
-
-export default function ChildItem({ children, isSubItem, ...props }: any) {
- const search = useCommandState((state) => state.search)
- // if search is empty & items is marked as a subItem, don't show it
- // ie: only show these items in search results, not top level
- if (!search && isSubItem) return null
- return <CommandItem {...props}>{children}</CommandItem>
-}
diff --git a/packages/ui-patterns/Cmdk/Command.Badges.tsx b/packages/ui-patterns/Cmdk/Command.Badges.tsx
deleted file mode 100644
index fb1686e6def..00000000000
--- a/packages/ui-patterns/Cmdk/Command.Badges.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Badge } from 'ui'
-import { Microscope } from 'lucide-react'
-
-export const BadgeExperimental = () => {
- return (
- <Badge>
- <Microscope className="!mr-1.5 !w-3.5 !h-3.5" /> Experimental
- </Badge>
- )
-}
diff --git a/packages/ui-patterns/Cmdk/Command.alerts.tsx b/packages/ui-patterns/Cmdk/Command.alerts.tsx
deleted file mode 100644
index 7c11bfd4651..00000000000
--- a/packages/ui-patterns/Cmdk/Command.alerts.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Alert } from 'ui'
-import { Microscope } from 'lucide-react'
-
-export const AiWarning = ({ className }: { className?: string }) => (
- <Alert
- variant="info"
- title="Supabase AI is experimental and may produce incorrect answers."
- className={className}
- icon={<Microscope strokeWidth={1.5} size={18} className="text-foreground-muted" />}
- >
- <p>Always verify the output before executing.</p>
- </Alert>
-)
-
-export const IncludeSchemaAlert = () => (
- <Alert
- variant={'warning'}
- title="Project metadata (tables, columns, and data types) is being shared with OpenAI"
- withIcon
- className="mx-3"
- >
- Start a new conversation to change this configuration
- </Alert>
-)
-
-export const ExcludeSchemaAlert = () => (
- <Alert
- variant={'info'}
- title="Project metadata (tables, columns, and data types) is not being shared with OpenAI"
- withIcon
- className="mx-3"
- >
- Start a new conversation to change this configuration
- </Alert>
-)
diff --git a/packages/ui-patterns/Cmdk/Command.constants.ts b/packages/ui-patterns/Cmdk/Command.constants.ts
deleted file mode 100644
index 0acab15843d..00000000000
--- a/packages/ui-patterns/Cmdk/Command.constants.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-export const COMMAND_ROUTES = {
- AI: 'Supabase AI',
- DOCS_SEARCH: 'Docs Search',
- GENERATE_SQL: 'Generate SQL',
- THEME: 'Theme',
- AI_ASK_ANYTHING: 'Ask anything',
- AI_RLS_POLICY: 'Help me create a RLS policy',
- API_KEYS: 'Project API keys',
-}
-
-type QueryCategory = {
- category: string
- queries: string[]
-}
-
-type SampleQueries = QueryCategory[]
-
-export const SAMPLE_QUERIES: SampleQueries = [
- {
- category: 'Tables',
- queries: [
- 'Create a table that stores a list of cities, and insert 10 rows of sample data into it',
- 'Create tables (with foreign key relationships) for blog posts and comments',
- 'Create tables for employees, reviewers, and employee reviews, with columns for employee ID, reviewer ID, and review text',
- ],
- },
- {
- category: 'Views',
- queries: [
- 'Create a view that shows the total revenue for each customer',
- 'Create a view that shows all orders that were placed in the last week',
- 'Create a view that shows all products that are currently out of stock',
- 'Create a materialized view that shows the customer_orders table the total value of orders in a month',
- ],
- },
- {
- category: 'Indexes',
- queries: [
- 'Create an index on the primary key column of my orders table',
- 'Create a partial index on the orders table:',
- 'Create an index on the customer_id column of the customer_orders table',
- ],
- },
- {
- category: 'Select',
- queries: [
- 'Retrieve a list of employees from the employees table who have a salary greater than $50,000',
- 'Retrieve a list of all employees with the title "Manager" from the employees table',
- 'Retrieve a list of all employees hired in the last 6 months',
- 'Retrieve the department and average salary of each department from the employees table, group by department',
- ],
- },
- {
- category: 'Triggers',
- queries: [
- 'Create a trigger that updates the updated_at column on the orders table with the current time when the row of the orders table is updated',
- 'Create a trigger to add a new user to the users table when someone new registers',
- 'Create a trigger to send an email whenever there is an insert in the orders table',
- 'Create a trigger to delete all orders placed by a customer when that customer is deleted from the customers table',
- ],
- },
- {
- category: 'Row Level Security',
- queries: [
- 'Create an RLS policy that grants only authenticated access to the profiles table',
- 'Create an RLS policy that grants SELECT access to the sales_rep role for the customers table, but denies access to all other roles',
- "Create an RLS policy that grants INSERT access access to the manager role for the employees table, but only for rows where the employee's department_id matches a list of departments that the manager is responsible for",
- ],
- },
- {
- category: 'Functions',
- queries: [
- "Create a function to add a new entry to a user's table when a new user signs up",
- 'Create an a function to calculate the average price of a product in a given category',
- 'Create a function to insert a new order and update the inventory for the ordered products',
- 'Create a function to calculate the total sales for a product given an id',
- ],
- },
-]
diff --git a/packages/ui-patterns/Cmdk/Command.icons.tsx b/packages/ui-patterns/Cmdk/Command.icons.tsx
deleted file mode 100644
index e9a81ab6608..00000000000
--- a/packages/ui-patterns/Cmdk/Command.icons.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { AiIconAnimation } from 'ui/src/layout/ai-icon-animation/ai-icon-animation'
-
-interface AiIconProps {
- className?: string
-}
-
-export const AiIcon = ({ className }: AiIconProps) => (
- <AiIconAnimation className={className} allowHoverEffect />
-)
-
-export const AiIconChat = ({ loading = false }) => (
- <AiIconAnimation className="ml-0.5" loading={loading} allowHoverEffect />
-)
diff --git a/packages/ui-patterns/Cmdk/Command.types.ts b/packages/ui-patterns/Cmdk/Command.types.ts
deleted file mode 100644
index 476ebc3c504..00000000000
--- a/packages/ui-patterns/Cmdk/Command.types.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-
-export interface NavItem {
- label: string;
- icon: string;
- url: string;
- sites: Site[];
- subItems?: NavItem[];
-}
-
-export type Site = "docs" | "dashboard";
-
-export interface NavItems {
- navItems: NavItem[];
-}
diff --git a/packages/ui-patterns/Cmdk/Command.utils.tsx b/packages/ui-patterns/Cmdk/Command.utils.tsx
deleted file mode 100644
index ee561c3cb89..00000000000
--- a/packages/ui-patterns/Cmdk/Command.utils.tsx
+++ /dev/null
@@ -1,463 +0,0 @@
-import * as React from 'react'
-import { Command as CommandPrimitive } from 'cmdk'
-import { ErrorBoundary } from 'react-error-boundary'
-
-import { cn } from 'ui/src/lib/utils'
-
-import { AlertTriangle } from 'lucide-react'
-import { DetailedHTMLProps, HTMLAttributes, KeyboardEventHandler } from 'react'
-import { Dialog, DialogContent } from 'ui'
-import { Button } from 'ui/src/components/Button'
-import { LoadingLine } from 'ui/src/components/LoadingLine/LoadingLine'
-import { useCommandMenu } from './CommandMenuContext'
-import { useBreakpoint } from 'common'
-
-type CommandPrimitiveElement = React.ElementRef<typeof CommandPrimitive>
-type CommandPrimitiveProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive>
-
-export const copyToClipboard = (str: string, callback = () => {}) => {
- const focused = window.document.hasFocus()
- if (focused) {
- window.navigator?.clipboard?.writeText(str).then(callback)
- } else {
- console.warn('Unable to copy to clipboard')
- }
-}
-
-export const Command = React.forwardRef<CommandPrimitiveElement, CommandPrimitiveProps>(
- ({ className, ...props }, ref) => (
- <CommandPrimitive
- ref={ref}
- className={cn('flex h-full w-full flex-col overflow-hidden', className)}
- {...props}
- />
- )
-)
-
-Command.displayName = CommandPrimitive.displayName
-
-export function CommandError({ resetErrorBoundary }: { resetErrorBoundary: () => void }) {
- return (
- <div className={cn('min-h-64', 'flex items-center justify-center')}>
- <div className="p-10 flex flex-col items-center gap-6 mt-4">
- <AlertTriangle strokeWidth={1.5} size={40} />
- <p className="text-lg text-center">
- Sorry, looks like we&apos;re having some issues with the command menu!
- </p>
- <p className="text-sm text-center">Please try again in a bit.</p>
- <Button size="tiny" type="secondary" onClick={resetErrorBoundary}>
- Try again?
- </Button>
- </div>
- </div>
- )
-}
-
-interface CommandDialogProps extends React.ComponentProps<typeof Dialog> {
- onKeyDown?: KeyboardEventHandler<HTMLDivElement>
- page?: number | string
- visible?: boolean
- setIsOpen: (open: boolean) => void
-}
-
-type CommandPrimitiveDialogElement = React.ElementRef<typeof CommandPrimitive.Dialog>
-
-export const CommandDialog = React.forwardRef<CommandPrimitiveDialogElement, CommandDialogProps>(
- ({ children, onKeyDown, page, setIsOpen, ...props }: CommandDialogProps, ref) => {
- const isOpen = props.visible || props.open
- const isMobile = useBreakpoint()
-
- return (
- <Dialog {...props} open={isOpen} onOpenChange={setIsOpen}>
- <DialogContent
- ref={ref}
- forceMount
- onOpenAutoFocus={(e) => isMobile && e.preventDefault()}
- onInteractOutside={(e) => {
- // Only hide menu when clicking outside, not focusing outside
- // Prevents Firefox dropdown issue that immediately closes menu after opening
- if (e.type === 'dismissableLayer.pointerDownOutside') {
- setIsOpen(!open)
- }
- }}
- hideClose
- size="xlarge"
- dialogOverlayProps={{
- className: cn('overflow-hidden flex data-closed:delay-100'),
- }}
- className={cn(
- 'relative my-0 mx-auto rounded-t-lg overflow-y-scroll',
- 'h-[85dvh] mt-[15vh] md:max-h-[500px] md:mt-0 left-0 bottom-0 md:bottom-auto',
- 'place-self-start md:place-self-auto',
- isOpen && '!animate-in !slide-in-from-bottom !duration-300',
- 'data-[state=closed]:!animate-out data-[state=closed]:!slide-out-to-bottom',
- 'md:data-[state=open]:!animate-in md:data-[state=closed]:!animate-out',
- 'md:data-[state=closed]:!zoom-out-95 md:data-[state=open]:!zoom-in-95',
- 'md:data-[state=closed]:!slide-out-to-left-[0%] md:data-[state=closed]:!slide-out-to-top-[0%]',
- 'md:data-[state=open]:!slide-in-from-left-[0%] md:data-[state=open]:!slide-in-from-top-[0%]'
- )}
- >
- <ErrorBoundary FallbackComponent={CommandError}>
- <Command
- className={cn(
- '[&_[cmdk-group]]:px-2 [&_[cmdk-group]]:!bg-transparent [&_[cmdk-group-heading]]:!bg-transparent [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-border-stronger [&_[cmdk-input]]:h-12',
- '[&_[cmdk-item]_svg]:h-5',
- '[&_[cmdk-item]_svg]:w-5',
- '[&_[cmdk-input-wrapper]_svg]:h-5',
- '[&_[cmdk-input-wrapper]_svg]:w-5',
- '[&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0'
- )}
- >
- {children}
- </Command>
- </ErrorBoundary>
- </DialogContent>
- </Dialog>
- )
- }
-)
-
-CommandDialog.displayName = 'CommandDialog'
-
-type CommandPrimitiveInputElement = React.ElementRef<typeof CommandPrimitive.Input>
-type CommandPrimitiveInputProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
-
-export const CommandInput = React.forwardRef<
- CommandPrimitiveInputElement,
- CommandPrimitiveInputProps
->(({ className, value, onValueChange, ...props }, ref) => {
- const { isLoading } = useCommandMenu()
-
- return (
- <div className="flex flex-col items-center" cmdk-input-wrapper="">
- <CommandPrimitive.Input
- value={value}
- onValueChange={onValueChange}
- ref={ref}
- className={cn(
- 'flex h-11 w-full rounded-md bg-transparent px-4 py-7 outline-none',
- 'focus:shadow-none focus:ring-transparent',
- 'text-foreground-light placeholder:text-foreground-muted disabled:cursor-not-allowed disabled:opacity-50 border-0',
- className
- )}
- {...props}
- />
- <LoadingLine loading={isLoading} />
- </div>
- )
-})
-
-CommandInput.displayName = CommandPrimitive.Input.displayName
-
-type CommandPrimitiveListElement = React.ElementRef<typeof CommandPrimitive.List>
-type CommandPrimitiveListProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
-
-export const CommandList = React.forwardRef<CommandPrimitiveListElement, CommandPrimitiveListProps>(
- ({ className, ...props }, ref) => (
- <CommandPrimitive.List
- ref={ref}
- className={cn('overflow-y-auto overflow-x-hidden bg-transparent', className)}
- {...props}
- />
- )
-)
-
-CommandList.displayName = CommandPrimitive.List.displayName
-
-type CommandPrimitiveEmptyElement = React.ElementRef<typeof CommandPrimitive.Empty>
-type CommandPrimitiveEmptyProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
-
-export const CommandEmpty = React.forwardRef<
- CommandPrimitiveEmptyElement,
- CommandPrimitiveEmptyProps
->((props, ref) => (
- <CommandPrimitive.Empty
- ref={ref}
- className="py-6 text-center text-sm text-foreground-muted"
- {...props}
- />
-))
-
-CommandEmpty.displayName = CommandPrimitive.Empty.displayName
-
-type CommandPrimitiveGroupElement = React.ElementRef<typeof CommandPrimitive.Group>
-type CommandPrimitiveGroupProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
-
-export const CommandGroup = React.forwardRef<
- CommandPrimitiveGroupElement,
- CommandPrimitiveGroupProps
->(({ className, ...props }, ref) => (
- <CommandPrimitive.Group
- ref={ref}
- className={cn(
- 'overflow-hidden py-3 px-2 text-foreground-muted [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pb-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-foreground-muted',
- className
- )}
- {...props}
- />
-))
-
-CommandGroup.displayName = CommandPrimitive.Group.displayName
-
-type CommandPrimitiveSeparatorElement = React.ElementRef<typeof CommandPrimitive.Separator>
-type CommandPrimitiveSeparatorProps = React.ComponentPropsWithoutRef<
- typeof CommandPrimitive.Separator
->
-
-export const CommandSeparator = React.forwardRef<
- CommandPrimitiveSeparatorElement,
- CommandPrimitiveSeparatorProps
->(({ className, ...props }, ref) => (
- <CommandPrimitive.Separator
- ref={ref}
- className={cn(
- `h-px
- w-full
- bg-border
- `,
- className
- )}
- {...props}
- />
-))
-
-CommandSeparator.displayName = CommandPrimitive.Separator.displayName
-
-type CommandPrimitiveItemElement = React.ElementRef<typeof CommandPrimitive.Item>
-type CommandPrimitiveItemProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
-
-export interface CommandItemProps extends CommandPrimitiveItemProps {
- type: 'link' | 'block-link' | 'command'
- badge?: React.ReactNode
-}
-
-export const CommandItem = React.forwardRef<CommandPrimitiveItemElement, CommandItemProps>(
- ({ className, type, children, badge, ...props }, ref) => (
- <CommandPrimitive.Item
- ref={ref}
- className={cn(
- 'cursor-default',
- 'select-none',
- 'items-center',
- 'rounded-md',
- 'text-sm',
- 'group',
- 'py-3',
- 'text-foreground-light',
- 'relative',
- 'flex',
- type === 'block-link'
- ? `
- bg-surface-200 dark:bg-surface-100
- px-5
- transition-all
- outline-none
- aria-selected:border-foreground-muted
- aria-selected:bg-selection
- dark:aria-selected:bg-selection
- aria-selected:shadow-sm
- data-[disabled]:pointer-events-none data-[disabled]:opacity-50`
- : type === 'link'
- ? `
- px-2
- transition-all
- outline-none
- aria-selected:bg-selection/90
- data-[disabled]:pointer-events-none data-[disabled]:opacity-50`
- : `
- px-2
- aria-selected:bg-selection/80
- aria-selected:backdrop-filter
- aria-selected:backdrop-blur-md
- data-[disabled]:pointer-events-none
- data-[disabled]:opacity-50
- `,
- className
- )}
- {...props}
- >
- <div className="w-full flex flex-row justify-between items-center">
- <div className="flex flex-row gap-2 flex-grow items-center">{children}</div>
- {badge}
- </div>
- </CommandPrimitive.Item>
- )
-)
-
-CommandItem.displayName = CommandPrimitive.Item.displayName
-
-export const CommandItemStale = React.forwardRef<CommandPrimitiveItemElement, CommandItemProps>(
- ({ className, ...props }, ref) => (
- <CommandPrimitive.Item
- ref={ref}
- className={cn(
- 'text-foreground-light relative flex cursor-default select-none items-center rounded-md py-1.5 px-2 text-sm outline-none aria-selected:bg-overlay-selection data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
- className
- )}
- {...props}
- />
- )
-)
-
-CommandItemStale.displayName = 'CommandItemStale'
-
-interface CommandShortcutProps {
- className?: string
- children?: React.ReactNode
- onClick?: () => void
- type?: 'default' | 'breadcrumb'
-}
-
-export const CommandShortcut = ({
- className,
- children,
- onClick,
- type = 'default',
-}: CommandShortcutProps) => {
- return (
- <button
- onClick={onClick}
- className={cn(
- 'cursor-default px-1.5 py-0.5 rounded text-xs [&:not(:last-child)]:hover:cursor-pointer',
- 'justify-end',
- type === 'breadcrumb'
- ? 'text-foreground-muted'
- : 'bg-overlay-hover text-foreground-muted [&:not(:last-child)]:hover:bg-selection last:bg-selection last:text-foreground-muted',
- className
- )}
- >
- {children}
- </button>
- )
-}
-
-CommandShortcut.displayName = 'CommandShortcut'
-
-export const CommandLabel = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
- return <span {...props} className={cn('grow', className)} />
-}
-
-CommandShortcut.displayName = 'CommandLabel'
-
-export interface TextHighlighterProps
- extends DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
- text: string
- query: string
-}
-
-export const TextHighlighter = ({ text, query, ...props }: TextHighlighterProps) => {
- // Wrap all instances of `query` in a span to make them bold
- const elements = text.split(query).flatMap((part, index, parts) => {
- const returnValue = [<>{part}</>]
-
- // Add back the wrapped `query` (if it's not the last element)
- if (index !== parts.length - 1) {
- returnValue.push(<span className="text-foreground">{query}</span>)
- }
-
- return returnValue
- })
-
- return <span {...props}>{elements}</span>
-}
-
-TextHighlighter.displayName = 'TextHighlighter'
-
-export interface UseHistoryKeysOptions {
- enable: boolean
- messages: string[]
- setPrompt: (prompt: string) => void
-}
-
-/**
- * Enables a shell-style message history when hitting
- * up/down on the keyboard
- */
-export function useHistoryKeys({ enable, messages, setPrompt }: UseHistoryKeysOptions) {
- // Message index when hitting up/down on the keyboard (shell style)
- const [, setMessageSelectionIndex] = React.useState(0)
-
- React.useEffect(() => {
- if (enable) {
- return
- }
-
- // Note: intentionally setting index to 1 greater than max index
- setMessageSelectionIndex(messages.length)
- }, [messages, enable])
-
- React.useEffect(() => {
- function onKeyDown(e: KeyboardEvent) {
- switch (e.key) {
- case 'ArrowUp':
- setMessageSelectionIndex((index) => {
- const newIndex = Math.max(index - 1, 0)
- const newMessage = messages[newIndex]
- if (newMessage) {
- setPrompt(newMessage)
- }
- return newIndex
- })
- return
- case 'ArrowDown':
- setMessageSelectionIndex((index) => {
- const newIndex = Math.min(index + 1, messages.length)
- const newMessage = messages[newIndex]
- if (newMessage) {
- setPrompt(newMessage)
- }
- return newIndex
- })
- return
- default:
- return
- }
- }
-
- window.addEventListener('keydown', onKeyDown)
-
- return () => {
- window.removeEventListener('keydown', onKeyDown)
- }
- }, [messages])
-}
-
-/**
- * Automatically focuses an input on key press
- * and on load (after the call stack)
- *
- * @returns An input ref for the input to focus
- */
-export function useAutoInputFocus(isEnabled: boolean = true) {
- const [input, setInput] = React.useState<HTMLInputElement>()
-
- // Use a callback-style ref to access the element when it mounts
- const inputRef = React.useCallback((inputElement: HTMLInputElement) => {
- if (isEnabled && inputElement) {
- setInput(inputElement)
-
- // We need to delay the focus until the end of the call stack
- // due to order of operations
- setTimeout(() => {
- inputElement.focus()
- }, 0)
- }
- }, [])
-
- // Focus the input when typing from anywhere
- React.useEffect(() => {
- function onKeyDown(e: KeyboardEvent) {
- if (!e.ctrlKey && !e.altKey && !e.metaKey && e.key !== 'Tab') {
- input?.focus()
- }
- }
-
- isEnabled && window.addEventListener('keydown', onKeyDown)
-
- return () => {
- window.removeEventListener('keydown', onKeyDown)
- }
- }, [input])
-
- return inputRef
-}
diff --git a/packages/ui-patterns/Cmdk/CommandMenu.tsx b/packages/ui-patterns/Cmdk/CommandMenu.tsx
deleted file mode 100644
index 63a09ff37a5..00000000000
--- a/packages/ui-patterns/Cmdk/CommandMenu.tsx
+++ /dev/null
@@ -1,355 +0,0 @@
-'use client'
-
-import { useParams } from 'common'
-import { useRouter } from 'next/navigation'
-import * as React from 'react'
-
-import { IconArrowRight } from 'ui/src/components/Icon/icons/IconArrowRight'
-import { IconBook } from 'ui/src/components/Icon/icons/IconBook'
-import { IconColumns } from 'ui/src/components/Icon/icons/IconColumns'
-import { IconHome } from 'ui/src/components/Icon/icons/IconHome'
-import { IconInbox } from 'ui/src/components/Icon/icons/IconInbox'
-import { IconKey } from 'ui/src/components/Icon/icons/IconKey'
-import { IconLifeBuoy } from 'ui/src/components/Icon/icons/IconLifeBuoy'
-import { IconLink } from 'ui/src/components/Icon/icons/IconLink'
-import { IconMonitor } from 'ui/src/components/Icon/icons/IconMonitor'
-import { IconPhone } from 'ui/src/components/Icon/icons/IconPhone'
-import { IconUser } from 'ui/src/components/Icon/icons/IconUser'
-import { AiIconAnimation } from 'ui/src/layout/ai-icon-animation/ai-icon-animation'
-import APIKeys from './APIKeys'
-import AiCommand from './AiCommand'
-import ChildItem from './ChildItem'
-import { BadgeExperimental } from './Command.Badges'
-import { COMMAND_ROUTES } from './Command.constants'
-import { AiIcon } from './Command.icons'
-import {
- CommandDialog,
- CommandGroup,
- CommandInput,
- CommandItem,
- CommandLabel,
- CommandList,
- copyToClipboard,
-} from './Command.utils'
-import { useCommandMenu } from './CommandMenuContext'
-import CommandMenuShortcuts from './CommandMenuShortcuts'
-import DocsSearch from './DocsSearch'
-import GenerateSQL from './GenerateSQL'
-import SearchableStudioItems from './SearchableStudioItems'
-import ThemeOptions from './ThemeOptions'
-import sharedItems from './utils/shared-nav-items.json'
-import useDragToClose from 'common/hooks/useDragToClose'
-import { DialogHeader } from 'ui'
-
-export const CHAT_ROUTES = [
- COMMAND_ROUTES.AI, // this one is temporary
- COMMAND_ROUTES.AI_ASK_ANYTHING,
- COMMAND_ROUTES.AI_RLS_POLICY,
- COMMAND_ROUTES.GENERATE_SQL,
-]
-
-const iconPicker: { [key: string]: React.ReactNode } = {
- arrowRight: <IconArrowRight />,
- book: <IconBook />,
- inbox: <IconInbox />,
- mobile: <IconPhone />,
- person: <IconUser />,
- services: <IconColumns />,
- contact: <IconMonitor />,
- icon: <IconHome />,
- products: <IconColumns />,
-}
-
-const CommandMenu = () => {
- const router = useRouter()
- const { ref: projectRef } = useParams()
-
- const {
- isOpen,
- setIsOpen,
- search,
- setSearch,
- pages,
- setPages,
- currentPage,
- site,
- project,
- inputRef: commandInputRef,
- } = useCommandMenu()
- const showCommandInput = !currentPage || !CHAT_ROUTES.includes(currentPage)
-
- // This function has been added to prevent the use of double quotes in the search docs input due to an issue with the cmdk-supabase module. This function can be removed when we transition to using cmdk.
- const handleInputChange = (value: string) => {
- const newValue = value.replace(/"/g, '') // Remove double quotes
- setSearch(newValue)
- }
-
- const commandListMaxHeight =
- currentPage === COMMAND_ROUTES.DOCS_SEARCH ||
- currentPage === COMMAND_ROUTES.AI ||
- currentPage === COMMAND_ROUTES.GENERATE_SQL
- ? 'min(600px, 70vh)'
- : 'auto'
-
- const {
- ref: dialogRef,
- handleTouchStart,
- handleTouchMove,
- handleTouchEnd,
- } = useDragToClose({
- onClose: () => setIsOpen(!open),
- })
-
- return (
- <>
- <CommandDialog
- ref={dialogRef}
- setIsOpen={setIsOpen}
- page={currentPage}
- visible={isOpen}
- onOpenChange={() => {
- setIsOpen(!isOpen)
- }}
- >
- <DialogHeader
- className="p-0 gap-0"
- // Close dialog by dragging the header down
- onTouchStart={handleTouchStart}
- onTouchMove={handleTouchMove}
- onTouchEnd={handleTouchEnd}
- >
- {pages.length > 0 && <CommandMenuShortcuts />}
- {showCommandInput && (
- <CommandInput
- ref={commandInputRef}
- placeholder="Type a command or search..."
- value={search}
- onValueChange={handleInputChange}
- />
- )}
- </DialogHeader>
- <CommandList
- style={{
- maxHeight: commandListMaxHeight,
- height:
- currentPage === COMMAND_ROUTES.DOCS_SEARCH ||
- currentPage === COMMAND_ROUTES.AI ||
- currentPage === COMMAND_ROUTES.GENERATE_SQL
- ? commandListMaxHeight
- : 'auto',
- }}
- className="pb-20 md:pb-0"
- >
- {!currentPage && (
- <>
- <CommandGroup heading="Documentation" forceMount={true}>
- <CommandItem
- type="command"
- onSelect={() => setPages([...pages, COMMAND_ROUTES.DOCS_SEARCH])}
- forceMount={true}
- >
- <IconBook />
-
- <span>
- Search the docs
- {search ? (
- <>
- {': '}
- <span className="text-foreground font-semibold">{search}</span>
- </>
- ) : (
- '...'
- )}
- </span>
- </CommandItem>
- <CommandItem
- type="command"
- onSelect={() => {
- setPages([...pages, COMMAND_ROUTES.AI])
- }}
- forceMount={true}
- >
- <AiIconAnimation />
- <span className="text-brand">
- Ask Supabase AI
- {search ? (
- <>
- {': '}
- <span className="text-foreground font-semibold">{search}</span>
- </>
- ) : (
- '...'
- )}
- </span>
- </CommandItem>
- </CommandGroup>
-
- {site === 'docs' && (
- <CommandGroup heading="Quickstarts">
- {sharedItems.quickstarts.map((item) => (
- <CommandItem key={item.url} type="link" onSelect={() => router.push(item.url)}>
- <IconArrowRight className="text-foreground-muted" />
- <CommandLabel>
- Start with <span className="font-bold"> {item.label}</span>
- </CommandLabel>
- </CommandItem>
- ))}
- </CommandGroup>
- )}
-
- {site === 'docs' && (
- <CommandGroup heading="Projects">
- {sharedItems.projectTools.map((item) => (
- <CommandItem
- key={item.url}
- type="link"
- onSelect={() =>
- window.open(`https://supabase.com/dashboard${item.url}`, '_blank')
- }
- >
- <IconArrowRight className="text-foreground-muted" />
- <CommandLabel>
- <span className="font-bold"> {item.label}</span>
- </CommandLabel>
- </CommandItem>
- ))}
- </CommandGroup>
- )}
-
- {site === 'docs' && (
- <CommandGroup heading="Studio tools">
- {sharedItems.tools.map((item) => (
- <CommandItem
- key={item.url}
- type="link"
- onSelect={() =>
- window.open(`https://supabase.com/dashboard${item.url}`, '_blank')
- }
- >
- <IconArrowRight className="text-foreground-muted" />
- <CommandLabel>
- Go to <span className="font-bold"> {item.label}</span>
- </CommandLabel>
- </CommandItem>
- ))}
- </CommandGroup>
- )}
-
- {site === 'studio' && (
- <CommandGroup heading="Experimental">
- <CommandItem
- type="command"
- badge={<BadgeExperimental />}
- onSelect={() => setPages([...pages, COMMAND_ROUTES.GENERATE_SQL])}
- >
- <AiIcon className="text-foreground-light" />
- <CommandLabel>Generate SQL with Supabase AI</CommandLabel>
- </CommandItem>
- </CommandGroup>
- )}
-
- {site === 'studio' && projectRef !== undefined && (
- <CommandGroup heading="Project tools">
- <CommandItem
- type="command"
- onSelect={() => {
- setSearch('')
- setPages([...pages, COMMAND_ROUTES.API_KEYS])
- }}
- >
- <IconKey className="text-foreground-light" />
- <CommandLabel>Get API keys</CommandLabel>
- </CommandItem>
- {project?.apiUrl !== undefined && (
- <ChildItem
- isSubItem={false}
- onSelect={() => {
- copyToClipboard(project?.apiUrl ?? '')
- setIsOpen(false)
- }}
- className="space-x-2"
- >
- <IconLink className="text-foreground-light" />
- <CommandLabel>Copy API URL</CommandLabel>
- </ChildItem>
- )}
- </CommandGroup>
- )}
-
- {site === 'studio' && (
- <CommandGroup heading="Navigate">
- {sharedItems.tools.map((item) => {
- const itemUrl = projectRef ? item.url.replace('_', projectRef) : item.url
-
- return (
- <CommandItem
- key={item.url}
- type="link"
- onSelect={() => {
- router.push(itemUrl)
- setIsOpen(false)
- }}
- >
- <IconArrowRight className="text-foreground-muted" />
- <CommandLabel>
- Go to <span className="font-bold"> {item.label}</span>
- </CommandLabel>
- </CommandItem>
- )
- })}
- </CommandGroup>
- )}
-
- {/* <DashboardTableEditor /> */}
-
- <CommandGroup heading="Support">
- {sharedItems.support.map((item) => (
- <CommandItem key={item.url} type="link" onSelect={() => router.push(item.url)}>
- <IconLifeBuoy className="text-foreground-muted" />
- <CommandLabel>
- Go to <span className="font-bold"> {item.label}</span>
- </CommandLabel>
- </CommandItem>
- ))}
- </CommandGroup>
-
- {site === 'docs' && (
- <CommandGroup heading="General">
- {sharedItems.docsGeneral.map((item) => (
- <CommandItem key={item.url} type="link" onSelect={() => router.push(item.url)}>
- {item?.icon && iconPicker[item.icon]}
- <CommandLabel>{item.label}</CommandLabel>
- </CommandItem>
- ))}
- </CommandGroup>
- )}
-
- <CommandGroup heading="Settings">
- <CommandItem
- type="link"
- onSelect={() => {
- setSearch('')
- setPages([...pages, 'Theme'])
- }}
- >
- <IconMonitor />
- Change theme
- </CommandItem>
- </CommandGroup>
-
- <ThemeOptions isSubItem />
- {site === 'studio' && search && <SearchableStudioItems />}
- </>
- )}
- {currentPage === COMMAND_ROUTES.AI && <AiCommand />}
- {currentPage === COMMAND_ROUTES.DOCS_SEARCH && <DocsSearch />}
- {currentPage === COMMAND_ROUTES.GENERATE_SQL && <GenerateSQL />}
- {currentPage === COMMAND_ROUTES.THEME && <ThemeOptions />}
- {currentPage === COMMAND_ROUTES.API_KEYS && <APIKeys />}
- </CommandList>
- </CommandDialog>
- </>
- )
-}
-
-export default CommandMenu
diff --git a/packages/ui-patterns/Cmdk/CommandMenuContext.tsx b/packages/ui-patterns/Cmdk/CommandMenuContext.tsx
deleted file mode 100644
index 60a41c4d876..00000000000
--- a/packages/ui-patterns/Cmdk/CommandMenuContext.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-'use client'
-import { createContext, useContext } from 'react'
-
-export interface CommandMenuContextValue {
- isOpen: boolean
- setIsOpen: React.Dispatch<React.SetStateAction<boolean>>
- isLoading: boolean
- setIsLoading: React.Dispatch<React.SetStateAction<boolean>>
- search: string
- setSearch: React.Dispatch<React.SetStateAction<string>>
- pages: string[]
- setPages: React.Dispatch<React.SetStateAction<string[]>>
- currentPage?: string
- inputRef: React.RefObject<HTMLInputElement>
- site: 'studio' | 'docs' | 'website'
-
- /**
- * Project metadata for easy retrieval
- */
- project?: { ref?: string; apiKeys?: { anon?: string; service?: string }; apiUrl?: string }
- /**
- * Any additional metadata that CMDK component can use in its AI prompts
- */
- metadata?: { definitions?: string; flags?: { [key: string]: string } }
- /**
- * Opt in flag to use additional metadata in AI prompts
- */
- isOptedInToAI: boolean
-
- // Optional callback to save a generated SQL output
- saveGeneratedSQL?: (answer: string, title: string) => Promise<void>
-}
-
-export const CommandMenuContext = createContext<CommandMenuContextValue | undefined>(undefined)
-export const useCommandMenu = () => {
- const context = useContext(CommandMenuContext)
-
- if (context === undefined) {
- throw new Error('useCommandMenu was used outside of CommandMenuProvider')
- }
-
- return context
-}
diff --git a/packages/ui-patterns/Cmdk/CommandMenuProvider.tsx b/packages/ui-patterns/Cmdk/CommandMenuProvider.tsx
deleted file mode 100644
index 7a98b385f33..00000000000
--- a/packages/ui-patterns/Cmdk/CommandMenuProvider.tsx
+++ /dev/null
@@ -1,123 +0,0 @@
-'use client'
-
-import dynamic from 'next/dynamic'
-import { ElementRef, PropsWithChildren, useEffect, useRef, useState } from 'react'
-import { CommandInput } from './Command.utils'
-import { CommandMenuContext } from './CommandMenuContext'
-
-// `CommandMenu` is heavy - code split to reduce app bundle size
-const CommandMenu = dynamic(() => import('./CommandMenu'), {
- loading: () => <p>Loading...</p>,
-})
-
-export interface CommandMenuProviderProps {
- site: 'studio' | 'docs' | 'website'
- projectRef?: string
- /**
- * Project's API keys, for easy access through CMDK
- */
- apiKeys?: { anon?: string; service?: string }
- apiUrl?: string
- /**
- * Opt in flag to use additional metadata in AI prompts
- */
- isOptedInToAI?: boolean
- /**
- * Any additional metadata that CMDK component can use in its AI prompts
- */
- metadata?: { definitions?: string; flags?: { [key: string]: string } }
- /**
- * Call back when save SQL snippet button is selected
- */
- saveGeneratedSQL?: (answer: string, title: string) => Promise<void>
-}
-
-const CommandMenuProvider = ({
- children,
- site,
- projectRef,
- apiKeys,
- apiUrl,
- metadata,
- isOptedInToAI = false,
- saveGeneratedSQL,
-}: PropsWithChildren<CommandMenuProviderProps>) => {
- const [isOpen, setIsOpen] = useState(false)
- const [isLoading, setIsLoading] = useState(false)
- const [search, setSearch] = useState('')
- const [pages, setPages] = useState<string[]>([])
- const inputRef = useRef<ElementRef<typeof CommandInput>>(null)
- const currentPage = pages[pages.length - 1]
-
- const project = projectRef !== undefined ? { ref: projectRef, apiKeys, apiUrl } : undefined
-
- useKeyboardEvents({ setIsOpen, currentPage, setSearch, setPages })
-
- return (
- <CommandMenuContext.Provider
- value={{
- isOpen,
- setIsOpen,
- isLoading,
- setIsLoading,
- setSearch,
- search,
- pages,
- setPages,
- currentPage,
- site,
- project,
- metadata,
- isOptedInToAI,
- saveGeneratedSQL,
- inputRef,
- }}
- >
- {children}
- <CommandMenu />
- </CommandMenuContext.Provider>
- )
-}
-function useKeyboardEvents({
- setIsOpen,
- currentPage,
- setSearch,
- setPages,
-}: {
- setIsOpen: (isOpen: boolean) => void
- setSearch: React.Dispatch<React.SetStateAction<string>>
- setPages: React.Dispatch<React.SetStateAction<string[]>>
- currentPage?: string
-}) {
- useEffect(() => {
- function onKeyDown(event: KeyboardEvent) {
- switch (event.key) {
- case 'Escape':
- event.preventDefault()
- // if on homepage, close the command palette
- if (!currentPage) setIsOpen(false)
- setSearch('')
- // if NOT on homepage, return to last page
- setPages((pages) => pages.slice(0, -1))
- return
- case 'k':
- case '/':
- if (event.metaKey || event.ctrlKey) {
- // Some browsers (ie. firefox) will focus the address bar by default
- event.preventDefault()
-
- setIsOpen(true)
- }
- return
- }
- }
-
- window.addEventListener('keydown', onKeyDown)
-
- return () => {
- window.removeEventListener('keydown', onKeyDown)
- }
- }, [setIsOpen, currentPage])
-}
-
-export default CommandMenuProvider
diff --git a/packages/ui-patterns/Cmdk/CommandMenuShortcuts.tsx b/packages/ui-patterns/Cmdk/CommandMenuShortcuts.tsx
deleted file mode 100644
index 3a0eed9b84f..00000000000
--- a/packages/ui-patterns/Cmdk/CommandMenuShortcuts.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { IconArrowLeft } from 'ui/src/components/Icon/icons/IconArrowLeft'
-
-import { BadgeExperimental } from './Command.Badges'
-import { COMMAND_ROUTES } from './Command.constants'
-import { CommandShortcut } from './Command.utils'
-import { useCommandMenu } from './CommandMenuContext'
-
-export default function CommandMenuShortcuts() {
- const { setPages, pages, currentPage } = useCommandMenu()
-
- return (
- <div className="flex w-full gap-2 px-4 pt-4 pb-2 justify-items-start flex-row items-center justify-between">
- <div className="flex gap-2 flex-row items-center">
- <CommandShortcut onClick={() => setPages([])}>
- <div className="flex items-center gap-2">
- <IconArrowLeft width={15} height={15} />
- </div>
- </CommandShortcut>
-
- {pages.map((page, index) => (
- <CommandShortcut
- type={page === currentPage ? 'breadcrumb' : 'default'}
- key={page}
- onClick={() => {
- if (index === pages.length - 1) {
- return
- }
- setPages(pages.slice(0, index - 1))
- }}
- >
- {page}
- </CommandShortcut>
- ))}
-
- {currentPage && isExperimental(currentPage) && <BadgeExperimental />}
- </div>
- </div>
- )
-}
-
-/**
- * TODO: remove this function and store this info on each page
- * Temporary function to determine whether or not to show 'Experimental' badge
- */
-function isExperimental(page: string) {
- switch (page) {
- case COMMAND_ROUTES.AI:
- case COMMAND_ROUTES.GENERATE_SQL:
- return true
- default:
- return false
- }
-}
diff --git a/packages/ui-patterns/Cmdk/DocsSearch.tsx b/packages/ui-patterns/Cmdk/DocsSearch.tsx
deleted file mode 100644
index deaa3ca67d3..00000000000
--- a/packages/ui-patterns/Cmdk/DocsSearch.tsx
+++ /dev/null
@@ -1,343 +0,0 @@
-'use client'
-
-import { useSupabaseClient } from '@supabase/auth-helpers-react'
-import {
- type DocsSearchResult as Page,
- type DocsSearchResultSection as PageSection,
- DocsSearchResultType as PageType,
- useDocsSearch,
-} from 'common'
-import { Book, ChevronRight, Github, Hash, Loader2, MessageSquare, Search } from 'lucide-react'
-import { useRouter } from 'next/navigation'
-import { useEffect, useRef } from 'react'
-import { Button, StatusIcon } from 'ui'
-import { CommandGroup, CommandItem, CommandLabel, TextHighlighter } from './Command.utils'
-import { useCommandMenu } from './CommandMenuContext'
-
-const questions = [
- 'How do I get started with Supabase?',
- 'How do I run Supabase locally?',
- 'How do I connect to my database?',
- 'How do I run migrations? ',
- 'How do I listen to changes in a table?',
- 'How do I set up authentication?',
-]
-
-const DocsSearch = () => {
- const supabaseClient = useSupabaseClient()
- const {
- searchState: state,
- handleDocsSearch: handleSearch,
- handleDocsSearchDebounced: debouncedSearch,
- resetSearch,
- } = useDocsSearch(supabaseClient)
- const { search, setSearch, inputRef, site, setIsOpen } = useCommandMenu()
- const initialLoad = useRef(true)
- const router = useRouter()
-
- async function openLink(pageType: PageType, link: string) {
- switch (pageType) {
- case PageType.Markdown:
- case PageType.Reference:
- if (site === 'docs') {
- await router.push(link)
- return setIsOpen(false)
- } else if (site === 'website') {
- await router.push(`/docs${link}`)
- setIsOpen(false)
- } else {
- window.open(`https://supabase.com/docs${link}`, '_blank')
- setIsOpen(false)
- }
- break
- case PageType.Integration:
- if (site === 'website') {
- router.push(link)
- setIsOpen(false)
- } else {
- window.open(`https://supabase.com${link}`, '_blank')
- setIsOpen(false)
- }
- break
- case PageType.GithubDiscussion:
- window.open(link, '_blank')
- setIsOpen(false)
- break
- default:
- throw new Error(`Unknown page type '${pageType}'`)
- }
- }
-
- const hasResults =
- state.status === 'fullResults' ||
- state.status === 'partialResults' ||
- (state.status === 'loading' && state.staleResults.length > 0)
-
- function handleResetPrompt() {
- setSearch('')
- resetSearch()
- }
-
- useEffect(() => {
- if (initialLoad.current) {
- // On first navigation into 'docs search' page, search immediately
- if (search) {
- handleSearch(search)
- }
- initialLoad.current = false
- } else if (search) {
- // Else if user is typing, debounce search
- debouncedSearch(search)
- } else {
- // If user clears search, reset results
- debouncedSearch.cancel()
- resetSearch()
- }
- }, [search, handleSearch, debouncedSearch, resetSearch])
-
- // Immediately run search if user presses enter
- // and abort any debounced searches that are waiting
- useEffect(() => {
- const handleEnter = (event: KeyboardEvent) => {
- if (
- event.key === 'Enter' &&
- document.activeElement === inputRef.current &&
- search &&
- // If there are results, cmdk menu will trigger navigation to the highlighted
- // result on Enter, even though the active element is the input
- !hasResults
- ) {
- event.preventDefault()
- debouncedSearch.cancel()
- handleSearch(search)
- }
- }
-
- inputRef.current?.addEventListener('keydown', handleEnter)
-
- return () => inputRef.current?.removeEventListener('keydown', handleEnter)
- }, [search, hasResults])
-
- const ChevronArrow = () => (
- <ChevronRight
- strokeWidth={1.5}
- className="
- text-foreground-muted
- opacity-0
- -left-4
- group-aria-selected:scale-[101%]
- group-aria-selected:opacity-100
- group-aria-selected:left-0
- "
- />
- )
-
- const IconContainer = (
- props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
- ) => (
- <div
- className="
- transition
- w-6 h-6
- bg-surface-100
- border
- group-aria-selected:bg-surface-200
- group-aria-selected:text-foreground-lighter
- text-foreground-muted
- rounded flex
- items-center
- justify-center
- "
- {...props}
- />
- )
-
- return (
- <>
- {hasResults &&
- ('results' in state ? state.results : state.staleResults).map((page, i) => {
- return (
- <CommandGroup
- heading=""
- key={`${page.path}-group`}
- value={`${encodeURIComponent(page.title)}-group-index-${i}`}
- forceMount={true}
- >
- <CommandItem
- key={`${page.path}-item`}
- value={`${encodeURIComponent(page.title)}-item-index-${i}`}
- type="block-link"
- onSelect={() => {
- openLink(page.type, formatPageUrl(page))
- }}
- forceMount={true}
- >
- <div className="grow flex gap-3 items-center">
- <IconContainer>{getPageIcon(page)}</IconContainer>
- <div className="flex flex-col gap-0">
- <CommandLabel>
- <TextHighlighter text={page.title} query={search} />
- </CommandLabel>
- {(page.description || page.subtitle) && (
- <div className="text-xs text-foreground-muted">
- <TextHighlighter
- text={page.description! || page.subtitle!}
- query={search}
- />
- </div>
- )}
- </div>
- </div>
-
- <ChevronArrow />
- </CommandItem>
- {page.sections.length > 0 && (
- <div className="border-l border-muted ml-3 pt-3">
- {page.sections.map((section, i) => (
- <CommandItem
- className="ml-3 mb-3"
- onSelect={() => {
- openLink(page.type, formatSectionUrl(page, section))
- }}
- key={`${page.path}__${section.heading}-item`}
- value={`${encodeURIComponent(
- page.title
- )}__${encodeURIComponent(section.heading)}-item-index-${i}`}
- forceMount={true}
- type="block-link"
- >
- <div className="grow flex gap-3 items-center">
- <IconContainer>{getPageSectionIcon(page)}</IconContainer>
- <div className="flex flex-col gap-0">
- <cite>
- <TextHighlighter
- className="not-italic text-[10px] rounded-full px-2 py-1 bg-surface-300 text-foreground-muted"
- text={page.title}
- query={search}
- />
- </cite>
- {section.heading && (
- <CommandLabel>
- <TextHighlighter text={section.heading} query={search} />
- </CommandLabel>
- )}
- </div>
- </div>
- <ChevronArrow />
- </CommandItem>
- ))}
- </div>
- )}
- </CommandGroup>
- )
- })}
- {state.status === 'initial' && (
- <CommandGroup>
- {questions.map((question) => {
- const key = question.replace(/\s+/g, '_')
- return (
- <CommandItem
- disabled={hasResults}
- onSelect={() => {
- if (!search) {
- handleSearch(question)
- setSearch(question)
- }
- }}
- type="command"
- key={key}
- >
- <Search />
- {question}
- </CommandItem>
- )
- })}
- </CommandGroup>
- )}
- {state.status === 'loading' && state.staleResults.length === 0 && (
- <div className="flex items-center gap-3 my-4 justify-center">
- <Loader2 className="animate animate-spin text-foreground-muted" size={14} />
- <p className="text-sm text-foreground-muted text-center">Searching for results</p>
- </div>
- )}
- {state.status === 'noResults' && (
- <div className="p-6 flex flex-col items-center gap-3 mt-4 text-foreground-light">
- <StatusIcon variant="default" />
- <p className="text-sm text-foreground-light text-center">No results found.</p>
- <Button size="tiny" type="default" onClick={handleResetPrompt}>
- Try again?
- </Button>
- </div>
- )}
- {state.status === 'error' && (
- <div className="p-6 flex flex-col items-center gap-3 mt-4">
- <StatusIcon variant="warning" />
- <div className="flex flex-col items-center gap-1">
- <p className="text-sm text-foreground-light">
- Sorry, looks like we&apos;re having some issues with search.
- </p>
- <p className="text-sm text-foreground-lighter">Please try again in a bit.</p>
- </div>
- <Button size="tiny" type="default" onClick={handleResetPrompt}>
- Try again?
- </Button>
- </div>
- )}
- </>
- )
-}
-
-export default DocsSearch
-
-export function formatPageUrl(page: Page) {
- switch (page.type) {
- case PageType.Markdown:
- case PageType.Reference:
- case PageType.Integration:
- case PageType.GithubDiscussion:
- return page.path
- default:
- throw new Error(`Unknown page type '${page.type}'`)
- }
-}
-
-export function formatSectionUrl(page: Page, section: PageSection) {
- switch (page.type) {
- case PageType.Markdown:
- case PageType.GithubDiscussion:
- return `${formatPageUrl(page)}#${section.slug ?? ''}`
- case PageType.Reference:
- return `${formatPageUrl(page)}/${section.slug ?? ''}`
- case PageType.Integration:
- // [Charis] Markdown headings on integrations pages don't have slugs yet
- return formatPageUrl(page)
- default:
- throw new Error(`Unknown page type '${page.type}'`)
- }
-}
-
-export function getPageIcon(page: Page) {
- switch (page.type) {
- case PageType.Markdown:
- case PageType.Reference:
- case PageType.Integration:
- return <Book strokeWidth={1.5} className="!mr-0 !w-4 !h-4" />
- case PageType.GithubDiscussion:
- return <Github strokeWidth={1.5} className="!mr-0 !w-4 !h-4" />
- default:
- throw new Error(`Unknown page type '${page.type}'`)
- }
-}
-
-export function getPageSectionIcon(page: Page) {
- switch (page.type) {
- case PageType.Markdown:
- case PageType.Reference:
- case PageType.Integration:
- return <Hash strokeWidth={1.5} className="!mr-0 !w-4 !h-4" />
- case PageType.GithubDiscussion:
- return <MessageSquare strokeWidth={1.5} className="!mr-0 !w-4 !h-4" />
- default:
- throw new Error(`Unknown page type '${page.type}'`)
- }
-}
diff --git a/packages/ui-patterns/Cmdk/GenerateSQL/GenerateSQL.tsx b/packages/ui-patterns/Cmdk/GenerateSQL/GenerateSQL.tsx
deleted file mode 100644
index 61f82eb2ac1..00000000000
--- a/packages/ui-patterns/Cmdk/GenerateSQL/GenerateSQL.tsx
+++ /dev/null
@@ -1,339 +0,0 @@
-import React from 'react'
-import { format } from 'sql-formatter'
-import { useCallback, useEffect, useRef, useState } from 'react'
-import {
- Button,
- CodeBlock,
- IconAlertTriangle,
- IconCornerDownLeft,
- IconUser,
- Input,
- Toggle,
- Tabs,
-} from 'ui'
-import { MessageRole, MessageStatus, useAiChat, UseAiChatOptions } from './../AiCommand'
-
-import { cn } from 'ui/src/lib/utils'
-import { AiIcon, AiIconChat } from '../Command.icons'
-import { CommandItem, useAutoInputFocus, useHistoryKeys } from '../Command.utils'
-import { useCommandMenu } from '../CommandMenuContext'
-import { SAMPLE_QUERIES } from '../Command.constants'
-import SQLOutputActions from './SQLOutputActions'
-import { generatePrompt } from './GenerateSQL.utils'
-import { ExcludeSchemaAlert, IncludeSchemaAlert, AiWarning } from '../Command.alerts'
-import { StatusIcon } from 'ui'
-
-const GenerateSQL = () => {
- const [includeSchemaMetadata, setIncludeSchemaMetadata] = useState(false)
- const [selectedCategory, setSelectedCategory] = useState<string>(SAMPLE_QUERIES[0].category)
-
- const { isLoading, setIsLoading, search, setSearch, isOptedInToAI, metadata, project } =
- useCommandMenu()
-
- const { flags, definitions } = metadata || {}
- const allowSendingSchemaMetadata =
- project?.ref !== undefined && flags?.allowCMDKDataOptIn && isOptedInToAI
-
- const messageTemplate = useCallback<NonNullable<UseAiChatOptions['messageTemplate']>>(
- (message) =>
- generatePrompt(message, isOptedInToAI && includeSchemaMetadata ? definitions : undefined),
- [isOptedInToAI, includeSchemaMetadata, definitions]
- )
-
- const { submit, reset, messages, isResponding, hasError } = useAiChat({
- messageTemplate,
- setIsLoading,
- })
-
- const inputRef = useAutoInputFocus()
-
- useHistoryKeys({
- enable: !isResponding,
- messages: messages
- .filter(({ role }) => role === MessageRole.User)
- .map(({ content }) => content),
- setPrompt: setSearch,
- })
-
- const handleSubmit = useCallback(
- (message: string) => {
- setSearch('')
- submit(message)
- },
- [submit]
- )
-
- const handleReset = useCallback(() => {
- setSearch('')
- reset()
- }, [reset])
-
- useEffect(() => {
- if (search) handleSubmit(search)
- }, [])
-
- // Detect an IME composition (so that we can ignore Enter keypress)
- const [isImeComposing, setIsImeComposing] = useState(false)
-
- const formatAnswer = (answer: string) => {
- try {
- return format(answer, {
- language: 'postgresql',
- keywordCase: 'lower',
- })
- } catch (error: any) {
- return answer
- }
- }
-
- return (
- <div onClick={(e) => e.stopPropagation()}>
- <div
- className={cn(
- 'relative py-4 max-h-[420px] overflow-auto',
- allowSendingSchemaMetadata ? 'mb-[155px]' : 'mb-[64px]'
- )}
- >
- {messages.map((message, i) => {
- switch (message.role) {
- case MessageRole.User:
- return (
- <div className="flex gap-6 mx-4 [overflow-anchor:none] mb-6">
- <div
- className="
- w-7 h-7 bg-background rounded-full border border-muted flex items-center justify-center text-foreground-lighter first-letter:
- ring-background ring-1 shadow-sm
- "
- >
- <IconUser strokeWidth={1.5} size={16} />
- </div>
- <div className="flex items-center prose text-foreground-light text-sm">
- {message.content}
- </div>
- </div>
- )
- case MessageRole.Assistant:
- const unformattedAnswer = message.content
- .replace(/```sql/g, '')
- .replace(/```.*/gs, '')
- .replace(/-- End of SQL query\.*/g, '')
- .trim()
-
- const answer =
- message.status === MessageStatus.Complete
- ? formatAnswer(unformattedAnswer)
- : unformattedAnswer
- const cantHelp =
- answer.replace(/^-- /, '') === "Sorry, I don't know how to help with that."
-
- return (
- <div className="px-4 [overflow-anchor:none] mb-[150px]">
- <div className="flex gap-6 [overflow-anchor:none] mb-6">
- <div>
- <AiIconChat
- loading={
- message.status === MessageStatus.Pending ||
- message.status === MessageStatus.InProgress
- }
- />
- </div>
- <>
- {message.status === MessageStatus.Pending ? (
- <div className="bg-border-strong h-[21px] w-[13px] mt-1 animate-bounce"></div>
- ) : cantHelp ? (
- <div className="p-6 flex flex-col flex-grow items-center gap-6 mt-4">
- <IconAlertTriangle
- className="text-amber-900"
- strokeWidth={1.5}
- size={21}
- />
- <p className="text-lg text-foreground text-center">
- Sorry, I don't know how to help with that.
- </p>
- <Button size="tiny" type="secondary" onClick={handleReset}>
- Try again?
- </Button>
- </div>
- ) : (
- <div className="space-y-2 flex-grow max-w-[93%]">
- <div className="-space-y-px">
- <CodeBlock
- hideCopy
- language="sql"
- className="
- relative prose bg-surface-100 max-w-none !mb-0
- !rounded-b-none
-
- "
- >
- {answer}
- </CodeBlock>
- <AiWarning className="!rounded-t-none border-muted" />
- </div>
- {message.status === MessageStatus.Complete && (
- <SQLOutputActions answer={answer} messages={messages.slice(0, i + 1)} />
- )}
- </div>
- )}
- </>
- </div>
- </div>
- )
- }
- })}
- {messages.length === 0 && !hasError && (
- <div>
- <div className="px-4">
- <h3 className="text-base text-foreground-light">
- Describe what you need and Supabase AI will try to generate the relevant SQL
- statements
- </h3>
- <p className="text-sm mt-1 text-foreground-light">
- Here are some example prompts to try out:
- </p>
- </div>
- <div className="mt-4 border-t pt-4 ml-4">
- <Tabs type="rounded-pills" size="small">
- {SAMPLE_QUERIES.map((sample) => (
- <Tabs.Panel
- key={sample.category}
- id={sample.category}
- label={sample.category}
- className="mt-4"
- >
- <div className="mr-8">
- {SAMPLE_QUERIES.find(
- (item) => item.category === sample.category
- )?.queries.map((query) => (
- <CommandItem
- type="command"
- onSelect={() => {
- if (!search) {
- handleSubmit(query)
- }
- }}
- onKeyDown={(e) => {
- switch (e.key) {
- case 'Enter':
- if (!search || isLoading || isResponding || isImeComposing) {
- return
- }
- return handleSubmit(query)
- default:
- return
- }
- }}
- key={query.replace(/\s+/g, '_')}
- >
- <div className="flex flex-row gap-2">
- <AiIcon />
- <p>{query}</p>
- </div>
- </CommandItem>
- ))}
- </div>
- </Tabs.Panel>
- ))}
- </Tabs>
- </div>
- </div>
- )}
- {hasError && (
- <div className="p-6 flex flex-col items-center gap-2 mt-4">
- <StatusIcon variant="warning" />
- <div>
- <p className="text-sm text-foreground text-center">
- Sorry, looks like Supabase AI is having a hard time!
- </p>
- <p className="text-sm text-foreground-lighter text-center">
- Please try again in a bit.
- </p>
- </div>
- <Button size="tiny" type="default" onClick={handleReset}>
- Try again?
- </Button>
- </div>
- )}
- <div className="[overflow-anchor:auto] h-px w-full"></div>
- </div>
-
- <div className="absolute bottom-0 w-full bg-background pt-4">
- {/* {messages.length > 0 && !hasError && <AiWarning className="mb-4 mx-4" />} */}
- {allowSendingSchemaMetadata && (
- <div className="mb-4">
- {messages.length === 0 ? (
- <div className="flex items-center justify-between px-6 py-3">
- <div>
- <p className="text-sm">
- Include table names, column names and their corresponding data types in
- conversation
- </p>
- <p className="text-sm text-foreground-light">
- This will generate answers that are more relevant to your project during the
- current conversation
- </p>
- </div>
- <Toggle
- disabled={!isOptedInToAI || isLoading || isResponding}
- checked={includeSchemaMetadata}
- onChange={() => setIncludeSchemaMetadata((prev) => !prev)}
- />
- </div>
- ) : includeSchemaMetadata ? (
- <IncludeSchemaAlert />
- ) : (
- <ExcludeSchemaAlert />
- )}
- </div>
- )}
- <Input
- inputRef={inputRef}
- className="bg-alternative rounded mx-3 mb-4 [&_input]:pr-32 md:[&_input]:pr-40"
- autoFocus
- placeholder={
- isLoading || isResponding
- ? 'Waiting on an answer...'
- : 'Describe what you need and Supabase AI will try to generate the relevant SQL statements'
- }
- value={search}
- actions={
- <>
- {!isLoading && !isResponding ? (
- <div
- className={`flex items-center gap-3 mr-3 transition-opacity duration-700 ${
- search ? 'opacity-100' : 'opacity-0'
- }`}
- >
- <span className="text-foreground-light">Submit message</span>
- <div className="hidden text-foreground-light md:flex items-center justify-center h-6 w-6 rounded bg-overlay-hover">
- <IconCornerDownLeft size={12} strokeWidth={1.5} />
- </div>
- </div>
- ) : null}
- </>
- }
- onChange={(e) => {
- if (!isLoading || !isResponding) {
- setSearch(e.target.value)
- }
- }}
- onCompositionStart={() => setIsImeComposing(true)}
- onCompositionEnd={() => setIsImeComposing(false)}
- onKeyDown={(e) => {
- switch (e.key) {
- case 'Enter':
- if (!search || isLoading || isResponding || isImeComposing) {
- return
- }
- return handleSubmit(search)
- default:
- return
- }
- }}
- />
- </div>
- </div>
- )
-}
-
-export default GenerateSQL
diff --git a/packages/ui-patterns/Cmdk/GenerateSQL/GenerateSQL.utils.ts b/packages/ui-patterns/Cmdk/GenerateSQL/GenerateSQL.utils.ts
deleted file mode 100644
index dd4c4ad9635..00000000000
--- a/packages/ui-patterns/Cmdk/GenerateSQL/GenerateSQL.utils.ts
+++ /dev/null
@@ -1,100 +0,0 @@
-import { stripIndent } from 'common-tags'
-
-export function getEdgeFunctionUrl() {
- const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL?.replace(/\/$/, '')
-
- if (!supabaseUrl) return undefined
-
- // https://github.com/supabase/supabase-js/blob/10d3423506cbd56345f7f6ab2ec2093c8db629d4/src/SupabaseClient.ts#L96
- const isPlatform = supabaseUrl.match(/(supabase\.co)|(supabase\.in)/)
-
- if (isPlatform) {
- const [schemeAndProjectId, domain, tld] = supabaseUrl.split('.')
- return `${schemeAndProjectId}.functions.${domain}.${tld}`
- } else {
- return `${supabaseUrl}/functions/v1`
- }
-}
-
-export function promptDataReducer(
- state: any[],
- action: {
- index?: number
- answer?: string | undefined
- status?: string
- query?: string | undefined
- type?: 'remove-last-item' | string
- }
-) {
- // set a standard state to use later
- let current = [...state]
-
- if (action.type) {
- switch (action.type) {
- case 'remove-last-item':
- current.pop()
- return [...current]
- default:
- break
- }
- }
-
- // check that an index is present
- if (action.index === undefined) return [...state]
-
- if (!current[action.index]) {
- current[action.index] = { query: '', answer: '', status: '' }
- }
-
- current[action.index].answer = action.answer
-
- if (action.query) {
- current[action.index].query = action.query
- }
- if (action.status) {
- current[action.index].status = action.status
- }
-
- return [...current]
-}
-
-export const generatePrompt = (prompt: string, definitions?: any) => {
- return stripIndent`
-${
- definitions !== undefined
- ? `
-Given the following Postgres SQL tables:
-${definitions}
-`
- : ''
-}
-
-Generate a Postgres SQL query based on the following natural language prompt.
-- Only output valid SQL - all explanations must be SQL comments
-- SQL comments should be short
-- Your very last output should be "\`\`\`"
-- For primary keys, always use "integer primary key generated always as identity"
-
-Natural language prompt:
-${prompt}
-
-Postgres SQL query (markdown SQL only):
-`.trim()
-}
-
-/**
- * Formats a string for use as a title.
- *
- * Removes punctuation and capitalizes each word
- */
-export function formatTitle(value: string) {
- let words = value.replace(/\.$/, '').replace(/['"]/g, '').split(' ')
- words = words.map((word) => {
- // Don't capitalize code
- if (/[._\(\)]+/.test(word)) {
- return word
- }
- return word.charAt(0).toUpperCase() + word.slice(1)
- })
- return words.join(' ')
-}
diff --git a/packages/ui-patterns/Cmdk/GenerateSQL/SQLOutputActions.tsx b/packages/ui-patterns/Cmdk/GenerateSQL/SQLOutputActions.tsx
deleted file mode 100644
index 3d363d22a52..00000000000
--- a/packages/ui-patterns/Cmdk/GenerateSQL/SQLOutputActions.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-import { useState, useEffect } from 'react'
-import CopyToClipboard from 'react-copy-to-clipboard'
-import { Button, IconCheck, IconClipboard, IconSave } from 'ui'
-import { useCommandMenu } from '../CommandMenuContext'
-import { stripIndent } from 'common-tags'
-import { formatTitle } from './GenerateSQL.utils'
-import { Message, MessageRole, MessageStatus, queryAi } from './../AiCommand'
-
-export interface SQLOutputActionsProps {
- answer: string
- messages: Message[]
-}
-
-const SQLOutputActions = ({ answer, messages }: SQLOutputActionsProps) => {
- const [showCopied, setShowCopied] = useState(false)
- const [isSaving, setIsSaving] = useState(false)
- const [isSaved, setIsSaved] = useState(false)
-
- const { project, saveGeneratedSQL } = useCommandMenu()
-
- const onSelectSaveSnippet = async () => {
- setIsSaving(true)
-
- let suggestedTitle
- try {
- suggestedTitle = await queryAi(
- [
- ...messages,
- {
- role: MessageRole.User,
- content: stripIndent`
- Generate a title for the above SQL snippet following all of these rules:
- - The title is only for the last SQL snippet
- - Focus on the main purposes of this snippet
- - Use as few words as possible
- - Title should be nouns, not verbs
- - Do not include word articles (eg. a, the, for, of)
- - Do not use words like "SQL" or "snippet" or "title"
- - Do not output markdown, quotes, etc
- - Do not be too verbose
- `,
- status: MessageStatus.Complete,
- },
- ],
- 10000
- )
- } catch (error) {
- suggestedTitle = ''
- }
-
- const formattedTitle = formatTitle(suggestedTitle)
- await saveGeneratedSQL?.(answer, formattedTitle)
- setIsSaved(true)
- setIsSaving(false)
- }
-
- useEffect(() => {
- if (!showCopied) return
- const timer = setTimeout(() => setShowCopied(false), 2000)
- return () => clearTimeout(timer)
- }, [showCopied])
-
- useEffect(() => {
- if (!isSaved) return
- const timer = setTimeout(() => setIsSaved(false), 2000)
- return () => clearTimeout(timer)
- }, [isSaved])
-
- return (
- <div className="flex items-center justify-end space-x-2">
- <CopyToClipboard text={answer?.replace(/```.*/g, '').trim()}>
- <Button
- type="default"
- icon={
- showCopied ? (
- <IconCheck size="tiny" className="text-brand" strokeWidth={2} />
- ) : (
- <IconClipboard size="tiny" />
- )
- }
- onClick={() => setShowCopied(true)}
- >
- {showCopied ? 'Copied' : 'Copy SQL'}
- </Button>
- </CopyToClipboard>
- {project?.ref !== undefined && saveGeneratedSQL !== undefined && (
- <Button
- type="default"
- loading={isSaving}
- disabled={isSaving}
- icon={
- isSaved ? (
- <IconCheck size="tiny" className="text-brand" strokeWidth={2} />
- ) : (
- <IconSave size="tiny" />
- )
- }
- onClick={() => onSelectSaveSnippet()}
- >
- {isSaved ? 'Snippet saved!' : 'Save into new snippet'}
- </Button>
- )}
- </div>
- )
-}
-
-export default SQLOutputActions
diff --git a/packages/ui-patterns/Cmdk/GenerateSQL/index.ts b/packages/ui-patterns/Cmdk/GenerateSQL/index.ts
deleted file mode 100644
index 13cc54742fc..00000000000
--- a/packages/ui-patterns/Cmdk/GenerateSQL/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import GenerateSQL from './GenerateSQL'
-
-export default GenerateSQL
diff --git a/packages/ui-patterns/Cmdk/SearchButton.tsx b/packages/ui-patterns/Cmdk/SearchButton.tsx
deleted file mode 100644
index aeb0c7153a8..00000000000
--- a/packages/ui-patterns/Cmdk/SearchButton.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-'use client'
-
-import { ButtonHTMLAttributes, DetailedHTMLProps, PropsWithChildren, useRef } from 'react'
-import { useCommandMenu } from './CommandMenuContext'
-
-const SearchButton = ({
- children,
- className,
- ...props
-}: PropsWithChildren<
- DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
->) => {
- const searchButtonRef = useRef<HTMLButtonElement>(null)
- const { setIsOpen, site } = useCommandMenu()
-
- return (
- <button
- type="button"
- ref={searchButtonRef}
- onClick={() => setIsOpen(true)}
- className={className}
- {...props}
- >
- {children}
- </button>
- )
-}
-
-export default SearchButton
diff --git a/packages/ui-patterns/Cmdk/SearchOnlyItem.tsx b/packages/ui-patterns/Cmdk/SearchOnlyItem.tsx
deleted file mode 100644
index dc39952a246..00000000000
--- a/packages/ui-patterns/Cmdk/SearchOnlyItem.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { useRouter } from 'next/navigation'
-import { CommandItem } from './Command.utils'
-import { useCommandMenu } from './CommandMenuContext'
-
-interface SearchOnlyItemProps {
- children: React.ReactNode
- url: string
-}
-
-export default function SearchOnlyItem({ children, url }: SearchOnlyItemProps) {
- const { project, setIsOpen, setSearch } = useCommandMenu()
- const router = useRouter()
-
- const baseURL = process.env.NEXT_PUBLIC_SITE_URL
- function handleRouteChange(url: string) {
- const localizedURL = project?.ref
- ? `${baseURL}${url.replace('/_/', `/${project?.ref}/`)}`
- : `${baseURL}${url}`
-
- router.push(localizedURL)
- setIsOpen(false)
- setSearch('')
- }
- return (
- <CommandItem type="link" onSelect={() => handleRouteChange(url)}>
- {children}
- </CommandItem>
- )
-}
diff --git a/packages/ui-patterns/Cmdk/SearchableStudioItems.tsx b/packages/ui-patterns/Cmdk/SearchableStudioItems.tsx
deleted file mode 100644
index 9da3925c58e..00000000000
--- a/packages/ui-patterns/Cmdk/SearchableStudioItems.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { CommandGroup } from './Command.utils'
-import SearchOnlyItem from './SearchOnlyItem'
-
-import sharedItems from './utils/shared-nav-items.json'
-
-export default function SearchableStudioItems() {
- return (
- <CommandGroup heading="Find">
- {sharedItems.tools
- .filter((item) => item.subItems) // filter items with subItems
- .flatMap((item) =>
- item.subItems?.map((subItem) => (
- <SearchOnlyItem key={subItem.url + subItem.label} url={subItem.url}>
- {subItem.label}
- </SearchOnlyItem>
- ))
- )}
- </CommandGroup>
- )
-}
diff --git a/packages/ui-patterns/Cmdk/ThemeOptions.tsx b/packages/ui-patterns/Cmdk/ThemeOptions.tsx
deleted file mode 100644
index 94fa8175b99..00000000000
--- a/packages/ui-patterns/Cmdk/ThemeOptions.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { CommandGroup } from 'cmdk'
-import { useCommandMenu } from './CommandMenuContext'
-import ChildItem from './ChildItem'
-import { useTheme } from 'next-themes'
-import { Theme, themes } from 'ui/src/components/ThemeProvider/themes'
-
-const ThemeOptions = ({ isSubItem = false }) => {
- const { setIsOpen } = useCommandMenu()
- const { setTheme } = useTheme()
- return (
- <CommandGroup>
- {themes
- .filter((x) => x.name === 'System' || x.name === 'Light' || x.name === 'Dark')
- .map((theme: Theme) => (
- <ChildItem
- key={theme.value}
- isSubItem={isSubItem}
- onSelect={() => {
- setTheme(theme.value)
- setIsOpen(false)
- }}
- >
- Change Theme to {theme.name === 'System' ? 'System Default' : theme.name}
- </ChildItem>
- ))}
- </CommandGroup>
- )
-}
-
-export default ThemeOptions
diff --git a/packages/ui-patterns/Cmdk/dashboard-nav-items.json b/packages/ui-patterns/Cmdk/dashboard-nav-items.json
deleted file mode 100644
index c12948d2e88..00000000000
--- a/packages/ui-patterns/Cmdk/dashboard-nav-items.json
+++ /dev/null
@@ -1,96 +0,0 @@
-{
- "items": [
- {
- "label": "Home",
- "icon": "home",
- "url": "http://www.example.com/home",
- "sites": ["docs", "dashboard"],
- "subItems": [
- {
- "label": "About",
- "icon": "book",
- "url": "http://www.example.com/about",
- "sites": ["docs", "dashboard"]
- },
- {
- "label": "Services",
- "icon": "services",
- "url": "http://www.example.com/services",
- "sites": ["docs", "dashboard"]
- },
- {
- "label": "Contact",
- "icon": "contact",
- "url": "http://www.example.com/contact",
- "sites": ["docs", "dashboard"]
- }
- ]
- },
- {
- "label": "Products",
- "icon": "products",
- "url": "http://www.example.com/products",
- "sites": ["dashboard"],
- "subItems": [
- {
- "label": "Mobile",
- "icon": "mobile",
- "url": "http://www.example.com/products/mobile"
- },
- {
- "label": "In person",
- "icon": "person",
- "url": "http://www.example.com/products/in-person"
- }
- ]
- }
- ],
- "docsTools": [
- {
- "label": "Database",
- "url": "https://supabase.com/docs/guides/database"
- },
- {
- "label": "Auth",
- "url": "https://supabase.com/docs/guides/auth/overview"
- },
- {
- "label": "Edge Functions",
- "url": "https://supabase.com/docs/guides/functions"
- },
- {
- "label": "Realtime",
- "url": "https://supabase.com/docs/guides/realtime"
- },
- {
- "label": "Storage",
- "url": "https://supabase.com/docs/guides/storage"
- }
- ],
- "docsSupport": [
- {
- "label": "Support",
- "url": "https://supabase.com/support"
- },
- {
- "label": "System Status",
- "url": "https://status.supabase.com/"
- },
- {
- "label": "Github Discussions",
- "url": "https://github.com/supabase/supabase/discussions"
- }
- ],
- "docsGeneral": [
- {
- "icon": "arrowRight",
- "label": "Go to the Dashboard",
- "url": "https://app.supabase.io"
- },
- {
- "icon": "inbox",
- "label": "Read the Changelog",
- "url": "https://supabase.com/changelog"
- }
- ]
-}
diff --git a/packages/ui-patterns/Cmdk/index.tsx b/packages/ui-patterns/Cmdk/index.tsx
deleted file mode 100644
index 38b0a2e41b0..00000000000
--- a/packages/ui-patterns/Cmdk/index.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-export { default as CommandMenuProvider } from './CommandMenuProvider'
-export * from './CommandMenuProvider'
-export * from './CommandMenuContext'
-
-export { default as CommandMenu } from './CommandMenu'
-
-export { default as AiCommand } from './AiCommand'
-
-export { default as DocsSearch } from './DocsSearch'
-
-export { default as SearchButton } from './SearchButton'
-
-export * from './Command.icons'
diff --git a/packages/ui-patterns/Cmdk/utils/dashboard-nav-items.json b/packages/ui-patterns/Cmdk/utils/dashboard-nav-items.json
deleted file mode 100644
index 86b94adb9fb..00000000000
--- a/packages/ui-patterns/Cmdk/utils/dashboard-nav-items.json
+++ /dev/null
@@ -1,75 +0,0 @@
-{
- "tools": {
- "label": "Dashboard Tools",
- "items": [
- {
- "label": "dashboard - Database",
- "url": "https://supabase.com/docs/guides/database",
- "subItems": [
- {
- "label": "Triggers",
- "url": "http://www.example.com/triggers"
- },
- {
- "label": "Functions",
- "icon": "functions",
- "url": "http://www.example.com/functions"
- }
- ]
- },
- {
- "label": "dashboard - Auth",
- "url": "https://supabase.com/docs/guides/auth/overview"
- },
- {
- "label": "dashboard - Edge Functions",
- "url": "https://supabase.com/docs/guides/functions"
- },
- {
- "label": "dashboard - Realtime",
- "url": "https://supabase.com/docs/guides/realtime"
- },
- {
- "label": "dashboard - Storage",
- "url": "https://supabase.com/docs/guides/storage"
- }
- ]
- },
- "settings": {
- "label": "Dashboard Settings",
- "items": [
- {
- "label": "settings - Database general",
- "url": "https://supabase.com/docs/guides/database"
- },
- {
- "label": "settings - Database settings",
- "url": "https://supabase.com/docs/guides/auth/overview"
- },
- {
- "label": "settings - API settings",
- "url": "https://supabase.com/docs/guides/functions"
- },
- {
- "label": "settings - Auth settings",
- "url": "https://supabase.com/docs/guides/realtime"
- },
- {
- "label": "settings - Storage settings",
- "url": "https://supabase.com/docs/guides/storage"
- },
- {
- "label": "settings - subscription settings",
- "url": "https://supabase.com/docs/guides/storage"
- },
- {
- "label": "settings - usage settings",
- "url": "https://supabase.com/docs/guides/storage"
- },
- {
- "label": "settings - invoices settings",
- "url": "https://supabase.com/docs/guides/storage"
- }
- ]
- }
-}
diff --git a/packages/ui-patterns/Cmdk/utils/docs-nav-items.json b/packages/ui-patterns/Cmdk/utils/docs-nav-items.json
deleted file mode 100644
index c897ec63ea8..00000000000
--- a/packages/ui-patterns/Cmdk/utils/docs-nav-items.json
+++ /dev/null
@@ -1,96 +0,0 @@
-{
- "general": [
- {
- "label": "Home",
- "icon": "home",
- "url": "http://www.example.com/home",
- "sites": ["docs", "dashboard"],
- "subItems": [
- {
- "label": "About",
- "icon": "book",
- "url": "http://www.example.com/about",
- "sites": ["docs", "dashboard"]
- },
- {
- "label": "Services",
- "icon": "services",
- "url": "http://www.example.com/services",
- "sites": ["docs", "dashboard"]
- },
- {
- "label": "Contact",
- "icon": "contact",
- "url": "http://www.example.com/contact",
- "sites": ["docs", "dashboard"]
- }
- ]
- },
- {
- "label": "Products",
- "icon": "products",
- "url": "http://www.example.com/products",
- "sites": ["dashboard"],
- "subItems": [
- {
- "label": "Mobile",
- "icon": "mobile",
- "url": "http://www.example.com/products/mobile"
- },
- {
- "label": "In person",
- "icon": "person",
- "url": "http://www.example.com/products/in-person"
- }
- ]
- }
- ],
- "docsTools": [
- {
- "label": "Database",
- "url": "https://supabase.com/docs/guides/database"
- },
- {
- "label": "Auth",
- "url": "https://supabase.com/docs/guides/auth/overview"
- },
- {
- "label": "Edge Functions",
- "url": "https://supabase.com/docs/guides/functions"
- },
- {
- "label": "Realtime",
- "url": "https://supabase.com/docs/guides/realtime"
- },
- {
- "label": "Storage",
- "url": "https://supabase.com/docs/guides/storage"
- }
- ],
- "docsSupport": [
- {
- "label": "Support",
- "url": "https://supabase.com/support"
- },
- {
- "label": "System Status",
- "url": "https://status.supabase.com/"
- },
- {
- "label": "Github Discussions",
- "url": "https://github.com/supabase/supabase/discussions"
- }
- ],
- "docsGeneral": [
- {
- "icon": "arrowRight",
- "label": "Go to the Dashboard",
- "url": "https://app.supabase.io"
- },
- {
- "icon": "inbox",
- "label": "Read the Changelog",
- "url": "https://supabase.com/changelog"
- }
- ]
-}
diff --git a/packages/ui-patterns/Cmdk/utils/shared-nav-items.json b/packages/ui-patterns/Cmdk/utils/shared-nav-items.json
deleted file mode 100644
index fa292da7753..00000000000
--- a/packages/ui-patterns/Cmdk/utils/shared-nav-items.json
+++ /dev/null
@@ -1,310 +0,0 @@
-{
- "tools": [
- {
- "label": "Table Editor",
- "url": "/project/_/editor"
- },
- {
- "label": "SQL Editor",
- "url": "/project/_/sql"
- },
- {
- "label": "Database",
- "url": "/project/_/database/tables",
- "subItems": [
- {
- "label": "Tables",
- "url": "/project/_/database/tables"
- },
- {
- "label": "Triggers",
- "url": "/project/_/database/triggers"
- },
- {
- "label": "Functions",
- "url": "/project/_/database/functions"
- },
- {
- "label": "Extensions",
- "url": "/project/_/database/extensions"
- },
- {
- "label": "Roles",
- "url": "/project/_/database/roles"
- },
- {
- "label": "Publications",
- "url": "/project/_/database/publications"
- },
- {
- "label": "Replication",
- "url": "/project/_/database/publications"
- },
- {
- "label": "Webhooks",
- "url": "/project/_/database/hooks"
- },
- {
- "label": "Backups",
- "url": "/project/_/database/backups/scheduled"
- },
- {
- "label": "Wrappers",
- "url": "/project/_/database/wrappers"
- },
- {
- "label": "Migrations",
- "url": "/project/_/database/migrations"
- }
- ]
- },
- {
- "label": "Auth",
- "url": "/project/_/auth/users",
- "subItems": [
- {
- "label": "Users",
- "url": "/project/_/auth/users"
- },
- {
- "label": "Policies",
- "url": "/project/_/auth/policies"
- },
- {
- "label": "Providers",
- "url": "/project/_/auth/providers"
- },
- {
- "label": "Email Templates",
- "url": "/project/_/auth/templates"
- },
- {
- "label": "URL Configuration",
- "url": "/project/_/auth/url-configuration"
- }
- ]
- },
- {
- "label": "Storage",
- "url": "/project/_/storage"
- },
- {
- "label": "Edge Functions",
- "url": "/project/_/functions"
- },
- {
- "label": "Logs",
- "url": "/project/_/logs/explorer",
- "subItems": [
- {
- "label": "Postgres logs",
- "url": "/project/_/logs/postgres-logs"
- },
- {
- "label": "PostgREST logs",
- "url": "/project/_/logs/postgrest-logs"
- },
- {
- "label": "Pooler logs",
- "url": "/project/_/logs/pooler-logs"
- },
- {
- "label": "Auth logs",
- "url": "/project/_/logs/auth-logs"
- },
- {
- "label": "Storage logs",
- "url": "/project/_/logs/storage-logs"
- },
- {
- "label": "Realtime logs",
- "url": "/project/_/logs/realtime-logs"
- }
- ]
- },
- {
- "label": "Reports",
- "url": "/project/_/reports",
- "subItems": [
- {
- "label": "API reports",
- "url": "/project/_/reports/api-overview"
- },
- {
- "label": "Storage reports",
- "url": "/project/_/reports/storage"
- },
- {
- "label": "Database reports",
- "url": "/project/_/reports/database"
- },
- {
- "label": "Query performance reports",
- "url": "/project/_/reports/query-performance"
- }
- ]
- },
- {
- "label": "API Docs",
- "url": "/project/_/api",
- "subItems": [
- {
- "label": "Auth docs",
- "url": "/project/_/api?page=auth"
- },
- {
- "label": "User management docs",
- "url": "/project/_/api?page=users"
- },
- {
- "label": "GraphQL",
- "url": "/project/_/api/graphiql"
- }
- ]
- },
- {
- "label": "Project Settings",
- "url": "/project/_/settings/general",
- "subItems": [
- {
- "label": "General settings",
- "url": "/project/_/settings/general"
- },
- {
- "label": "Database settings",
- "url": "/project/_/settings/database"
- },
- {
- "label": "API settings",
- "url": "/project/_/settings/api"
- },
- {
- "label": "Auth settings",
- "url": "/project/_/settings/auth"
- },
- {
- "label": "Storage settings",
- "url": "/project/_/settings/storage"
- },
- {
- "label": "Log Drains",
- "url": "/project/_/settings/log-drains"
- },
- {
- "label": "Custom Domains",
- "url": "/project/_/settings/general#custom-domains"
- },
- {
- "label": "Restart project",
- "url": "/project/_/settings/general#restart-project"
- },
- {
- "label": "Pause project",
- "url": "/project/_/settings/general#pause-project"
- },
- {
- "label": "Transfer project",
- "url": "/project/_/settings/general#transfer-project"
- },
- {
- "label": "Delete project",
- "url": "/project/_/settings/general#delete-project"
- },
- {
- "label": "Database password",
- "url": "/project/_/settings/database#database-password"
- },
- {
- "label": "Connection string",
- "url": "/project/_/settings/database#connection-string"
- },
- {
- "label": "Connection pooling",
- "url": "/project/_/settings/database#connection-pooling"
- },
- {
- "label": "SSL Configuration",
- "url": "/project/_/settings/database#ssl-configuration"
- },
- {
- "label": "Network Restrictions",
- "url": "/project/_/settings/database#network-restrictions"
- },
- {
- "label": "Banned IPs",
- "url": "/project/_/settings/database#banned-ips"
- }
- ]
- }
- ],
- "projectTools": [
- {
- "label": "Your Projects",
- "url": "/projects"
- },
- {
- "label": "Project API Keys",
- "url": "/project/_/settings/api"
- }
- ],
- "support": [
- {
- "label": "Support",
- "url": "https://supabase.com/support"
- },
- {
- "label": "System Status",
- "url": "https://status.supabase.com/"
- },
- {
- "label": "Github Discussions",
- "url": "https://github.com/supabase/supabase/discussions"
- }
- ],
- "quickstarts": [
- {
- "label": "React",
- "url": "https://supabase.com/docs/guides/getting-started/quickstarts/reactjs"
- },
- {
- "label": "Next.js",
- "url": "https://supabase.com/docs/guides/getting-started/quickstarts/nextjs"
- },
- {
- "label": "Nuxt.js",
- "url": "https://supabase.com/docs/guides/getting-started/quickstarts/nuxtjs"
- },
- {
- "label": "Flutter",
- "url": "https://supabase.com/docs/guides/getting-started/quickstarts/flutter"
- },
- {
- "label": "Kotlin",
- "url": "https://supabase.com/docs/guides/getting-started/quickstarts/android"
- },
- {
- "label": "SvelteKit",
- "url": "https://supabase.com/docs/guides/getting-started/quickstarts/sveltekit"
- },
- {
- "label": "SolidJS",
- "url": "https://supabase.com/docs/guides/getting-started/quickstarts/solidjs"
- },
- {
- "label": "Vue",
- "url": "https://supabase.com/docs/guides/getting-started/quickstarts/vue"
- }
- ],
- "docsGeneral": [
- {
- "icon": "arrowRight",
- "label": "Go to the Dashboard",
- "url": "https://app.supabase.io"
- },
- {
- "icon": "inbox",
- "label": "Read the Changelog",
- "url": "https://supabase.com/changelog"
- }
- ]
-}
diff --git a/packages/ui-patterns/index.tsx b/packages/ui-patterns/index.tsx
index bfd43090dea..70587fabd33 100644
--- a/packages/ui-patterns/index.tsx
+++ b/packages/ui-patterns/index.tsx
@@ -2,6 +2,7 @@
* The components are listed here so that VsCode can find out about them and list them as import suggestions. Don't
* import directly from here.
*/
+export * from './CommandMenu'
export * from './ConsentToast'
export * from './CountdownWidget'
export * from './ExpandableVideo'