Skip to content

Commit 16348ea

Browse files
committed
Add debug mode for viewing ReactFlow Node ids
1 parent bdff2a9 commit 16348ea

File tree

5 files changed

+95
-25
lines changed

5 files changed

+95
-25
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ VITE_ENABLE_GOOGLE_CLOUD_SUBMITTER=<boolean>
1717

1818
# Github
1919
VITE_REQUIRE_AUTHORIZATION=<boolean>
20-
VITE_GITHUB_CLIENT_ID=<string>
20+
VITE_GITHUB_CLIENT_ID=<string>
21+
22+
# Dev Tools
23+
VITE_ENABLE_DEBUG_MODE=<boolean>

src/components/shared/ReactFlow/FlowCanvas/IONode/IONode.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Handle, Position } from "@xyflow/react";
2-
import { memo, useEffect, useMemo } from "react";
2+
import { memo, useCallback, useEffect, useMemo } from "react";
33

44
import { InputValueEditor } from "@/components/Editor/IOEditor/InputValueEditor";
55
import { OutputNameEditor } from "@/components/Editor/IOEditor/OutputNameEditor";
@@ -12,6 +12,13 @@ import { useComponentSpec } from "@/providers/ComponentSpecProvider";
1212
import { useContextPanel } from "@/providers/ContextPanelProvider";
1313
import type { IONodeData } from "@/types/nodes";
1414
import type { InputSpec, TypeSpecType } from "@/utils/componentSpec";
15+
import { ENABLE_DEBUG_MODE } from "@/utils/constants";
16+
import {
17+
inputIdToNodeId,
18+
inputNameToInputId,
19+
outputIdToNodeId,
20+
outputNameToOutputId,
21+
} from "@/utils/nodes/conversions";
1522

