Change appearance of parameters in task details (#1017)
This commit is contained in:
@@ -1,10 +1,22 @@
|
|||||||
import { useLayoutEffect, useRef } from "react";
|
import { ChangeEventHandler, useLayoutEffect, useRef } from "react";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { cn } from "@/util/utils";
|
import { cn } from "@/util/utils";
|
||||||
|
|
||||||
type Props = React.ComponentPropsWithoutRef<typeof Textarea>;
|
type Props = {
|
||||||
|
value: string;
|
||||||
|
onChange?: ChangeEventHandler<HTMLTextAreaElement>;
|
||||||
|
className?: string;
|
||||||
|
readOnly?: boolean;
|
||||||
|
placeholder?: string;
|
||||||
|
};
|
||||||
|
|
||||||
function AutoResizingTextarea(props: Props) {
|
function AutoResizingTextarea({
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
className,
|
||||||
|
readOnly,
|
||||||
|
placeholder,
|
||||||
|
}: Props) {
|
||||||
const ref = useRef<HTMLTextAreaElement>(null);
|
const ref = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
@@ -25,12 +37,15 @@ function AutoResizingTextarea(props: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Textarea
|
<Textarea
|
||||||
{...props}
|
value={value}
|
||||||
|
onChange={onChange}
|
||||||
|
readOnly={readOnly}
|
||||||
|
placeholder={placeholder}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
onKeyDown={setSize}
|
onKeyDown={setSize}
|
||||||
onInput={setSize}
|
onInput={setSize}
|
||||||
rows={1}
|
rows={1}
|
||||||
className={cn("min-h-0 resize-none overflow-y-hidden", props.className)}
|
className={cn("min-h-0 resize-none overflow-y-hidden", className)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ function TaskDetails() {
|
|||||||
<CodeEditor
|
<CodeEditor
|
||||||
language="json"
|
language="json"
|
||||||
value={JSON.stringify(task.extracted_information, null, 2)}
|
value={JSON.stringify(task.extracted_information, null, 2)}
|
||||||
disabled
|
readOnly
|
||||||
fontSize={12}
|
fontSize={12}
|
||||||
minHeight={"96px"}
|
minHeight={"96px"}
|
||||||
maxHeight={"500px"}
|
maxHeight={"500px"}
|
||||||
@@ -148,7 +148,7 @@ function TaskDetails() {
|
|||||||
<CodeEditor
|
<CodeEditor
|
||||||
language="json"
|
language="json"
|
||||||
value={JSON.stringify(task.failure_reason, null, 2)}
|
value={JSON.stringify(task.failure_reason, null, 2)}
|
||||||
disabled
|
readOnly
|
||||||
fontSize={12}
|
fontSize={12}
|
||||||
minHeight={"96px"}
|
minHeight={"96px"}
|
||||||
maxHeight={"500px"}
|
maxHeight={"500px"}
|
||||||
|
|||||||
@@ -1,18 +1,10 @@
|
|||||||
import { getClient } from "@/api/AxiosClient";
|
import { getClient } from "@/api/AxiosClient";
|
||||||
import { TaskApiResponse } from "@/api/types";
|
import { TaskApiResponse } from "@/api/types";
|
||||||
import {
|
import { AutoResizingTextarea } from "@/components/AutoResizingTextarea/AutoResizingTextarea";
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardDescription,
|
|
||||||
CardHeader,
|
|
||||||
CardTitle,
|
|
||||||
} from "@/components/ui/card";
|
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
|
||||||
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
||||||
import { basicTimeFormat } from "@/util/timeFormat";
|
import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
|
||||||
import { Label, Separator } from "@radix-ui/react-dropdown-menu";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
@@ -44,74 +36,85 @@ function TaskParameters() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<section className="space-y-8 rounded-lg bg-slate-elevation3 px-6 py-5">
|
||||||
<CardHeader className="border-b-2">
|
<div className="flex gap-16">
|
||||||
<CardTitle className="text-xl">Parameters</CardTitle>
|
<div className="w-72">
|
||||||
<CardDescription>Task URL and Input Parameters</CardDescription>
|
<h1 className="text-lg">URL</h1>
|
||||||
</CardHeader>
|
<h2 className="text-base text-slate-400">
|
||||||
<CardContent className="py-8">
|
The starting URL for the task
|
||||||
<div className="flex flex-col gap-8">
|
</h2>
|
||||||
<div className="flex items-center">
|
|
||||||
<Label className="w-40 shrink-0">URL</Label>
|
|
||||||
<Input value={task.request.url} readOnly />
|
|
||||||
</div>
|
|
||||||
<Separator />
|
|
||||||
<div className="flex items-center">
|
|
||||||
<Label className="w-40 shrink-0">Created at</Label>
|
|
||||||
<Input value={basicTimeFormat(task.created_at)} readOnly />
|
|
||||||
</div>
|
|
||||||
<Separator />
|
|
||||||
<div className="flex items-center">
|
|
||||||
<Label className="w-40 shrink-0">Navigation Goal</Label>
|
|
||||||
<Textarea
|
|
||||||
rows={5}
|
|
||||||
value={task.request.navigation_goal ?? ""}
|
|
||||||
readOnly
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Separator />
|
|
||||||
<div className="flex items-center">
|
|
||||||
<Label className="w-40 shrink-0">Navigation Payload</Label>
|
|
||||||
<Textarea
|
|
||||||
rows={5}
|
|
||||||
value={
|
|
||||||
typeof task.request.navigation_payload === "object"
|
|
||||||
? JSON.stringify(task.request.navigation_payload, null, 2)
|
|
||||||
: task.request.navigation_payload
|
|
||||||
}
|
|
||||||
readOnly
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Separator />
|
|
||||||
<div className="flex items-center">
|
|
||||||
<Label className="w-40 shrink-0">Data Extraction Goal</Label>
|
|
||||||
<Textarea
|
|
||||||
rows={5}
|
|
||||||
value={task.request.data_extraction_goal ?? ""}
|
|
||||||
readOnly
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<Label className="w-40 shrink-0">
|
|
||||||
Extracted Information Schema
|
|
||||||
</Label>
|
|
||||||
<Textarea
|
|
||||||
rows={5}
|
|
||||||
value={
|
|
||||||
typeof task.request.extracted_information_schema === "object"
|
|
||||||
? JSON.stringify(
|
|
||||||
task.request.extracted_information_schema,
|
|
||||||
null,
|
|
||||||
2,
|
|
||||||
)
|
|
||||||
: task.request.extracted_information_schema
|
|
||||||
}
|
|
||||||
readOnly
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
<Input value={task.request.url} readOnly />
|
||||||
</Card>
|
</div>
|
||||||
|
<div className="flex gap-16">
|
||||||
|
<div className="w-72">
|
||||||
|
<h1 className="text-lg">Navigation Goal</h1>
|
||||||
|
<h2 className="text-base text-slate-400">
|
||||||
|
Where should Skyvern go and what should Skyvern do?
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<AutoResizingTextarea
|
||||||
|
value={task.request.navigation_goal ?? ""}
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-16">
|
||||||
|
<div className="w-72">
|
||||||
|
<h1 className="text-lg">Navigation Payload</h1>
|
||||||
|
<h2 className="text-base text-slate-400">
|
||||||
|
Specify important parameters, routes, or states
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<CodeEditor
|
||||||
|
className="w-full"
|
||||||
|
language="json"
|
||||||
|
value={
|
||||||
|
typeof task.request.navigation_payload === "object"
|
||||||
|
? JSON.stringify(task.request.navigation_payload, null, 2)
|
||||||
|
: task.request.navigation_payload
|
||||||
|
}
|
||||||
|
readOnly
|
||||||
|
minHeight="96px"
|
||||||
|
maxHeight="500px"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-16">
|
||||||
|
<div className="w-72">
|
||||||
|
<h1 className="text-lg">Data Extraction Goal</h1>
|
||||||
|
<h2 className="text-base text-slate-400">
|
||||||
|
What outputs are you looking to get?
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<AutoResizingTextarea
|
||||||
|
value={task.request.data_extraction_goal ?? ""}
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-16">
|
||||||
|
<div className="w-72">
|
||||||
|
<h1 className="text-lg">Data Schema</h1>
|
||||||
|
<h2 className="text-base text-slate-400">
|
||||||
|
Specify the output format in JSON
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<CodeEditor
|
||||||
|
className="w-full"
|
||||||
|
language="json"
|
||||||
|
value={
|
||||||
|
typeof task.request.extracted_information_schema === "object"
|
||||||
|
? JSON.stringify(
|
||||||
|
task.request.extracted_information_schema,
|
||||||
|
null,
|
||||||
|
2,
|
||||||
|
)
|
||||||
|
: task.request.extracted_information_schema
|
||||||
|
}
|
||||||
|
readOnly
|
||||||
|
minHeight="96px"
|
||||||
|
maxHeight="500px"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ function WorkflowRun() {
|
|||||||
) : (
|
) : (
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
value={JSON.stringify(value, null, 2)}
|
value={JSON.stringify(value, null, 2)}
|
||||||
disabled
|
readOnly
|
||||||
language="json"
|
language="json"
|
||||||
fontSize={12}
|
fontSize={12}
|
||||||
minHeight="96px"
|
minHeight="96px"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type Props = {
|
|||||||
value: string;
|
value: string;
|
||||||
onChange?: (value: string) => void;
|
onChange?: (value: string) => void;
|
||||||
language: "python" | "json";
|
language: "python" | "json";
|
||||||
disabled?: boolean;
|
readOnly?: boolean;
|
||||||
minHeight?: string;
|
minHeight?: string;
|
||||||
maxHeight?: string;
|
maxHeight?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -22,7 +22,7 @@ function CodeEditor({
|
|||||||
maxHeight,
|
maxHeight,
|
||||||
language,
|
language,
|
||||||
className,
|
className,
|
||||||
disabled,
|
readOnly = false,
|
||||||
fontSize = 8,
|
fontSize = 8,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const extensions =
|
const extensions =
|
||||||
@@ -37,7 +37,7 @@ function CodeEditor({
|
|||||||
theme={tokyoNightStorm}
|
theme={tokyoNightStorm}
|
||||||
minHeight={minHeight}
|
minHeight={minHeight}
|
||||||
maxHeight={maxHeight}
|
maxHeight={maxHeight}
|
||||||
readOnly={disabled}
|
readOnly={readOnly}
|
||||||
className={cn("cursor-auto", className)}
|
className={cn("cursor-auto", className)}
|
||||||
style={{
|
style={{
|
||||||
fontSize: fontSize,
|
fontSize: fontSize,
|
||||||
|
|||||||
Reference in New Issue
Block a user