From c887eb7094535e335ece5e744855fbbd200c3032 Mon Sep 17 00:00:00 2001 From: Chris Lo <46541035+topher-lo@users.noreply.github.com> Date: Mon, 20 May 2024 23:37:31 -0700 Subject: [PATCH 1/4] feat(ui): Update default open settings --- frontend/src/components/workspace/panel/workflow/controls.tsx | 4 ++-- frontend/src/components/workspace/panel/workflow/form.tsx | 2 +- frontend/src/components/workspace/panel/workflow/runs.tsx | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/workspace/panel/workflow/controls.tsx b/frontend/src/components/workspace/panel/workflow/controls.tsx index ddcc4adfc..201d18088 100644 --- a/frontend/src/components/workspace/panel/workflow/controls.tsx +++ b/frontend/src/components/workspace/panel/workflow/controls.tsx @@ -103,8 +103,8 @@ export function WorkflowControlsForm({ return ( - - + +
diff --git a/frontend/src/components/workspace/panel/workflow/form.tsx b/frontend/src/components/workspace/panel/workflow/form.tsx index a51dff704..2787b9727 100644 --- a/frontend/src/components/workspace/panel/workflow/form.tsx +++ b/frontend/src/components/workspace/panel/workflow/form.tsx @@ -109,7 +109,7 @@ export function WorkflowForm({
- +
diff --git a/frontend/src/components/workspace/panel/workflow/runs.tsx b/frontend/src/components/workspace/panel/workflow/runs.tsx index 378e432c2..ea698524c 100644 --- a/frontend/src/components/workspace/panel/workflow/runs.tsx +++ b/frontend/src/components/workspace/panel/workflow/runs.tsx @@ -56,8 +56,8 @@ export function WorkflowRunsView({ }, }) return ( - - + +
From 0142a63653d6ba5dfed98febbb4bc4e42b41532b Mon Sep 17 00:00:00 2001 From: Chris Lo <46541035+topher-lo@users.noreply.github.com> Date: Tue, 21 May 2024 02:49:42 -0700 Subject: [PATCH 2/4] Action form header --- .../workspace/canvas/action-node.tsx | 8 +- .../workspace/panel/action/form.tsx | 395 +++++++++--------- .../workspace/panel/workflow/form.tsx | 2 +- .../workspace/panel/workspace-panel.tsx | 2 +- 4 files changed, 205 insertions(+), 202 deletions(-) diff --git a/frontend/src/components/workspace/canvas/action-node.tsx b/frontend/src/components/workspace/canvas/action-node.tsx index 36507ae6a..4c91ae491 100644 --- a/frontend/src/components/workspace/canvas/action-node.tsx +++ b/frontend/src/components/workspace/canvas/action-node.tsx @@ -30,7 +30,7 @@ import { Handle, NodeProps, Position, useNodeId, type Node } from "reactflow" import { type ActionType } from "@/types/schemas" import { cn, copyToClipboard, slugify } from "@/lib/utils" -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" +import { Avatar, AvatarFallback } from "@/components/ui/avatar" import { Button } from "@/components/ui/button" import { Card, @@ -107,7 +107,7 @@ export function getTileColor( return defaultColor } -const typeToNodeSubtitle: Record = { +export const typeToNodeSubtitle: Record = { webhook: "Webhook", http_request: "HTTP Request", data_transform: "Data Transform", @@ -135,7 +135,6 @@ export default React.memo(function ActionNode({ const tileIcon = tileIconMapping[type] ?? Sparkles const isConfiguredMessage = isConfigured ? "ready" : "missing inputs" const { toast } = useToast() - const avatarImageAlt = `${type}-${title}` const handleCopyToClipboard = useCallback(() => { const slug = slugify(title) @@ -175,10 +174,9 @@ export default React.memo(function ActionNode({ return ( - +
- {React.createElement(tileIcon, { className: "h-5 w-5" })} diff --git a/frontend/src/components/workspace/panel/action/form.tsx b/frontend/src/components/workspace/panel/action/form.tsx index 1c3b5197c..0b2075e55 100644 --- a/frontend/src/components/workspace/panel/action/form.tsx +++ b/frontend/src/components/workspace/panel/action/form.tsx @@ -2,17 +2,15 @@ import React from "react" import { useWorkflowBuilder } from "@/providers/builder" import { zodResolver } from "@hookform/resolvers/zod" import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" -import { CircleIcon, Save } from "lucide-react" +import { SaveIcon, Sparkles } from "lucide-react" import { FormProvider, useForm } from "react-hook-form" -import SyntaxHighlighter from "react-syntax-highlighter" -import { atomOneDark } from "react-syntax-highlighter/dist/esm/styles/hljs" import { z } from "zod" import { Action, type ActionType } from "@/types/schemas" import { getActionById, updateAction } from "@/lib/flow" import { cn } from "@/lib/utils" -import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { FormControl, FormField, @@ -29,10 +27,9 @@ import { TooltipTrigger, } from "@/components/ui/tooltip" import { toast } from "@/components/ui/use-toast" -import { CollapsibleSection } from "@/components/collapsible-section" import { FormLoading } from "@/components/loading/form" import { AlertNotification } from "@/components/notifications" -import { ActionNodeType } from "@/components/workspace/canvas/action-node" +import { ActionNodeType, getTileColor, typeToNodeSubtitle, tileIconMapping } from "@/components/workspace/canvas/action-node" import { baseActionSchema, getSubActionSchema, @@ -114,11 +111,18 @@ export function ActionForm({ }, }) // Set the initial form values + // TODO: More robust handling of undefined values + const type = action?.type ?? "webhook" + const title = action?.title ?? "" + const description = action?.description ?? "" + const subtitle = typeToNodeSubtitle[type as keyof typeof typeToNodeSubtitle]; + const tileIcon = tileIconMapping[actionType] ?? Sparkles + const methods = useForm({ resolver: zodResolver(schema), values: { - title: action?.title ?? "", - description: action?.description ?? "", + title: title, + description: description, ...(action?.inputs ? processInputs(action.inputs) : {}), // Unpack the inputs object }, }) @@ -169,199 +173,200 @@ export function ActionForm({ mutate(values) }) - const status = "online" return ( -
+ //
+ // + //
+ // ( + // + // Title + // + // + // + // + // + // )} + // /> + // ( + // + // Description + // + //