|
13 | 13 | */
|
14 | 14 | import { useParams } from 'react-router-dom'
|
15 | 15 | import { useEffect, useRef, useState } from 'react'
|
16 |
| -import { Alert, Box, CircularProgress, Grid } from '@mui/material' |
| 16 | +import { Alert, Box, CircularProgress, Grid, Typography } from '@mui/material' |
17 | 17 | import { ReactFlow, type Edge, type Node, useNodesState, useEdgesState } from '@xyflow/react'
|
18 | 18 | import '@xyflow/react/dist/style.css'
|
19 | 19 | import { queryStatusApi, QueryStatusInfo } from '../api/webapp/api.ts'
|
@@ -115,21 +115,31 @@ export const QueryLivePlan = () => {
|
115 | 115 | ref={containerRef}
|
116 | 116 | sx={{ width: '100%', height: '80vh', border: '1px solid #ccc' }}
|
117 | 117 | >
|
118 |
| - <ReactFlow |
119 |
| - nodes={nodes} |
120 |
| - edges={edges} |
121 |
| - onNodesChange={onNodesChange} |
122 |
| - onEdgesChange={onEdgesChange} |
123 |
| - nodeTypes={nodeTypes} |
124 |
| - minZoom={0.1} |
125 |
| - proOptions={{ hideAttribution: true }} |
126 |
| - defaultViewport={{ x: 200, y: 20, zoom: 0.8 }} |
127 |
| - > |
128 |
| - <HelpMessage |
129 |
| - layoutDirection={layoutDirection} |
130 |
| - onLayoutDirectionChange={setLayoutDirection} |
131 |
| - /> |
132 |
| - </ReactFlow> |
| 118 | + {nodes.length > 0 ? ( |
| 119 | + <ReactFlow |
| 120 | + nodes={nodes} |
| 121 | + edges={edges} |
| 122 | + onNodesChange={onNodesChange} |
| 123 | + onEdgesChange={onEdgesChange} |
| 124 | + nodeTypes={nodeTypes} |
| 125 | + minZoom={0.1} |
| 126 | + proOptions={{ hideAttribution: true }} |
| 127 | + defaultViewport={{ |
| 128 | + x: (nodes[0].position.x / 2) * -1, |
| 129 | + y: 20, |
| 130 | + zoom: 0.8, |
| 131 | + }} |
| 132 | + > |
| 133 | + <HelpMessage |
| 134 | + layoutDirection={layoutDirection} |
| 135 | + onLayoutDirectionChange={setLayoutDirection} |
| 136 | + /> |
| 137 | + </ReactFlow> |
| 138 | + ) : ( |
| 139 | + <Typography sx={{ p: 1 }} fontSize="small"> |
| 140 | + Rendering... |
| 141 | + </Typography> |
| 142 | + )} |
133 | 143 | </Box>
|
134 | 144 | </Box>
|
135 | 145 | </Grid>
|
|
0 commit comments