Change position of generate with ai button in data schema (#1739)

This commit is contained in:
Shuchang Zheng
2025-02-06 23:33:54 +08:00
committed by GitHub
parent 9f14224589
commit 1f308fffc4

View File

@@ -61,6 +61,7 @@ function WorkflowDataSchemaInputGroup({
return ( return (
<div className="space-y-2"> <div className="space-y-2">
<div className="flex h-7 items-center justify-between">
<div className="flex gap-4"> <div className="flex gap-4">
<div className="flex gap-2"> <div className="flex gap-2">
<Label className="text-xs text-slate-300">Data Schema</Label> <Label className="text-xs text-slate-300">Data Schema</Label>
@@ -69,24 +70,32 @@ function WorkflowDataSchemaInputGroup({
<Checkbox <Checkbox
checked={value !== "null"} checked={value !== "null"}
onCheckedChange={(checked) => { onCheckedChange={(checked) => {
onChange(checked ? JSON.stringify(exampleValue, null, 2) : "null"); onChange(
checked ? JSON.stringify(exampleValue, null, 2) : "null",
);
}} }}
/> />
</div> </div>
{value !== "null" && !generateWithAIActive && (
<Button
variant="tertiary"
className="h-7 text-xs"
onClick={() => {
setGenerateWithAIActive(true);
}}
>
<MagicWandIcon className="mr-2 size-4" />
Generate with AI
</Button>
)}
</div>
{value !== "null" && ( {value !== "null" && (
<div className="space-y-2"> <div className="space-y-2">
<CodeEditor {generateWithAIActive ? (
language="json"
value={value}
onChange={onChange}
className="nowheel nopan"
fontSize={8}
/>
{value !== "null" &&
(generateWithAIActive ? (
<div className="flex w-full items-center rounded-xl border px-4"> <div className="flex w-full items-center rounded-xl border px-4">
<Cross2Icon <Cross2Icon
className="size-4" className="size-4 cursor-pointer"
onClick={() => { onClick={() => {
setGenerateWithAIActive(false); setGenerateWithAIActive(false);
setGenerateWithAIPrompt(""); setGenerateWithAIPrompt("");
@@ -104,25 +113,21 @@ function WorkflowDataSchemaInputGroup({
<ReloadIcon className="size-4 animate-spin" /> <ReloadIcon className="size-4 animate-spin" />
) : ( ) : (
<PaperPlaneIcon <PaperPlaneIcon
className="size-4" className="size-4 cursor-pointer"
onClick={() => { onClick={() => {
getDataSchemaSuggestionMutation.mutate(); getDataSchemaSuggestionMutation.mutate();
}} }}
/> />
)} )}
</div> </div>
) : ( ) : null}
<Button <CodeEditor
variant="tertiary" language="json"
size="sm" value={value}
onClick={() => { onChange={onChange}
setGenerateWithAIActive(true); className="nowheel nopan"
}} fontSize={8}
> />
<MagicWandIcon className="mr-2 size-4" />
Generate with AI
</Button>
))}
</div> </div>
)} )}
</div> </div>