Skip to content

Commit d8f3fa3

Browse files
bengotowbengotow
andauthored
[ui] Remove AssetNode observeEnabled checks, stories and tests use new 2025 rendering (#33093)
## Summary & Motivation - Removes feature gating in AssetNode - it always renders with `observeEnabled` - Moves the storybooks and the tests to the new 2025 rendering (with facets) - Updates the tests to mock Health data as well as the live data. --------- Co-authored-by: bengotow <bgotow@elementl.com>
1 parent 023c833 commit d8f3fa3

6 files changed

Lines changed: 361 additions & 261 deletions

File tree

js_modules/dagster-ui/packages/ui-core/src/asset-data/AssetHealthDataProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function useAssetHealthData(assetKey: AssetKeyInput, thread: LiveDataThre
8686
* Instead we'll just return an empty asset health fragment.
8787
*/
8888
const {allAssetKeys} = useAllAssetsNodes();
89-
const shouldSkip = !allAssetKeys.has(tokenForAssetKey(assetKey));
89+
const shouldSkip = !process.env.STORYBOOK && !allAssetKeys.has(tokenForAssetKey(assetKey));
9090
const result = AssetHealthData.useLiveDataSingle(tokenForAssetKey(assetKey), thread, shouldSkip);
9191
useBlockTraceUntilTrue('useAssetHealthData', !!result.liveData, {skip: shouldSkip});
9292
const liveData = useMemo(() => {

js_modules/dagster-ui/packages/ui-core/src/asset-graph/AssetNode.tsx

Lines changed: 3 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import {Box, Colors, FontFamily, Icon, Tooltip} from '@dagster-io/ui-components'
22
import isEqual from 'lodash/isEqual';
33
import * as React from 'react';
44
import {Link} from 'react-router-dom';
5-
import {observeEnabled} from 'shared/app/observeEnabled.oss';
65
import styled, {CSSObject} from 'styled-components';
76

87
import {ASSET_NODE_HOVER_EXPAND_HEIGHT} from './AssetNode2025';
98
import {AssetNodeFacet} from './AssetNodeFacetsUtil';
109
import {AssetNodeHealthRow} from './AssetNodeHealthRow';
1110
import {AssetNodeMenuProps, useAssetNodeMenu} from './AssetNodeMenu';
12-
import {buildAssetNodeStatusContent} from './AssetNodeStatusContent';
1311
import {ContextMenuWrapper} from './ContextMenuWrapper';
1412
import {LiveDataForNode} from './Utils';
1513
import {
@@ -71,11 +69,8 @@ export const AssetNode = React.memo(({definition, selected, onChangeAssetSelecti
7169
<PartitionCountTags definition={definition} liveData={liveData} />
7270
)}
7371
</Box>
74-
{observeEnabled() ? (
75-
<AssetNodeHealthRow definition={definition} liveData={liveData} />
76-
) : (
77-
<AssetNodeStatusRow definition={definition} liveData={liveData} />
78-
)}
72+
<AssetNodeHealthRow definition={definition} liveData={liveData} />
73+
7974
{hasChecks && <AssetNodeChecksRow definition={definition} liveData={liveData} />}
8075
</AssetNodeBox>
8176
<Box
@@ -132,28 +127,6 @@ export const AssetNodeRowBox = styled(Box)`
132127
}
133128
`;
134129

135-
interface StatusRowProps {
136-
definition: AssetNodeFragment;
137-
liveData: LiveDataForNode | undefined;
138-
}
139-
140-
const AssetNodeStatusRow = ({definition, liveData}: StatusRowProps) => {
141-
const {content, background} = buildAssetNodeStatusContent({
142-
assetKey: definition.assetKey,
143-
definition,
144-
liveData,
145-
});
146-
return (
147-
<AssetNodeRowBox
148-
background={background}
149-
padding={{horizontal: 8}}
150-
flex={{justifyContent: 'space-between', alignItems: 'center', gap: 6}}
151-
>
152-
{content}
153-
</AssetNodeRowBox>
154-
);
155-
};
156-
157130
export const AssetNodeContextMenuWrapper = React.memo(
158131
({children, ...menuProps}: AssetNodeMenuProps & {children: React.ReactNode}) => {
159132
const {dialog, menu} = useAssetNodeMenu(menuProps);
@@ -208,20 +181,7 @@ type AssetNodeMinimalProps = {
208181
height: number;
209182
};
210183

211-
export const AssetNodeMinimal = (props: AssetNodeMinimalProps) => {
212-
return observeEnabled() ? (
213-
<AssetNodeMinimalWithHealth {...props} />
214-
) : (
215-
<AssetNodeMinimalOld {...props} />
216-
);
217-
};
218-
219-
export const AssetNodeMinimalWithHealth = ({
220-
definition,
221-
facets,
222-
height,
223-
selected,
224-
}: AssetNodeMinimalProps) => {
184+
export const AssetNodeMinimal = ({definition, facets, height, selected}: AssetNodeMinimalProps) => {
225185
const {isMaterializable, assetKey} = definition;
226186
const {liveData} = useAssetLiveData(assetKey);
227187
const {liveData: healthData} = useAssetHealthData(assetKey);
@@ -294,75 +254,6 @@ export const AssetNodeMinimalWithHealth = ({
294254
);
295255
};
296256

297-
export const AssetNodeMinimalOld = ({
298-
definition,
299-
facets,
300-
height,
301-
selected,
302-
}: AssetNodeMinimalProps) => {
303-
const {isMaterializable, assetKey} = definition;
304-
const {liveData} = useAssetLiveData(assetKey);
305-
306-
const {border, background} = buildAssetNodeStatusContent({assetKey, definition, liveData});
307-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
308-
const displayName = assetKey.path[assetKey.path.length - 1]!;
309-
310-
const isChanged = definition.changedReasons.length;
311-
const isStale = isAssetStale(liveData);
312-
313-
const queuedRuns = liveData?.unstartedRunIds.length;
314-
const inProgressRuns = liveData?.inProgressRunIds.length;
315-
316-
// old design
317-
let paddingTop = height / 2 - 52;
318-
let nodeHeight = 86;
319-
320-
if (facets !== null) {
321-
const topTagsPresent = facets.has(AssetNodeFacet.UnsyncedTag);
322-
const bottomTagsPresent = facets.has(AssetNodeFacet.KindTag);
323-
paddingTop = ASSET_NODE_VERTICAL_MARGIN + (topTagsPresent ? ASSET_NODE_TAGS_HEIGHT : 0);
324-
nodeHeight =
325-
height -
326-
ASSET_NODE_VERTICAL_MARGIN * 2 -
327-
(topTagsPresent ? ASSET_NODE_TAGS_HEIGHT : ASSET_NODE_HOVER_EXPAND_HEIGHT) -
328-
(bottomTagsPresent ? ASSET_NODE_TAGS_HEIGHT : 0);
329-
330-
// Ensure that we have room for the label, even if it makes the minimal format larger.
331-
if (nodeHeight < 38) {
332-
nodeHeight = 38;
333-
}
334-
}
335-
336-
return (
337-
<MinimalAssetNodeContainer $selected={selected} style={{paddingTop}}>
338-
<TooltipStyled
339-
content={displayName}
340-
canShow={displayName.length > 14}
341-
targetTagName="div"
342-
position="top"
343-
>
344-
<MinimalAssetNodeBox
345-
$selected={selected}
346-
$isMaterializable={isMaterializable}
347-
$background={background}
348-
$border={border}
349-
$inProgress={!!inProgressRuns}
350-
$isQueued={!!queuedRuns}
351-
$height={nodeHeight}
352-
>
353-
{isChanged ? (
354-
<MinimalNodeChangedDot changedReasons={definition.changedReasons} assetKey={assetKey} />
355-
) : null}
356-
{isStale ? <MinimalNodeStaleDot assetKey={assetKey} liveData={liveData} /> : null}
357-
<MinimalName style={{fontSize: 24}} $isMaterializable={isMaterializable}>
358-
{withMiddleTruncation(displayName, {maxLength: 18})}
359-
</MinimalName>
360-
</MinimalAssetNodeBox>
361-
</TooltipStyled>
362-
</MinimalAssetNodeContainer>
363-
);
364-
};
365-
366257
// Note: This fragment should only contain fields that are needed for
367258
// useAssetGraphData and the Asset DAG. Some pages of Dagster UI request this
368259
// fragment for every AssetNode on the instance. Add fields with care!

js_modules/dagster-ui/packages/ui-core/src/asset-graph/AssetNode2025.tsx

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import clsx from 'clsx';
33
import isEqual from 'lodash/isEqual';
44
import * as React from 'react';
55
import {Link} from 'react-router-dom';
6-
import {observeEnabled} from 'shared/app/observeEnabled.oss';
76
import {UserDisplay} from 'shared/runs/UserDisplay.oss';
87

98
import {
@@ -15,9 +14,9 @@ import {
1514
} from './AssetNode';
1615
import {labelForFacet} from './AssetNodeFacets';
1716
import {AssetNodeFacet} from './AssetNodeFacetsUtil';
18-
import {AssetNodeFreshnessRow, AssetNodeFreshnessRowOld} from './AssetNodeFreshnessRow';
17+
import {AssetNodeFreshnessRow} from './AssetNodeFreshnessRow';
1918
import {AssetNodeHealthRow} from './AssetNodeHealthRow';
20-
import {assetNodeLatestEventContent, buildAssetNodeStatusContent} from './AssetNodeStatusContent';
19+
import {assetNodeLatestEventContent} from './AssetNodeStatusContent';
2120
import {LiveDataForNode, LiveDataForNodeWithStaleData} from './Utils';
2221
import styles from './css/AssetNode2025.module.css';
2322
import {ASSET_NODE_TAGS_HEIGHT} from './layout';
@@ -123,21 +122,15 @@ export const AssetNodeWithLiveData = ({
123122
<PartitionsFacetContent definition={definition} liveData={liveData} />
124123
</AssetNodeRow>
125124
)}
126-
{facets.has(AssetNodeFacet.Freshness) &&
127-
(observeEnabled() ? (
128-
<AssetNodeFreshnessRow definition={definition} liveData={liveData} />
129-
) : (
130-
<AssetNodeFreshnessRowOld liveData={liveData} />
131-
))}
125+
{facets.has(AssetNodeFacet.Freshness) && (
126+
<AssetNodeFreshnessRow definition={definition} liveData={liveData} />
127+
)}
132128
{facets.has(AssetNodeFacet.Automation) && (
133129
<AssetNodeAutomationRow definition={definition} automationData={automationData} />
134130
)}
135-
{facets.has(AssetNodeFacet.Status) &&
136-
(observeEnabled() ? (
137-
<AssetNodeHealthRow definition={definition} liveData={liveData} />
138-
) : (
139-
<AssetNodeStatusRow definition={definition} liveData={liveData} />
140-
))}
131+
{facets.has(AssetNodeFacet.Status) && (
132+
<AssetNodeHealthRow definition={definition} liveData={liveData} />
133+
)}
141134
</AssetNodeBox>
142135
{facets.has(AssetNodeFacet.KindTag) && (
143136
<Box
@@ -321,29 +314,6 @@ export const AssetNodeRow = ({
321314
);
322315
};
323316

324-
const AssetNodeStatusRow = ({
325-
definition,
326-
liveData,
327-
}: {
328-
definition: AssetNodeFragment;
329-
liveData: LiveDataForNode | undefined;
330-
}) => {
331-
const {content, background} = buildAssetNodeStatusContent({
332-
assetKey: definition.assetKey,
333-
definition,
334-
liveData,
335-
});
336-
return (
337-
<AssetNodeRowBox
338-
background={background}
339-
padding={{horizontal: 8}}
340-
flex={{justifyContent: 'space-between', alignItems: 'center', gap: 6}}
341-
>
342-
{content}
343-
</AssetNodeRowBox>
344-
);
345-
};
346-
347317
const SingleOwnerOrTooltip = ({owners}: {owners: AssetNodeFragment['owners']}) => {
348318
if (owners.length === 1) {
349319
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

0 commit comments

Comments
 (0)