1- import React , {
2- useEffect ,
3- useMemo ,
4- useState ,
5- useCallback ,
6- Fragment ,
7- useRef ,
8- } from 'react'
1+ import React , { useEffect , useMemo , useCallback } from 'react'
92import { Handle , Position , useUpdateNodeInternals } from 'reactflow'
103import 'reactflow/dist/base.css'
114import { mergeLineageWithColumns , mergeConnections } from './help'
@@ -20,18 +13,12 @@ import {
2013} from '@/utils/index'
2114import { EnumSide , type Side } from './types'
2215import { NoSymbolIcon } from '@heroicons/react/24/solid'
23- import {
24- InformationCircleIcon ,
25- ClockIcon ,
26- ExclamationCircleIcon ,
27- } from '@heroicons/react/24/outline'
16+ import { ClockIcon , ExclamationCircleIcon } from '@heroicons/react/24/outline'
2817import clsx from 'clsx'
2918import {
3019 type ColumnDescription ,
3120 type ColumnLineageApiLineageModelNameColumnNameGet200 ,
3221 type LineageColumn ,
33- type LineageColumnSource ,
34- type LineageColumnExpression ,
3522} from '@/api/client'
3623import Loading from '@/components/loading/Loading'
3724import Spinner from '@/components/logo/Spinner'
@@ -41,21 +28,19 @@ import {
4128 type ModelSQLMeshModel ,
4229} from '@/domain/sqlmesh-model'
4330import { useLineageFlow } from './context'
44- import { Popover , Transition } from '@headlessui/react'
4531import { useApiColumnLineage } from '@/api/index'
4632import SourceList from '@/components/sourceList/SourceList'
4733import type { Lineage } from '@/domain/lineage'
4834import type { ModelName } from '@/domain/models'
4935import type { Column } from '@/domain/column'
5036
51- export default function ModelColumns ( {
37+ export function ModelColumns ( {
5238 nodeId,
5339 columns,
5440 disabled,
5541 className,
5642 limit = 5 ,
5743 withHandles = false ,
58- withSource = false ,
5944 withDescription = true ,
6045 maxHeight = '50vh' ,
6146} : {
@@ -65,7 +50,6 @@ export default function ModelColumns({
6550 className ?: string
6651 limit ?: number
6752 withHandles ?: boolean
68- withSource ?: boolean
6953 withDescription ?: boolean
7054 maxHeight ?: string
7155} ) : JSX . Element {
@@ -224,17 +208,6 @@ export default function ModelColumns({
224208 }
225209 withHandles = { withHandles }
226210 withDescription = { withDescription }
227- expression = {
228- withSource
229- ? getColumnFromLineage ( lineage , nodeId , column . name )
230- ?. expression
231- : undefined
232- }
233- source = {
234- withSource
235- ? getColumnFromLineage ( lineage , nodeId , column . name ) ?. source
236- : undefined
237- }
238211 isEmpty = {
239212 isNotNil ( getColumnFromLineage ( lineage , nodeId , column . name ) ) &&
240213 Object . keys (
@@ -273,17 +246,6 @@ export default function ModelColumns({
273246 }
274247 withHandles = { withHandles }
275248 withDescription = { withDescription }
276- expression = {
277- withSource
278- ? getColumnFromLineage ( lineage , nodeId , column . name )
279- ?. expression
280- : undefined
281- }
282- source = {
283- withSource
284- ? getColumnFromLineage ( lineage , nodeId , column . name ) ?. source
285- : undefined
286- }
287249 isEmpty = {
288250 isNotNil ( getColumnFromLineage ( lineage , nodeId , column . name ) ) &&
289251 Object . keys (
@@ -330,17 +292,6 @@ export default function ModelColumns({
330292 }
331293 withHandles = { withHandles }
332294 withDescription = { withDescription }
333- expression = {
334- withSource
335- ? getColumnFromLineage ( lineage , nodeId , item . name )
336- ?. expression
337- : undefined
338- }
339- source = {
340- withSource
341- ? getColumnFromLineage ( lineage , nodeId , item . name ) ?. source
342- : undefined
343- }
344295 isEmpty = {
345296 isNotNil ( getColumnFromLineage ( lineage , nodeId , item . name ) ) &&
346297 Object . keys (
@@ -373,8 +324,6 @@ function ModelColumn({
373324 selectManually,
374325 withHandles = false ,
375326 withDescription = true ,
376- source,
377- expression,
378327} : {
379328 id : string
380329 nodeId : string
@@ -385,8 +334,6 @@ function ModelColumn({
385334 hasRight ?: boolean
386335 isEmpty ?: boolean
387336 withHandles ?: boolean
388- source ?: LineageColumnSource
389- expression ?: LineageColumnExpression
390337 withDescription ?: boolean
391338 updateColumnLineage : (
392339 lineage : ColumnLineageApiLineageModelNameColumnNameGet200 ,
@@ -447,12 +394,6 @@ function ModelColumn({
447394 disabled = { disabled }
448395 className = "px-2"
449396 >
450- { isNotNil ( source ) && (
451- < ColumnSource
452- source = { source }
453- expression = { expression }
454- />
455- ) }
456397 < ColumnStatus
457398 isFetching = { isFetching }
458399 isError = { isError }
@@ -644,90 +585,6 @@ function ColumnStatus({
644585 )
645586}
646587
647- function ColumnSource ( {
648- // source,
649- expression,
650- } : {
651- source : LineageColumnSource
652- expression ?: LineageColumnExpression
653- } ) : JSX . Element {
654- const elSourceContainer = useRef < HTMLDivElement > ( null )
655- // const { handleClickModel } = useLineageFlow()
656-
657- // const modelExtensions = useSQLMeshModelExtensions(undefined, model => {
658- // handleClickModel?.(model.name)
659- // })
660-
661- const [ isShowing , setIsShowing ] = useState ( false )
662-
663- useEffect ( ( ) => {
664- if ( isShowing ) {
665- scrollToExpression ( )
666- }
667- } , [ isShowing , expression ] )
668-
669- function scrollToExpression ( ) : void {
670- // NOTE: This is a hack to scroll to the expression
671- // and should be replaced with a code mirror extension
672- setTimeout ( ( ) => {
673- const lines = Array . from (
674- elSourceContainer . current ?. querySelector ( '[role="textbox"].cm-content' )
675- ?. children ?? [ ] ,
676- )
677-
678- for ( const node of lines ) {
679- if ( node . textContent ?. trim ( ) === expression ) {
680- node . scrollIntoView ( {
681- behavior : 'smooth' ,
682- block : 'center' ,
683- inline : 'nearest' ,
684- } )
685- setTimeout ( ( ) => node . classList . add ( 'sqlmesh-expression' ) , 500 )
686- return
687- }
688- }
689- } , 300 )
690- }
691-
692- return (
693- < Popover
694- onMouseLeave = { ( ) => setIsShowing ( false ) }
695- onMouseOver = { ( ) => setIsShowing ( true ) }
696- className = "flex"
697- >
698- < InformationCircleIcon
699- className = { clsx (
700- 'inline-block mr-3 w-4 h-4' ,
701- isShowing ? 'text-inherit' : 'text-prose' ,
702- ) }
703- />
704- < Transition
705- show = { isShowing }
706- as = { Fragment }
707- enter = "transition ease-out duration-200"
708- enterFrom = "opacity-0 -translate-y-[40%]"
709- enterTo = "opacity-100 -translate-y-[50%]"
710- leave = "transition ease-in duration-150"
711- leaveFrom = "opacity-100 -translate-y-[50%]"
712- leaveTo = "opacity-0 -translate-y-[40%]"
713- >
714- < Popover . Panel
715- ref = { elSourceContainer }
716- className = "fixed -translate-x-[100%] -translate-y-[50%] z-10 content transform cursor-pointer rounded-lg bg-theme border-4 border-neutral-200 dark:border-neutral-600"
717- onClick = { e => e . stopPropagation ( ) }
718- >
719- { /* <CodeEditorDefault
720- content={source as string}
721- type={EnumFileExtensions.SQL}
722- className="w-full h-[25rem] text-xs rounded-lg scrollbar scrollbar--vertical scrollbar--horizontal overflow-auto max-w-[40rem]"
723- extensions={modelExtensions}
724- /> */ }
725- </ Popover . Panel >
726- </ Transition >
727- </ Popover >
728- )
729- }
730-
731588function getColumnFromLineage (
732589 lineage : Record < string , Lineage > ,
733590 nodeId : string ,
0 commit comments