1- import { Box , Colors , Icon , MiddleTruncate , UnstyledButton } from '@dagster-io/ui-components' ;
1+ import { Box , Colors , Icon , UnstyledButton } from '@dagster-io/ui-components' ;
22import * as React from 'react' ;
33import { observeEnabled } from 'shared/app/observeEnabled.oss' ;
44import styled from 'styled-components' ;
@@ -12,6 +12,8 @@ import {
1212} from './util' ;
1313import { AssetHealthSummary } from '../../assets/AssetHealthSummary' ;
1414import { ExplorerPath } from '../../pipelines/PipelinePathUtils' ;
15+ import { FocusableLabelContainer , GrayOnHoverBox } from '../../ui/Sidebar/FocusableLabelContainer' ;
16+ import { SidebarDisclosureTriangle } from '../../ui/Sidebar/SidebarDisclosureTriangle' ;
1517import { AssetGroup } from '../AssetGraphExplorer' ;
1618import { AssetNodeMenuProps , useAssetNodeMenu } from '../AssetNodeMenu' ;
1719import { useGroupNodeContextMenu } from '../CollapsedGroupNode' ;
@@ -52,27 +54,7 @@ export const AssetSidebarNode = (props: AssetSidebarNodeProps) => {
5254 onDoubleClick = { ( e ) => ! e . metaKey && toggleOpen ( ) }
5355 >
5456 { showArrow ? (
55- < UnstyledButton
56- onClick = { ( e ) => {
57- e . stopPropagation ( ) ;
58- toggleOpen ( ) ;
59- } }
60- onDoubleClick = { ( e ) => {
61- e . stopPropagation ( ) ;
62- } }
63- onKeyDown = { ( e ) => {
64- if ( e . code === 'Space' ) {
65- // Prevent the default scrolling behavior
66- e . preventDefault ( ) ;
67- }
68- } }
69- style = { { cursor : 'pointer' , width : 18 } }
70- >
71- < Icon
72- name = "arrow_drop_down"
73- style = { { transform : isOpen ? 'rotate(0deg)' : 'rotate(-90deg)' } }
74- />
75- </ UnstyledButton >
57+ < SidebarDisclosureTriangle isOpen = { isOpen } toggleOpen = { toggleOpen } />
7658 ) : level === 1 && isAssetNode ? (
7759 // Special case for when asset nodes are at the root (level = 1) due to their being only a single group.
7860 // In this case we don't need the spacer div to align nodes because none of the nodes will be collapsible/un-collapsible.
@@ -188,43 +170,6 @@ const AssetSidebarLocationLabel = ({
188170 ) ;
189171} ;
190172
191- const FocusableLabelContainer = ( {
192- isSelected,
193- isLastSelected,
194- icon,
195- text,
196- } : {
197- isSelected : boolean ;
198- isLastSelected : boolean ;
199- icon : React . ReactNode ;
200- text : string ;
201- } ) => {
202- const ref = React . useRef < HTMLButtonElement | null > ( null ) ;
203- React . useLayoutEffect ( ( ) => {
204- // When we click on a node in the graph it also changes "isSelected" in the sidebar.
205- // We want to check if the focus is currently in the graph and if it is lets keep it there
206- // Otherwise it means the click happened in the sidebar in which case we should move focus to the element
207- // in the sidebar
208- if ( ref . current && isLastSelected && ! isElementInsideSVGViewport ( document . activeElement ) ) {
209- ref . current . focus ( ) ;
210- }
211- } , [ isLastSelected ] ) ;
212-
213- return (
214- < GrayOnHoverBox
215- ref = { ref }
216- style = { {
217- gridTemplateColumns : icon ? 'auto minmax(0, 1fr)' : 'minmax(0, 1fr)' ,
218- gridTemplateRows : 'minmax(0, 1fr)' ,
219- ...( isSelected ? { background : Colors . backgroundBlue ( ) } : { } ) ,
220- } }
221- >
222- { icon }
223- < MiddleTruncate text = { text } />
224- </ GrayOnHoverBox >
225- ) ;
226- } ;
227-
228173const BoxWrapper = ( { level, children} : { level : number ; children : React . ReactNode } ) => {
229174 const wrapper = React . useMemo ( ( ) => {
230175 let sofar = children ;
@@ -255,22 +200,6 @@ const ExpandMore = styled(UnstyledButton)`
255200 visibility: hidden;
256201` ;
257202
258- const GrayOnHoverBox = styled ( UnstyledButton ) `
259- border-radius: 8px;
260- user-select: none;
261- width: 100%;
262- display: grid;
263- flex-direction: row;
264- height: 32px;
265- align-items: center;
266- padding: 5px 8px;
267- justify-content: space-between;
268- gap: 6px;
269- flex-grow: 1;
270- flex-shrink: 1;
271- transition: background 100ms linear;
272- ` ;
273-
274203export const ItemContainer = styled ( Box ) `
275204 height: 32px;
276205 position: relative;
@@ -287,7 +216,3 @@ export const ItemContainer = styled(Box)`
287216 }
288217 }
289218` ;
290-
291- function isElementInsideSVGViewport ( element : Element | null ) {
292- return ! ! element ?. closest ( '[data-svg-viewport]' ) ;
293- }
0 commit comments