diff --git a/frontend/src/components/forms/workflow.tsx b/frontend/src/components/forms/workflow.tsx index 9ccff9303..0d0ba919a 100644 --- a/frontend/src/components/forms/workflow.tsx +++ b/frontend/src/components/forms/workflow.tsx @@ -29,18 +29,23 @@ const workflowFormSchema = z.object({ description: z.string() }) +interface WorkflowFormProps { + workflowId: string; + workflowTitle: string; + workflowDescription: string; + workflowStatus: string; +} + -export function WorkflowForm(): React.JSX.Element { +export function WorkflowForm({ workflowId, workflowTitle, workflowDescription, workflowStatus }: WorkflowFormProps): React.JSX.Element { - const { selectedWorkflowMetadata, setSelectedWorkflowMetadata } = useSelectedWorkflowMetadata() - const status = selectedWorkflowMetadata.status || "offline" - const statusCapitalized = status[0].toUpperCase() + status.slice(1); + const statusCapitalized = workflowStatus[0].toUpperCase() + workflowStatus.slice(1); const form = useForm>({ resolver: zodResolver(workflowFormSchema), defaultValues: { - title: selectedWorkflowMetadata.title || "", - description: selectedWorkflowMetadata.description || "", + title: workflowTitle || "", + description: workflowDescription || "", }, }) @@ -66,7 +71,7 @@ export function WorkflowForm(): React.JSX.Element { } // TODO: Move get workflow ID logic into panel to ensure order of hooks called - const { mutate } = useUpdateWorkflow(selectedWorkflowMetadata.id); + const { mutate } = useUpdateWorkflow(workflowId); function onSubmit(values: z.infer) { mutate(values); } @@ -78,9 +83,9 @@ export function WorkflowForm(): React.JSX.Element {

Workflow Status

- - - {statusCapitalized} + + + {statusCapitalized} diff --git a/frontend/src/components/panel.tsx b/frontend/src/components/panel.tsx index fb8d5bc61..6ba6f092a 100644 --- a/frontend/src/components/panel.tsx +++ b/frontend/src/components/panel.tsx @@ -4,12 +4,19 @@ import { Skeleton } from "@/components/ui/skeleton" import { WorkflowForm } from "@/components/forms/workflow" import { ActionForm } from "@/components/forms/action" +import { useSelectedWorkflowMetadata } from "@/providers/selected-workflow" export function WorkflowPanel() { const [isActionNodeSelected, setIsActionNodeSelected] = useState(false); const [selectedActionNodeId, setSelectedActionNodeId] = useState(null) + const { selectedWorkflowMetadata, setSelectedWorkflowMetadata } = useSelectedWorkflowMetadata() + // Workflow metadata + const workflowId = selectedWorkflowMetadata.id + const workflowTitle = selectedWorkflowMetadata.title + const workflowDescription = selectedWorkflowMetadata.description + const workflowStatus = selectedWorkflowMetadata.status useOnSelectionChange({ onChange: ({ nodes }: { nodes: Node[] }) => { @@ -24,32 +31,32 @@ export function WorkflowPanel() { } }); - if (isActionNodeSelected && !selectedActionNodeId) { - return ( -
-
-
-
-
- - -
-
-
-
-
- ) - } - return (
{isActionNodeSelected && selectedActionNodeId ? ( - // Make sure selectedActionNodeId is a string when passed as a prop + ) : (!isActionNodeSelected && workflowId && workflowTitle && workflowDescription && workflowStatus) ? ( + ) : ( - +
+
+
+
+
+ + +
+
+
+
+
)}