mirror of
https://github.com/supabase/supabase.git
synced 2026-10-19 08:09:11 +03:00
* Add a API endpoint for generating queries for the SQL editor. * Merge all multiline props. * Add a new component for diff actions. * Copy components for the AI panel. * Add useChat hook. * Add a feature preview for the this feature. The preview is dependent on the feature flag. * Reorder the nesting in the SQL editor to accomodate the AI assistant. * Try to fit both AI assistants in the SQL editor, available via a feature preview. * Refactor the SQL editor to make the diff work correctly in all cases. * Minor fixes for the old AI feature. * Fix the debug functionality to work with both assistants. * Fix some copy-paste leftovers. * Remove unneeded code. * Make the icons softer. * Fix the name of the panel component. * Fix console.logs. * Add overflow to the AI assistant. * surface opt in config in ai settings button * Skip diffing if editor is empty * Add selected state when selecting a message to insert/replace code * Add sample prompts * Add SQL ai dislaimer when replacing code * Light mode action bar nudges * Add text for the feature preview. * lang nudges * Hide the command suggestions for now. * Set the discussion url to undefined. * Don't add the disclaimer twice. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Terry Sutton <saltcod@gmail.com>
74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
IconChevronDown,
|
|
IconCornerDownLeft,
|
|
IconLoader,
|
|
} from 'ui'
|
|
|
|
import { DiffType } from './SQLEditor.types'
|
|
import { getDiffTypeButtonLabel, getDiffTypeDropdownLabel } from './SQLEditor.utils'
|
|
|
|
type DiffActionBarProps = {
|
|
loading: boolean
|
|
selectedDiffType: DiffType
|
|
onChangeDiffType: (type: DiffType) => void
|
|
onAccept: () => void
|
|
onCancel: () => void
|
|
}
|
|
|
|
export const DiffActionBar = ({
|
|
loading,
|
|
selectedDiffType,
|
|
onChangeDiffType,
|
|
onAccept,
|
|
onCancel,
|
|
}: DiffActionBarProps) => {
|
|
return (
|
|
<>
|
|
<div className="flex items-center">
|
|
<Button
|
|
className="rounded-r-none"
|
|
type="primary"
|
|
size="tiny"
|
|
icon={loading && <IconLoader className="animate-spin" size={14} />}
|
|
iconRight={<IconCornerDownLeft size={12} strokeWidth={1.5} />}
|
|
onClick={onAccept}
|
|
>
|
|
{getDiffTypeButtonLabel(selectedDiffType)}
|
|
</Button>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
type="primary"
|
|
className="rounded-l-none border-l-0 px-[4px] py-[5px] flex"
|
|
icon={<IconChevronDown />}
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" side="bottom">
|
|
{Object.values(DiffType)
|
|
.filter((diffType) => diffType !== selectedDiffType)
|
|
.map((diffType) => (
|
|
<DropdownMenuItem key={diffType} onClick={() => onChangeDiffType(diffType)}>
|
|
<p>{getDiffTypeDropdownLabel(diffType)}</p>
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
<Button
|
|
type="alternative"
|
|
size="tiny"
|
|
className="bg-brand-300 hover:bg-brand-400 dark:bg-brand-400 dark:hover:bg-brand-500 text-brand-600 group"
|
|
iconRight={<span className="dark:text-brand-500 group-hover:text-brand-600">ESC</span>}
|
|
onClick={onCancel}
|
|
>
|
|
Discard
|
|
</Button>
|
|
</>
|
|
)
|
|
}
|