-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bengotow
committed
Jul 24, 2024
1 parent
55857c3
commit ba433d5
Showing
11 changed files
with
621 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
js_modules/dagster-ui/packages/ui-core/src/assets/VirtualizedSimpleAssetKeyList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// eslint-disable-next-line no-restricted-imports | ||
|
||
import {useVirtualizer} from '@tanstack/react-virtual'; | ||
import {CSSProperties, useRef} from 'react'; | ||
|
||
import {displayNameForAssetKey} from '../asset-graph/Utils'; | ||
import {AssetKeyInput} from '../graphql/types'; | ||
import {Inner, Row} from '../ui/VirtualizedTable'; | ||
|
||
export const VirtualizedSimpleAssetKeyList = ({ | ||
assetKeys, | ||
style, | ||
}: { | ||
assetKeys: AssetKeyInput[]; | ||
style: CSSProperties; | ||
}) => { | ||
const parentRef = useRef<HTMLDivElement>(null); | ||
const rowVirtualizer = useVirtualizer({ | ||
count: assetKeys.length, | ||
getScrollElement: () => parentRef.current, | ||
estimateSize: () => 24, | ||
overscan: 10, | ||
}); | ||
|
||
const totalHeight = rowVirtualizer.getTotalSize(); | ||
const items = rowVirtualizer.getVirtualItems(); | ||
|
||
return ( | ||
<div style={{...style, overflowY: 'auto'}} ref={parentRef}> | ||
<Inner $totalHeight={totalHeight}> | ||
{items.map(({index, key, size, start}) => { | ||
const assetKey = assetKeys[index]!; | ||
return ( | ||
<Row key={key} $height={size} $start={start}> | ||
{displayNameForAssetKey(assetKey)} | ||
</Row> | ||
); | ||
})} | ||
</Inner> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.