1623
interface IONodeProps {
1724
type: "input" | "output";
@@ -51,6 +58,22 @@ const IONode = ({ type, data, selected = false }: IONodeProps) => {
5158
[componentSpec.outputs, spec.name],
5259
);
5360

61+
const nodeId = isInput
62+
? inputIdToNodeId(inputNameToInputId(spec.name))
63+
: outputIdToNodeId(outputNameToOutputId(spec.name));
64+
65+
const nodeHandleId = `${nodeId}_handle`;
66+
67+
const handleHandleClick = useCallback(() => {
68+
if (ENABLE_DEBUG_MODE) {
69+
console.log(`${isInput ? "Input" : "Output"} Node Handle clicked:`, {
70+
name: isInput ? input?.name : output?.name,
71+
nodeId,
72+
handleId: nodeHandleId,
73+
});
74+
}
75+
}, [isInput, input, output, nodeId, nodeHandleId]);
76+
5477
useEffect(() => {
5578
if (selected) {
5679
if (input && isInput) {
@@ -112,6 +135,11 @@ const IONode = ({ type, data, selected = false }: IONodeProps) => {
112135
<Card className={cn("border-2 max-w-[300px] p-0", borderColor)}>
113136
<CardHeader className="px-2 py-2.5">
114137
<CardTitle className="break-words">{spec.name}</CardTitle>
138+
{ENABLE_DEBUG_MODE && (
139+
<Paragraph size="xs" tone="subdued">
140+
Node Id: {nodeId}
141+
</Paragraph>
142+
)}
115143
</CardHeader>
116144
<CardContent className="p-2 max-w-[250px]">
117145
<BlockStack gap="2">
@@ -150,6 +178,7 @@ const IONode = ({ type, data, selected = false }: IONodeProps) => {
150178
type={handleType}
151179
position={handlePosition}
152180
className={cn(handleDefaultClassName, handleClassName)}
181+
onClick={handleHandleClick}
153182
/>
154183
</CardContent>
155184
</Card>

src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/Handles.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { cn } from "@/lib/utils";
1515
import { useTaskNode } from "@/providers/TaskNodeProvider";
1616
import type { InputSpec, OutputSpec } from "@/utils/componentSpec";
17+
import { ENABLE_DEBUG_MODE } from "@/utils/constants";
1718

1819
type InputHandleProps = {
1920
input: InputSpec;
@@ -32,7 +33,7 @@ export const InputHandle = ({
3233
onLabelClick,
3334
onHandleSelectionChange,
3435
}: InputHandleProps) => {
35-
const { nodeId, state } = useTaskNode();
36+
const { nodeId, state, name } = useTaskNode();
3637

3738
const fromHandle = useConnection((connection) => connection.fromHandle?.id);
3839
const toHandle = useConnection((connection) => connection.toHandle?.id);
@@ -54,8 +55,17 @@ export const InputHandle = ({
5455
(e: ReactMouseEvent<HTMLDivElement>) => {
5556
e.stopPropagation();
5657
setSelected(!selected);
58+
59+
if (ENABLE_DEBUG_MODE) {
60+
console.log("Input Handle clicked:", {
61+
name: input.name,
62+
handleId,
63+
nodeId,
64+
taskName: name,
65+
});
66+
}
5767
},
58-
[selected],
68+
[selected, name, input, handleId, nodeId],
5969
);
6070

6171
const handleLabelClick = useCallback(
@@ -218,7 +228,7 @@ export const OutputHandle = ({
218228
onLabelClick,
219229
onHandleSelectionChange,
220230
}: OutputHandleProps) => {
221-
const { nodeId, state } = useTaskNode();
231+
const { nodeId, state, name } = useTaskNode();
222232

223233
const fromHandle = useConnection((connection) => connection.fromHandle?.id);
224234
const toHandle = useConnection((connection) => connection.toHandle?.id);
@@ -237,8 +247,17 @@ export const OutputHandle = ({
237247
(e: ReactMouseEvent<HTMLDivElement>) => {
238248
e.stopPropagation();
239249
setSelected(!selected);
250+
251+
if (ENABLE_DEBUG_MODE) {
252+
console.log("Output Handle clicked:", {
253+
name: output.name,
254+
handleId,
255+
nodeId,
256+
taskName: name,
257+
});
258+
}
240259
},
241-
[selected],
260+
[selected, output, handleId, nodeId, name],
242261
);
243262

244263
const handleLabelClick = useCallback(

src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/TaskNodeCard.tsx

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import { PublishedComponentBadge } from "@/components/shared/ManageComponent/Pub
66
import { trimDigest } from "@/components/shared/ManageComponent/utils/digest";
77
import { useBetaFlagValue } from "@/components/shared/Settings/useBetaFlags";
88
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
9-
import { BlockStack } from "@/components/ui/layout";
9+
import { BlockStack, InlineStack } from "@/components/ui/layout";
1010
import { QuickTooltip } from "@/components/ui/tooltip";
1111
import { Text } from "@/components/ui/typography";
1212
import { cn } from "@/lib/utils";
1313
import { useContextPanel } from "@/providers/ContextPanelProvider";
1414
import { useTaskNode } from "@/providers/TaskNodeProvider";
15+
import { ENABLE_DEBUG_MODE } from "@/utils/constants";
1516

1617
import {
1718
type NotifyMessage,
@@ -172,27 +173,42 @@ const TaskNodeCard = () => {
172173
}}
173174
ref={nodeRef}
174175
>
175-
<CardHeader className="border-b border-slate-200 px-2 py-2.5 flex flex-row justify-between items-start">
176+
<CardHeader className="border-b border-slate-200 px-2 py-2.5 items-start">
176177
<BlockStack>
177-
<CardTitle className="break-words text-left text-xs text-slate-900">
178-
{name}
179-
</CardTitle>
180-
{taskId &&
181-
taskId !== name &&
182-
!taskId.match(new RegExp(`^${name}\\s*\\d+$`)) && (
183-
<Text size="xs" tone="subdued" className="font-light">
184-
{taskId}
185-
</Text>
178+
<InlineStack
179+
align="space-between"
180+
blockAlign="start"
181+
wrap="nowrap"
182+
className="w-full"
183+
>
184+
<BlockStack>
185+
<CardTitle className="break-words text-left text-xs text-slate-900">
186+
{name}
187+
</CardTitle>
188+
{taskId &&
189+
taskId !== name &&
190+
!taskId.match(new RegExp(`^${name}\\s*\\d+$`)) && (
191+
<Text size="xs" tone="subdued" className="font-light">
192+
{taskId}
193+
</Text>
194+
)}
195+
</BlockStack>
196+
197+
{isRemoteComponentLibrarySearchEnabled ? (
198+
<PublishedComponentBadge componentRef={taskSpec.componentRef}>
199+
{digestMarkup}
200+
</PublishedComponentBadge>
201+
) : (
202+
digestMarkup
186203
)}
187-
</BlockStack>
204+
</InlineStack>
188205

189-
{isRemoteComponentLibrarySearchEnabled ? (
190-
<PublishedComponentBadge componentRef={taskSpec.componentRef}>
191-
{digestMarkup}
192-
</PublishedComponentBadge>
193-
) : (
194-
digestMarkup
195-
)}
206+
{ENABLE_DEBUG_MODE && (
207+
<Text size="xs" tone="subdued">
208+
Node Id: {nodeId}
209+
</Text>
210+
)}
211+
</BlockStack>
196212
</CardHeader>
197213
<CardContent className="p-2 flex flex-col gap-2">
198214
<div

src/utils/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* Environment Config */
2+
export const ENABLE_DEBUG_MODE =
3+
import.meta.env.VITE_ENABLE_DEBUG_MODE === "true";
4+
25
export const ABOUT_URL =
36
import.meta.env.VITE_ABOUT_URL || "https://cloud-pipelines.net/";
47

0 commit comments

Comments
 (0)