11import { useApiModelLineage , useApiModels } from '@/api/index'
2- import { useEffect , useMemo , useRef , useState } from 'react'
2+ import { useEffect , useMemo , useState } from 'react'
33import { type ModelSQLMeshModel } from '@/domain/sqlmesh-model'
44import { type HighlightedNodes , useLineageFlow } from './context'
5- import { ChevronDownIcon } from '@heroicons/react/24/solid'
65import ReactFlow , {
76 Controls ,
87 Background ,
@@ -14,14 +13,12 @@ import ReactFlow, {
1413 useReactFlow ,
1514 type Edge ,
1615 type Node ,
17- Panel ,
1816 ReactFlowProvider ,
1917} from 'reactflow'
2018import Loading from '@/components/loading/Loading'
2119import Spinner from '@/components/logo/Spinner'
2220import { createLineageWorker } from '@/workers/index'
2321import { isArrayEmpty , isFalse , isNil , isNotNil } from '@/utils/index'
24- import ListboxShow from '@/components/listbox/ListboxShow'
2522import clsx from 'clsx'
2623import ModelNode from './ModelNode'
2724import {
@@ -32,9 +29,6 @@ import {
3229 getUpdatedEdges ,
3330 createGraphLayout ,
3431} from './help'
35- import { Popover } from '@headlessui/react'
36- import ModelLineageDetails from './ModelLineageDetails'
37- import { Divider } from '@/components/divider/Divider'
3832import { SettingsControl } from '@/components/graph/SettingsControl'
3933import {
4034 toModelLineage ,
@@ -209,7 +203,6 @@ function ModelColumnLineage(): JSX.Element {
209203 connectedNodes,
210204 connections,
211205 nodesMap,
212- showControls,
213206 handleError,
214207 setActiveNodes,
215208 setWithColumns,
@@ -337,7 +330,6 @@ function ModelColumnLineage(): JSX.Element {
337330
338331 setEdges ( newEdges )
339332 setNodes ( newNodes )
340- console . log ( 'newActiveNodes' , newActiveNodes )
341333 setActiveNodes ( newActiveNodes )
342334 } , [
343335 connections ,
@@ -385,15 +377,6 @@ function ModelColumnLineage(): JSX.Element {
385377 snapGrid = { [ 16 , 16 ] }
386378 snapToGrid
387379 >
388- { showControls && (
389- < Panel
390- position = "top-right"
391- className = "bg-theme !m-0 w-full !z-10"
392- >
393- < GraphControls nodes = { nodes } />
394- < Divider />
395- </ Panel >
396- ) }
397380 < Controls
398381 className = "bg-light p-1 rounded-md !border-none !shadow-lg"
399382 showInteractive = { false }
@@ -417,104 +400,3 @@ function ModelColumnLineage(): JSX.Element {
417400 </ >
418401 )
419402}
420-
421- function GraphControls ( { nodes = [ ] } : { nodes : Node [ ] } ) : JSX . Element {
422- const {
423- withColumns,
424- // mainNode,
425- selectedNodes,
426- withConnected,
427- withImpacted,
428- withSecondary,
429- hasBackground,
430- activeNodes,
431- // highlightedNodes,
432- // setSelectedNodes,
433- setWithColumns,
434- setWithConnected,
435- setWithImpacted,
436- setWithSecondary,
437- setHasBackground,
438- } = useLineageFlow ( )
439-
440- useEffect ( ( ) => {
441- setWithColumns ( true )
442- setWithSecondary ( true )
443- setWithConnected ( true )
444- setWithImpacted ( true )
445- } , [ setWithSecondary ] )
446-
447- const lineageInfoTrigger = useRef < HTMLButtonElement > ( null )
448-
449- // const highlightedNodeModels = useMemo(
450- // () => Object.values(highlightedNodes ?? {}).flat(),
451- // [highlightedNodes],
452- // )
453- // function handleSelect(model: { name: string; description: string }): void {
454- // if (highlightedNodeModels.includes(model.name) || mainNode === model.name)
455- // return
456-
457- // setSelectedNodes(current => {
458- // if (current.has(model.name)) {
459- // current.delete(model.name)
460- // } else {
461- // current.add(model.name)
462- // }
463-
464- // return new Set(current)
465- // })
466- // }
467-
468- return (
469- < div className = "px-2 flex items-center text-xs text-neutral-400 @container" >
470- < div className = "contents" >
471- < Popover
472- className = "flex @lg:hidden bg-none border-none"
473- aria-label = "Show lineage node details"
474- >
475- < Popover . Button
476- ref = { lineageInfoTrigger }
477- className = "flex items-center relative w-full cursor-pointer bg-primary-10 text-xs rounded-full text-primary-500 py-1 px-3 text-center focus:outline-none focus-visible:border-accent-500 focus-visible:ring-2 focus-visible:ring-light focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-brand-300 border-1 border-transparent"
478- >
479- Details
480- < ChevronDownIcon
481- className = "ml-2 h-4 w-4"
482- aria-hidden = "true"
483- />
484- </ Popover . Button >
485- < Popover . Panel className = "absolute left-2 right-2 flex-col z-50 mt-8 transform flex px-4 py-3 bg-theme-lighter shadow-xl focus:ring-2 ring-opacity-5 rounded-lg" >
486- < ModelLineageDetails nodes = { nodes } />
487- </ Popover . Panel >
488- </ Popover >
489- < div className = "hidden @lg:contents w-full" >
490- < ModelLineageDetails nodes = { nodes } />
491- </ div >
492- </ div >
493- < div className = "flex w-full justify-end items-center" >
494- { /* <ModelLineageSearch handleSelect={handleSelect} /> */ }
495- < ListboxShow
496- options = { {
497- Background : setHasBackground ,
498- Columns :
499- activeNodes . size > 0 && selectedNodes . size === 0
500- ? undefined
501- : setWithColumns ,
502- Connected : activeNodes . size > 0 ? undefined : setWithConnected ,
503- 'Upstream/Downstream' :
504- activeNodes . size > 0 ? undefined : setWithImpacted ,
505- All : activeNodes . size > 0 ? undefined : setWithSecondary ,
506- } }
507- value = {
508- [
509- withColumns && 'Columns' ,
510- hasBackground && 'Background' ,
511- withConnected && 'Connected' ,
512- withImpacted && 'Upstream/Downstream' ,
513- withSecondary && 'All' ,
514- ] . filter ( Boolean ) as string [ ]
515- }
516- />
517- </ div >
518- </ div >
519- )
520- }
0 commit comments