Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,68 +61,73 @@ function WorkflowDataSchemaInputGroup({

return (
<div className="space-y-2">
<div className="flex gap-4">
<div className="flex gap-2">
<Label className="text-xs text-slate-300">Data Schema</Label>
<HelpTooltip content={helpTooltips["task"]["dataSchema"]} />
<div className="flex h-7 items-center justify-between">
<div className="flex gap-4">
<div className="flex gap-2">
<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>
<Checkbox
checked={value !== "null"}
onCheckedChange={(checked) => {
onChange(checked ? JSON.stringify(exampleValue, null, 2) : "null");
}}
/>
{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" && (
<div className="space-y-2">
{generateWithAIActive ? (
<div className="flex w-full items-center rounded-xl border px-4">
<Cross2Icon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clickable icons (Cross2Icon and PaperPlaneIcon) should include accessible labels (e.g., aria-label) for improved accessibility.

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
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">
<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>
Expand Down
Loading