mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
Add new command menu to studio. Ports over commands from old menu (with some minor reorganization), then adds: - Branch switcher - Project switcher
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { useIsLoggedIn } from 'common'
|
|
import { useAppStateSnapshot } from 'state/app-state'
|
|
import { AiIconAnimation } from 'ui'
|
|
import { BadgeExperimental, useRegisterCommands, useSetQuery } from 'ui-patterns/CommandMenu'
|
|
import { orderCommandSectionsByPriority } from '../App/CommandMenu/ordering'
|
|
import { COMMAND_MENU_SECTIONS } from '../App/CommandMenu/CommandMenu.utils'
|
|
|
|
export function useGenerateSqlCommand() {
|
|
const isLoggedIn = useIsLoggedIn()
|
|
|
|
const { setShowGenerateSqlModal } = useAppStateSnapshot()
|
|
const setQuery = useSetQuery()
|
|
|
|
useRegisterCommands(
|
|
COMMAND_MENU_SECTIONS.QUERY,
|
|
[
|
|
{
|
|
id: 'generate-sql-ai',
|
|
name: 'Run SQL with Supabase AI',
|
|
action: () => {
|
|
setShowGenerateSqlModal(true)
|
|
setQuery('')
|
|
},
|
|
icon: () => <AiIconAnimation allowHoverEffect />,
|
|
badge: () => <BadgeExperimental />,
|
|
},
|
|
],
|
|
{
|
|
enabled: isLoggedIn,
|
|
orderSection: orderCommandSectionsByPriority,
|
|
sectionMeta: { priority: 2 },
|
|
}
|
|
)
|
|
}
|