Skip to content

Commit 427232c

Browse files
committed
eslint fix
1 parent 3f4f91a commit 427232c

5 files changed

Lines changed: 98 additions & 82 deletions

File tree

apps/chaingraph-frontend/src/components/flow/nodes/ChaingraphNode/NodeHeader.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,27 @@ export function NodeHeader({
156156
<div className="flex items-center gap-2 min-w-0 relative">
157157
{headerData?.categoryMetadata
158158
? (
159-
<LazyNodeDocTooltip
160-
nodeId={nodeId}
161-
categoryMetadata={headerData.categoryMetadata}
162-
className="cursor-pointer"
163-
>
159+
<LazyNodeDocTooltip
160+
nodeId={nodeId}
161+
categoryMetadata={headerData.categoryMetadata}
162+
className="cursor-pointer"
163+
>
164+
<div
165+
className="w-6 min-w-6 h-6 rounded flex items-center justify-center hover:opacity-80 transition-opacity"
166+
style={{
167+
background: `${style.text}20`,
168+
}}
169+
>
170+
<Icon
171+
className="w-4 h-4"
172+
style={{ color: style.text }}
173+
/>
174+
</div>
175+
</LazyNodeDocTooltip>
176+
)
177+
: (
164178
<div
165-
className="w-6 min-w-6 h-6 rounded flex items-center justify-center hover:opacity-80 transition-opacity"
179+
className="w-6 min-w-6 h-6 rounded flex items-center justify-center"
166180
style={{
167181
background: `${style.text}20`,
168182
}}
@@ -172,21 +186,7 @@ export function NodeHeader({
172186
style={{ color: style.text }}
173187
/>
174188
</div>
175-
</LazyNodeDocTooltip>
176-
)
177-
: (
178-
<div
179-
className="w-6 min-w-6 h-6 rounded flex items-center justify-center"
180-
style={{
181-
background: `${style.text}20`,
182-
}}
183-
>
184-
<Icon
185-
className="w-4 h-4"
186-
style={{ color: style.text }}
187-
/>
188-
</div>
189-
)}
189+
)}
190190

191191
<EditableNodeTitle
192192
nodeId={nodeId}

apps/chaingraph-frontend/src/components/flow/nodes/GroupNode/GroupNode.tsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -175,34 +175,34 @@ function GroupNodeComponent({
175175
>
176176
{hasTitle || isEditing
177177
? (
178-
<EditableTitle
179-
value={renderData?.title || ''}
180-
onChange={handleTitleChange}
181-
isEditing={isEditing}
182-
onEditingChange={setIsEditing}
183-
className={cn(
184-
'text-xl leading-tight',
185-
'max-w-full',
186-
)}
187-
/>
188-
)
178+
<EditableTitle
179+
value={renderData?.title || ''}
180+
onChange={handleTitleChange}
181+
isEditing={isEditing}
182+
onEditingChange={setIsEditing}
183+
className={cn(
184+
'text-xl leading-tight',
185+
'max-w-full',
186+
)}
187+
/>
188+
)
189189
: (
190-
<Button
191-
variant="ghost"
192-
size="sm"
193-
className={cn(
194-
'text-muted-foreground/60',
195-
'hover:text-muted-foreground',
196-
'transition-colors',
197-
'flex items-center gap-2',
198-
'w-fit',
199-
)}
200-
onClick={() => setIsEditing(true)}
201-
>
202-
<Plus className="w-4 h-4" />
203-
<span>Add Title</span>
204-
</Button>
205-
)}
190+
<Button
191+
variant="ghost"
192+
size="sm"
193+
className={cn(
194+
'text-muted-foreground/60',
195+
'hover:text-muted-foreground',
196+
'transition-colors',
197+
'flex items-center gap-2',
198+
'w-fit',
199+
)}
200+
onClick={() => setIsEditing(true)}
201+
>
202+
<Plus className="w-4 h-4" />
203+
<span>Add Title</span>
204+
</Button>
205+
)}
206206
</div>
207207

208208
</div>

apps/chaingraph-frontend/src/store/nodes/hooks/useXYFlowNodes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
* As of the Change Date specified in that file, in accordance with the Business Source License, use of this software will be governed by the Apache License, version 2.0.
77
*/
88

9-
import type { Node } from '@xyflow/react'
109
import { useStoreMap } from 'effector-react'
11-
import { useMemo, useRef } from 'react'
1210
import { $combinedXYFlowNodesList as $xyflowNodes } from '@/store/xyflow/stores'
1311

1412
/**

apps/chaingraph-frontend/src/store/nodes/stores.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import type { INode, NodeUIStyle, Position } from '@badaitech/chaingraph-types'
10-
import { isDeepEqual } from '@badaitech/chaingraph-types'
1110
import type {
1211
AddNodeEvent,
1312
NodeState,
@@ -18,6 +17,7 @@ import type {
1817
UpdateNodeTitleEvent,
1918
UpdateNodeUIEvent,
2019
} from './types'
20+
import { isDeepEqual } from '@badaitech/chaingraph-types'
2121
import { DefaultPosition } from '@badaitech/chaingraph-types'
2222

2323
import { combine, sample } from 'effector'
@@ -575,7 +575,8 @@ function extractNodeUIState(node: INode): NodeUIState {
575575
// Helper to check if UI state changed - uses isDeepEqual for type-safety
576576
// (new fields automatically compared, no manual field list to maintain)
577577
function uiStateChanged(current: NodeUIState | undefined, next: NodeUIState): boolean {
578-
if (!current) return true
578+
if (!current)
579+
return true
579580
return !isDeepEqual(current, next)
580581
}
581582

@@ -619,7 +620,8 @@ export const $nodeUIState = nodesDomain.createStore<Record<string, NodeUIState>>
619620
// UI updates
620621
.on(updateNodeUILocal, (state, { nodeId, ui }) => {
621622
const current = state[nodeId]
622-
if (!current) return state
623+
if (!current)
624+
return state
623625

624626
// Compute partial updates from the UI payload
625627
const updates: Partial<NodeUIState> = {}
@@ -645,20 +647,22 @@ export const $nodeUIState = nodesDomain.createStore<Record<string, NodeUIState>>
645647
const newStyle = ui.style
646648
const styleChanged
647649
= currentStyle?.backgroundColor !== newStyle?.backgroundColor
648-
|| currentStyle?.borderColor !== newStyle?.borderColor
650+
|| currentStyle?.borderColor !== newStyle?.borderColor
649651

650652
if (styleChanged) {
651653
updates.uiStyle = newStyle
652654
}
653655
}
654656

655-
if (Object.keys(updates).length === 0) return state
657+
if (Object.keys(updates).length === 0)
658+
return state
656659
return { ...state, [nodeId]: { ...current, ...updates } }
657660
})
658661
// Metadata changes (includes title)
659662
.on(setNodeMetadata, (state, { nodeId, metadata }) => {
660663
const current = state[nodeId]
661-
if (!current) return state
664+
if (!current)
665+
return state
662666

663667
const updates: Partial<NodeUIState> = {}
664668
const newTitle = metadata.title || ''
@@ -673,13 +677,15 @@ export const $nodeUIState = nodesDomain.createStore<Record<string, NodeUIState>>
673677
}
674678
}
675679

676-
if (Object.keys(updates).length === 0) return state
680+
if (Object.keys(updates).length === 0)
681+
return state
677682
return { ...state, [nodeId]: { ...current, ...updates } }
678683
})
679684
// Version updates
680685
.on(setNodeVersion, (state, { nodeId, version }) => {
681686
const current = state[nodeId]
682-
if (!current || current.version === version) return state
687+
if (!current || current.version === version)
688+
return state
683689
return { ...state, [nodeId]: { ...current, version } }
684690
})
685691
// Bulk set
@@ -1210,9 +1216,11 @@ sample({
12101216
source: $selectedNodeIds,
12111217
filter: (current, next) => {
12121218
// Only update if arrays are different
1213-
if (current.length !== next.length) return true
1219+
if (current.length !== next.length)
1220+
return true
12141221
for (let i = 0; i < current.length; i++) {
1215-
if (current[i] !== next[i]) return true
1222+
if (current[i] !== next[i])
1223+
return true
12161224
}
12171225
return false
12181226
},

apps/chaingraph-frontend/src/store/xyflow/stores/node-render-data.ts

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
*/
88

99
import type { CategoryMetadata, INode, Position } from '@badaitech/chaingraph-types'
10-
import { isDeepEqual } from '@badaitech/chaingraph-types'
1110
import type { PulseState, XYFlowNodeRenderData, XYFlowNodesDataChangedPayload } from '../types'
1211
import type { DragDropRenderState } from '@/store/drag-drop/types'
1312
import type { ExecutionState, NodeExecutionState } from '@/store/execution/types'
1413
import type { NodePortLists } from '@/store/ports-v2'
1514
import { NODE_CATEGORIES } from '@badaitech/chaingraph-nodes'
15+
import { isDeepEqual } from '@badaitech/chaingraph-types'
1616
import { sample } from 'effector'
1717
import { trace } from '@/lib/perf-trace'
1818
import { $categoryMetadata } from '@/store/categories'
@@ -170,11 +170,11 @@ function buildCompleteRenderMap(
170170
executionStatus: (execNode?.status as XYFlowNodeRenderData['executionStatus']) || 'idle',
171171
executionNode: execNode
172172
? {
173-
status: execNode.status,
174-
executionTime: execNode.executionTime,
175-
error: execNode.error,
176-
node: execNode.node,
177-
}
173+
status: execNode.status,
174+
executionTime: execNode.executionTime,
175+
error: execNode.error,
176+
node: execNode.node,
177+
}
178178
: null,
179179
isHighlighted: highlightSet.has(nodeId),
180180
hasAnyHighlights,
@@ -338,7 +338,8 @@ sample({
338338

339339
for (const nodeId of nodeIds) {
340340
const current = renderMap[nodeId]
341-
if (!current) continue
341+
if (!current)
342+
continue
342343

343344
const pos = positions[nodeId]
344345
const dims = dimensions[nodeId]
@@ -348,8 +349,10 @@ sample({
348349

349350
if (posChanged || dimsChanged) {
350351
const nodeChanges: Partial<XYFlowNodeRenderData> = {}
351-
if (posChanged) nodeChanges.position = pos
352-
if (dimsChanged) nodeChanges.dimensions = dims
352+
if (posChanged)
353+
nodeChanges.position = pos
354+
if (dimsChanged)
355+
nodeChanges.dimensions = dims
353356
changes.push({ nodeId, changes: nodeChanges })
354357
}
355358
}
@@ -382,13 +385,20 @@ sample({
382385
// Fields to sync from NodeUIState to XYFlowNodeRenderData
383386
// Using isDeepEqual for type-safety (new fields automatically compared)
384387
const fieldsToSync = [
385-
'version', 'isSelected', 'isHidden', 'isDraggable',
386-
'nodeType', 'isErrorPortCollapsed', 'title', 'uiStyle',
388+
'version',
389+
'isSelected',
390+
'isHidden',
391+
'isDraggable',
392+
'nodeType',
393+
'isErrorPortCollapsed',
394+
'title',
395+
'uiStyle',
387396
] as const
388397

389398
for (const [nodeId, uiState] of Object.entries(uiStates)) {
390399
const current = renderMap[nodeId]
391-
if (!current) continue
400+
if (!current)
401+
continue
392402

393403
const updates: Partial<XYFlowNodeRenderData> = {}
394404

@@ -454,20 +464,20 @@ sample({
454464
// Execution node data
455465
const executionNode = execNode
456466
? {
457-
status: execNode.status,
458-
executionTime: execNode.executionTime,
459-
error: execNode.error,
460-
node: execNode.node,
461-
}
467+
status: execNode.status,
468+
executionTime: execNode.executionTime,
469+
error: execNode.error,
470+
node: execNode.node,
471+
}
462472
: null
463473

464474
// Deep comparison for execution node
465475
const currentExecNode = current.executionNode
466476
const execNodeChanged
467477
= (currentExecNode === null) !== (executionNode === null)
468-
|| currentExecNode?.status !== executionNode?.status
469-
|| currentExecNode?.executionTime !== executionNode?.executionTime
470-
|| currentExecNode?.node !== executionNode?.node
478+
|| currentExecNode?.status !== executionNode?.status
479+
|| currentExecNode?.executionTime !== executionNode?.executionTime
480+
|| currentExecNode?.node !== executionNode?.node
471481

472482
if (execNodeChanged) {
473483
updates.executionNode = executionNode
@@ -593,8 +603,8 @@ sample({
593603
// Compare with current
594604
const changed
595605
= (current.dropFeedback === null) !== (dropFeedback === null)
596-
|| current.dropFeedback?.canAcceptDrop !== dropFeedback?.canAcceptDrop
597-
|| current.dropFeedback?.dropType !== dropFeedback?.dropType
606+
|| current.dropFeedback?.canAcceptDrop !== dropFeedback?.canAcceptDrop
607+
|| current.dropFeedback?.dropType !== dropFeedback?.dropType
598608

599609
if (changed) {
600610
changes.push({ nodeId, changes: { dropFeedback } })

0 commit comments

Comments
 (0)