@@ -2,6 +2,7 @@ import { isNil, isArrayNotEmpty, isNotNil, toID, isFalse } from '@utils/index'
22import clsx from 'clsx'
33import { useMemo , useCallback , useState , useRef } from 'react'
44import { ModelType } from '@api/client'
5+ import { useStoreContext } from '@context/context'
56import { useLineageFlow } from './context'
67import { type GraphNodeData } from './help'
78import { Position , type NodeProps , NodeResizeControl } from 'reactflow'
@@ -44,6 +45,7 @@ export default function ModelNode({
4445 highlightedNodes,
4546 activeNodes,
4647 } = useLineageFlow ( )
48+ const nodeColors = useStoreContext ( s => s . nodeColors )
4749
4850 const columns : Column [ ] = useMemo ( ( ) => {
4951 const model = models . get ( id )
@@ -113,6 +115,16 @@ export default function ModelNode({
113115 [ setSelectedNodes , highlightedNodeModels ] ,
114116 )
115117
118+ const tagColor = useMemo ( ( ) => {
119+ const tags = nodeData . tags
120+ if ( isNil ( tags ) || Object . keys ( nodeColors ) . length === 0 ) return undefined
121+ for ( const tag of tags ) {
122+ const color = nodeColors [ tag ]
123+ if ( color ) return color
124+ }
125+ return undefined
126+ } , [ nodeData . tags , nodeColors ] )
127+
116128 const splat = highlightedNodes [ '*' ]
117129 const hasSelectedColumns = columns . some ( ( { name } ) =>
118130 connections . get ( toID ( id , name ) ) ,
@@ -183,7 +195,12 @@ export default function ModelNode({
183195 ? 'ring-8 ring-neutral-50'
184196 : isSelected && 'ring-8 ring-secondary-50 dark:ring-primary-50' ,
185197 ) }
186- style = { { width : '100%' } }
198+ style = { {
199+ width : '100%' ,
200+ ...( tagColor != null
201+ ? { borderColor : tagColor , backgroundColor : tagColor , color : tagColor }
202+ : { } ) ,
203+ } }
187204 >
188205 < NodeResizeControl
189206 minWidth = { 150 }
0 commit comments