Files
supabase/apps/studio/components/interfaces/SqlGenerator/SqlGenerator.Commands.tsx
T
Charis 84732ff44c feat: add new command menu to studio (#28432)
Add new command menu to studio. Ports over commands from old menu (with some minor reorganization), then adds:
- Branch switcher
- Project switcher
2024-08-08 16:42:07 -04:00

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 },
}
)
}