@@ -10,8 +10,10 @@ import { ModelLineage } from '@/components/graph/ModelLineage'
1010import { useVSCode } from '@/hooks/vscode'
1111import React from 'react'
1212import { ModelSQLMeshModel } from '@/domain/sqlmesh-model'
13+ import { useEventBus } from '@/utilsutils/eventBus'
1314
1415export function LineagePage ( ) {
16+ const { emit } = useEventBus ( )
1517 // Handle messages from VSCode extension
1618 React . useEffect ( ( ) => {
1719 const handleMessage = ( event : MessageEvent ) => {
@@ -21,7 +23,7 @@ export function LineagePage() {
2123 switch ( payload . key ) {
2224 case 'changeFocusOnFile' :
2325 console . log ( 'Changing focus to file:' , payload . payload . path )
24- // Implement your focus change logic here
26+ emit ( 'changeFocusedFile' , { fileUri : payload . payload . path } )
2527 break
2628 default :
2729 console . error (
@@ -92,6 +94,7 @@ export function LineageComponentFromWeb({
9294} ) : JSX . Element {
9395 const vscode = useVSCode ( )
9496 function handleClickModel ( id : string ) : void {
97+ console . log ( 'handling click' , id )
9598 const decodedId = decodeURIComponent ( id )
9699 const model = Object . values ( models ) . find ( ( m : Model ) => m . fqn === decodedId )
97100 if ( ! model ) {
@@ -121,53 +124,8 @@ export function LineageComponentFromWeb({
121124 models = { models }
122125 showControls = { false }
123126 >
124- { ' ' }
125- < UpdateLineageFocus >
126- < ModelLineage model = { sqlmModel } />
127- </ UpdateLineageFocus >
127+ < ModelLineage model = { sqlmModel } />
128128 </ LineageFlowProvider >
129129 </ div >
130130 )
131131}
132-
133- export function UpdateLineageFocus ( {
134- children,
135- } : {
136- children : React . ReactNode
137- } ) {
138- const lineageFlow = useLineageFlow ( )
139-
140- React . useEffect ( ( ) => {
141- const handleMessage = ( event : MessageEvent ) => {
142- console . log ( 'handleMessage in lineage page' , event )
143- // Ensure the message is from VSCode
144- if ( event . data && event . data . key === 'vscode_send' ) {
145- const payload = event . data . payload
146- switch ( payload . key ) {
147- case 'changeFocusOnFile' :
148- console . log ( 'Changing focus to file:' , payload . payload . path )
149- lineageFlow . setMainNode ( '"memory"."sushi"."customers"' )
150- // Add a small delay to ensure the state update is processed
151- setTimeout ( ( ) => {
152- console . log ( 'Delayed state update confirmation' )
153- } , 1000 )
154- console . log ( 'set main node' , lineageFlow . mainNode )
155- // Implement your focus change logic here
156- // TODO NEED TO PASS THE FQN of the model not the path
157- break
158- default :
159- console . error (
160- 'Unhandled message type in lineage page:' ,
161- payload . key ,
162- )
163- }
164- }
165- }
166- window . addEventListener ( 'message' , handleMessage )
167- return ( ) => {
168- window . removeEventListener ( 'message' , handleMessage )
169- }
170- } , [ ] )
171-
172- return children
173- }
0 commit comments