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

Move navigation payload to base content #894

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
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
92 changes: 62 additions & 30 deletions skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function CreateNewTaskForm({ initialValues }: Props) {
const [section, setSection] = useState<"base" | "extraction" | "advanced">(
"base",
);
const [showAdvancedBaseContent, setShowAdvancedBaseContent] = useState(false);

const form = useForm<CreateNewTaskFormValues>({
resolver: zodResolver(createNewTaskFormSchema),
Expand Down Expand Up @@ -233,6 +234,67 @@ function CreateNewTaskForm({ initialValues }: Props) {
</FormItem>
)}
/>
{showAdvancedBaseContent ? (
<div className="border-t border-dashed pt-4">
<FormField
control={form.control}
name="navigationPayload"
render={({ field }) => (
<FormItem>
<div className="flex gap-16">
<FormLabel>
<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>
<Button
className="mt-4"
type="button"
variant="tertiary"
onClick={() => {
setShowAdvancedBaseContent(false);
}}
size="sm"
>
Hide Advanced Settings
</Button>
</FormLabel>
<div className="w-full">
<FormControl>
<CodeEditor
{...field}
language="json"
fontSize={12}
minHeight="96px"
value={
field.value === null ? "" : field.value
}
/>
</FormControl>
<FormMessage />
</div>
</div>
</FormItem>
)}
/>
</div>
) : (
<div>
<Button
type="button"
variant="tertiary"
onClick={() => {
setShowAdvancedBaseContent(true);
}}
size="sm"
>
Show Advanced Settings
</Button>
</div>
)}
</div>
</div>
)}
Expand Down Expand Up @@ -331,36 +393,6 @@ function CreateNewTaskForm({ initialValues }: Props) {
{section === "advanced" && (
<div className="space-y-6">
<div className="space-y-4">
<FormField
control={form.control}
name="navigationPayload"
render={({ field }) => (
<FormItem>
<div className="flex gap-16">
<FormLabel>
<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>
</FormLabel>
<div className="w-full">
<FormControl>
<CodeEditor
{...field}
language="json"
fontSize={12}
minHeight="96px"
value={field.value === null ? "" : field.value}
/>
</FormControl>
<FormMessage />
</div>
</div>
</FormItem>
)}
/>
<FormField
control={form.control}
name="maxStepsOverride"
Expand Down
97 changes: 62 additions & 35 deletions skyvern-frontend/src/routes/tasks/create/SavedTaskForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function SavedTaskForm({ initialValues }: Props) {
const [section, setSection] = useState<"base" | "extraction" | "advanced">(
"base",
);
const [showAdvancedBaseContent, setShowAdvancedBaseContent] = useState(false);

const form = useForm<SavedTaskFormValues>({
resolver: zodResolver(savedTaskFormSchema),
Expand Down Expand Up @@ -398,6 +399,67 @@ function SavedTaskForm({ initialValues }: Props) {
</FormItem>
)}
/>
{showAdvancedBaseContent ? (
<div className="border-t border-dashed pt-4">
<FormField
control={form.control}
name="navigationPayload"
render={({ field }) => (
<FormItem>
<div className="flex gap-16">
<FormLabel>
<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>
<Button
className="mt-4"
type="button"
variant="tertiary"
onClick={() => {
setShowAdvancedBaseContent(false);
}}
size="sm"
>
Hide Advanced Settings
</Button>
</FormLabel>
<div className="w-full">
<FormControl>
<CodeEditor
{...field}
language="json"
fontSize={12}
minHeight="96px"
value={
field.value === null ? "" : field.value
}
/>
</FormControl>
<FormMessage />
</div>
</div>
</FormItem>
)}
/>
</div>
) : (
<div>
<Button
type="button"
variant="tertiary"
onClick={() => {
setShowAdvancedBaseContent(true);
}}
size="sm"
>
Show Advanced Settings
</Button>
</div>
)}
</div>
</div>
)}
Expand Down Expand Up @@ -497,41 +559,6 @@ function SavedTaskForm({ initialValues }: Props) {
{section === "advanced" && (
<div className="space-y-6">
<div className="space-y-4">
<FormField
control={form.control}
name="navigationPayload"
render={({ field }) => (
<FormItem>
<div className="flex gap-16">
<FormLabel>
<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>
</FormLabel>
<div className="w-full">
<FormControl>
<CodeEditor
{...field}
language="json"
fontSize={12}
minHeight="96px"
value={
field.value === null ||
typeof field.value === "undefined"
? ""
: field.value
}
/>
</FormControl>
<FormMessage />
</div>
</div>
</FormItem>
)}
/>
<FormField
control={form.control}
name="maxStepsOverride"
Expand Down
Loading