diff --git a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx index 4ad23f9fcff..bd018484210 100644 --- a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx +++ b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx @@ -282,6 +282,15 @@ const GenerateSQL = () => { )} { + if (inputElement) { + // We need to delay the focus until the end of the call stack + // due to order of operations + setTimeout(() => { + inputElement.focus() + }, 0) + } + }} className="bg-scale-100 rounded mx-3" autoFocus placeholder={ diff --git a/packages/ui/src/components/Input/Input.tsx b/packages/ui/src/components/Input/Input.tsx index a78fade9330..7017131c166 100644 --- a/packages/ui/src/components/Input/Input.tsx +++ b/packages/ui/src/components/Input/Input.tsx @@ -15,7 +15,7 @@ export interface Props extends Omit, disabled?: boolean error?: string icon?: any - inputRef?: string + inputRef?: React.LegacyRef label?: string | React.ReactNode afterLabel?: string beforeLabel?: string diff --git a/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx b/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx index 6ba77a93994..ce0b1ed4db0 100644 --- a/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx +++ b/studio/components/layouts/SQLEditorLayout/SQLEditorMenu.tsx @@ -1,7 +1,17 @@ import { partition } from 'lodash' import { useState, useMemo } from 'react' import { observer } from 'mobx-react-lite' -import { Button, Menu, Input, IconSearch, IconPlus, IconX } from 'ui' +import { + Button, + Menu, + Input, + IconSearch, + IconPlus, + IconX, + Dropdown, + IconChevronDown, + useCommandMenu, +} from 'ui' import { PermissionAction } from '@supabase/shared-types/out/constants' import { checkPermissions, useStore } from 'hooks' @@ -17,6 +27,7 @@ import ShimmeringLoader from 'components/ui/ShimmeringLoader' import QueryItem from './QueryItem' import { createSqlSnippetSkeleton } from 'components/interfaces/SQLEditor/SQLEditor.utils' import { useRouter } from 'next/router' +import { COMMAND_ROUTES } from 'ui/src/components/Command/Command.constants' const SideBarContent = observer(() => { const { ui } = useStore() @@ -24,6 +35,7 @@ const SideBarContent = observer(() => { const router = useRouter() const { data: profile } = useProfileQuery() const [filterString, setFilterString] = useState('') + const { setPages, setIsOpen } = useCommandMenu() const snap = useSqlEditorStateSnapshot() const { isLoading, isSuccess } = useSqlSnippetsQuery(ref, { @@ -83,16 +95,45 @@ const SideBarContent = observer(() => { {IS_PLATFORM && (
- +
+ + { + setIsOpen(true) + setPages([COMMAND_ROUTES.GENERATE_SQL]) + }} + > +
+

New AI query

+

+ Generate a SQL query using Supabase AI +

+
+ , + ]} + > +
}