Skip to content

Commit a9b0b3e

Browse files
phixMephix
andauthored
Quality of life updates for new lineage graph display. (#2750)
Co-authored-by: phix <peter.hicks@astronomer.io>
1 parent 32ae5cb commit a9b0b3e

4 files changed

Lines changed: 38 additions & 10 deletions

File tree

web/libs/graph/src/components/ZoomPanSvg/ZoomPanSvg.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface ZoomPanControls {
3333
centerOnExtent(extent: Extent): void
3434
scaleZoom(kDelta?: number): void
3535
resetZoom(): void
36-
centerOnPositionedNode(nodeId: string): void
36+
centerOnPositionedNode(nodeId: string, k?: number): void
3737
}
3838

3939
interface Props extends BoxProps {
@@ -232,12 +232,12 @@ export const ZoomPanSvg = ({
232232
animateToZoomState(zoomIdentity)
233233
}
234234

235-
const centerOnPositionedNode = (nodeId: string) => {
235+
const centerOnPositionedNode = (nodeId: string, k = currentZoomState.k) => {
236236
const node = positionedNodes.find((node) => node.id === nodeId)
237237
if (!node) return
238238

239239
const extent = getNodeExtent(node)
240-
centerOnExtent(extent)
240+
centerOnExtent(extent, k)
241241
}
242242

243243
const fitContent = () => {

web/src/routes/column-level/ZoomControls.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CropFree, ZoomIn, ZoomOut } from '@mui/icons-material'
1+
import { CenterFocusStrong, CropFree, ZoomIn, ZoomOut } from '@mui/icons-material'
22
import { Tooltip } from '@mui/material'
33
import { theme } from '../../helpers/theme'
44
import Box from '@mui/material/Box'
@@ -8,9 +8,14 @@ import React from 'react'
88
interface ZoomControlsProps {
99
handleScaleZoom: (inOrOut: 'in' | 'out') => void
1010
handleResetZoom: () => void
11+
handleCenterOnNode?: () => void
1112
}
1213

13-
export const ZoomControls = ({ handleScaleZoom, handleResetZoom }: ZoomControlsProps) => {
14+
export const ZoomControls = ({
15+
handleScaleZoom,
16+
handleResetZoom,
17+
handleCenterOnNode,
18+
}: ZoomControlsProps) => {
1419
return (
1520
<Box
1621
display={'flex'}
@@ -38,6 +43,13 @@ export const ZoomControls = ({ handleScaleZoom, handleResetZoom }: ZoomControlsP
3843
<CropFree />
3944
</IconButton>
4045
</Tooltip>
46+
{handleCenterOnNode && (
47+
<Tooltip title={'Center on selected node'} placement={'left'}>
48+
<IconButton size={'small'} onClick={handleCenterOnNode}>
49+
<CenterFocusStrong />
50+
</IconButton>
51+
</Tooltip>
52+
)}
4153
</Box>
4254
)
4355
}

web/src/routes/table-level/ActionBar.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ export const ActionBar = ({
109109
control={
110110
<Switch
111111
size={'small'}
112-
defaultChecked
113112
value={isFull}
113+
defaultChecked={searchParams.get('isFull') === 'true'}
114114
onChange={(_, checked) => {
115115
setIsFull(checked)
116+
searchParams.set('isFull', checked.toString())
117+
setSearchParams(searchParams)
116118
}}
117119
/>
118120
}
@@ -123,8 +125,11 @@ export const ActionBar = ({
123125
<Switch
124126
size={'small'}
125127
value={isCompact}
128+
defaultChecked={searchParams.get('isCompact') === 'true'}
126129
onChange={(_, checked) => {
127130
setIsCompact(checked)
131+
searchParams.set('isCompact', checked.toString())
132+
setSearchParams(searchParams)
128133
}}
129134
/>
130135
}

web/src/routes/table-level/TableLevel.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as Redux from 'redux'
22
import { ActionBar } from './ActionBar'
33
import { Box } from '@mui/system'
4+
import { DEFAULT_MAX_SCALE, Graph, ZoomPanControls } from '../../../libs/graph'
45
import { Drawer } from '@mui/material'
5-
import { Graph, ZoomPanControls } from '../../../libs/graph'
66
import { IState } from '../../store/reducers'
77
import { JobOrDataset } from '../../components/lineage/types'
88
import { LineageGraph } from '../../types/api'
@@ -41,8 +41,8 @@ const ColumnLevel: React.FC<ColumnLevelProps> = ({
4141

4242
const [depth, setDepth] = useState(Number(searchParams.get('depth')) || 2)
4343

44-
const [isCompact, setIsCompact] = useState(false)
45-
const [isFull, setIsFull] = useState(true)
44+
const [isCompact, setIsCompact] = useState(searchParams.get('isCompact') === 'true')
45+
const [isFull, setIsFull] = useState(searchParams.get('isFull') === 'true')
4646

4747
const graphControls = useRef<ZoomPanControls>()
4848

@@ -64,6 +64,13 @@ const ColumnLevel: React.FC<ColumnLevelProps> = ({
6464
graphControls.current?.fitContent()
6565
}
6666

67+
const handleCenterOnNode = () => {
68+
graphControls.current?.centerOnPositionedNode(
69+
`${nodeType}:${namespace}:${name}`,
70+
DEFAULT_MAX_SCALE
71+
)
72+
}
73+
6774
const setGraphControls = useCallbackRef((zoomControls) => {
6875
graphControls.current = zoomControls
6976
})
@@ -103,7 +110,11 @@ const ColumnLevel: React.FC<ColumnLevelProps> = ({
103110
<TableLevelDrawer />
104111
</Box>
105112
</Drawer>
106-
<ZoomControls handleScaleZoom={handleScaleZoom} handleResetZoom={handleResetZoom} />
113+
<ZoomControls
114+
handleCenterOnNode={handleCenterOnNode}
115+
handleScaleZoom={handleScaleZoom}
116+
handleResetZoom={handleResetZoom}
117+
/>
107118
<ParentSize>
108119
{(parent) => (
109120
<Graph<JobOrDataset, TableLevelNodeData>

0 commit comments

Comments
 (0)