Change position of generate with ai button in data schema (#1739)
This commit is contained in:
@@ -61,20 +61,66 @@ function WorkflowDataSchemaInputGroup({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<div className="flex gap-4">
|
<div className="flex h-7 items-center justify-between">
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-4">
|
||||||
<Label className="text-xs text-slate-300">Data Schema</Label>
|
<div className="flex gap-2">
|
||||||
<HelpTooltip content={helpTooltips["task"]["dataSchema"]} />
|
<Label className="text-xs text-slate-300">Data Schema</Label>
|
||||||
|
<HelpTooltip content={helpTooltips["task"]["dataSchema"]} />
|
||||||
|
</div>
|
||||||
|
<Checkbox
|
||||||
|
checked={value !== "null"}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
onChange(
|
||||||
|
checked ? JSON.stringify(exampleValue, null, 2) : "null",
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Checkbox
|
{value !== "null" && !generateWithAIActive && (
|
||||||
checked={value !== "null"}
|
<Button
|
||||||
onCheckedChange={(checked) => {
|
variant="tertiary"
|
||||||
onChange(checked ? JSON.stringify(exampleValue, null, 2) : "null");
|
className="h-7 text-xs"
|
||||||
}}
|
onClick={() => {
|
||||||
/>
|
setGenerateWithAIActive(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MagicWandIcon className="mr-2 size-4" />
|
||||||
|
Generate with AI
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{value !== "null" && (
|
{value !== "null" && (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
|
{generateWithAIActive ? (
|
||||||
|
<div className="flex w-full items-center rounded-xl border px-4">
|
||||||
|
<Cross2Icon
|
||||||
|
className="size-4 cursor-pointer"
|
||||||
|
onClick={() => {
|
||||||
|
setGenerateWithAIActive(false);
|
||||||
|
setGenerateWithAIPrompt("");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<AutoResizingTextarea
|
||||||
|
className="min-h-0 resize-none rounded-md border-transparent px-4 py-2 text-xs hover:border-transparent focus-visible:ring-0"
|
||||||
|
value={generateWithAIPrompt}
|
||||||
|
onChange={(event) => {
|
||||||
|
setGenerateWithAIPrompt(event.target.value);
|
||||||
|
}}
|
||||||
|
placeholder="Describe how you want your output formatted"
|
||||||
|
/>
|
||||||
|
{getDataSchemaSuggestionMutation.isPending ? (
|
||||||
|
<ReloadIcon className="size-4 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<PaperPlaneIcon
|
||||||
|
className="size-4 cursor-pointer"
|
||||||
|
onClick={() => {
|
||||||
|
getDataSchemaSuggestionMutation.mutate();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
language="json"
|
language="json"
|
||||||
value={value}
|
value={value}
|
||||||
@@ -82,47 +128,6 @@ function WorkflowDataSchemaInputGroup({
|
|||||||
className="nowheel nopan"
|
className="nowheel nopan"
|
||||||
fontSize={8}
|
fontSize={8}
|
||||||
/>
|
/>
|
||||||
{value !== "null" &&
|
|
||||||
(generateWithAIActive ? (
|
|
||||||
<div className="flex w-full items-center rounded-xl border px-4">
|
|
||||||
<Cross2Icon
|
|
||||||
className="size-4"
|
|
||||||
onClick={() => {
|
|
||||||
setGenerateWithAIActive(false);
|
|
||||||
setGenerateWithAIPrompt("");
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<AutoResizingTextarea
|
|
||||||
className="min-h-0 resize-none rounded-md border-transparent px-4 py-2 text-xs hover:border-transparent focus-visible:ring-0"
|
|
||||||
value={generateWithAIPrompt}
|
|
||||||
onChange={(event) => {
|
|
||||||
setGenerateWithAIPrompt(event.target.value);
|
|
||||||
}}
|
|
||||||
placeholder="Describe how you want your output formatted"
|
|
||||||
/>
|
|
||||||
{getDataSchemaSuggestionMutation.isPending ? (
|
|
||||||
<ReloadIcon className="size-4 animate-spin" />
|
|
||||||
) : (
|
|
||||||
<PaperPlaneIcon
|
|
||||||
className="size-4"
|
|
||||||
onClick={() => {
|
|
||||||
getDataSchemaSuggestionMutation.mutate();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<Button
|
|
||||||
variant="tertiary"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => {
|
|
||||||
setGenerateWithAIActive(true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<MagicWandIcon className="mr-2 size-4" />
|
|
||||||
Generate with AI
|
|
||||||
</Button>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user