|
9 | 9 | RefreshCw, |
10 | 10 | Trash2, |
11 | 11 | } from "lucide-react"; |
12 | | -import { useCallback, useMemo, useRef, useState } from "react"; |
| 12 | +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; |
13 | 13 | import { toast } from "sonner"; |
14 | 14 | import { |
15 | 15 | AlertDialog, |
@@ -181,6 +181,23 @@ export const PanelInner = () => { |
181 | 181 | const selectedEdges = edges.filter((edge) => edge.selected); |
182 | 182 | const hasMultipleSelections = selectedNodes.length + selectedEdges.length > 1; |
183 | 183 |
|
| 184 | + // Switch to Properties tab if Code tab is hidden for the selected node |
| 185 | + useEffect(() => { |
| 186 | + if (!selectedNode || activeTab !== "code") { |
| 187 | + return; |
| 188 | + } |
| 189 | + |
| 190 | + const isConditionAction = |
| 191 | + selectedNode.data.config?.actionType === "Condition"; |
| 192 | + const isManualTrigger = |
| 193 | + selectedNode.data.type === "trigger" && |
| 194 | + selectedNode.data.config?.triggerType === "Manual"; |
| 195 | + |
| 196 | + if (isConditionAction || isManualTrigger) { |
| 197 | + setActiveTab("properties"); |
| 198 | + } |
| 199 | + }, [selectedNode, activeTab, setActiveTab]); |
| 200 | + |
184 | 201 | // Generate workflow code |
185 | 202 | const workflowCode = useMemo(() => { |
186 | 203 | const baseName = |
@@ -668,8 +685,9 @@ export const PanelInner = () => { |
668 | 685 | > |
669 | 686 | Properties |
670 | 687 | </TabsTrigger> |
671 | | - {selectedNode.data.type !== "trigger" || |
672 | | - (selectedNode.data.config?.triggerType as string) !== "Manual" ? ( |
| 688 | + {(selectedNode.data.type !== "trigger" || |
| 689 | + (selectedNode.data.config?.triggerType as string) !== "Manual") && |
| 690 | + selectedNode.data.config?.actionType !== "Condition" ? ( |
673 | 691 | <TabsTrigger |
674 | 692 | className="bg-transparent text-muted-foreground data-[state=active]:text-foreground data-[state=active]:shadow-none" |
675 | 693 | value="code" |
|
0 commit comments