Lineage node with no columns (#24421)

* Hide footer when node does not have children

* Add unit test

* Do not render searchbar when there is no column
This commit is contained in:
Ushran Gouhar 2025-11-19 13:34:47 +05:30 committed by GitHub
parent 9af41247ec
commit 6f58f18a7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 82 additions and 8 deletions

View File

@ -151,7 +151,7 @@ describe('CustomNodeV1', () => {
expect(screen.getByTestId('dbt-icon')).toBeInTheDocument();
});
it('should render children dropdown button', () => {
it('should render footer only when there are children', () => {
isColumnLayerActive = true;
render(
<ReactFlowProvider>
@ -167,6 +167,65 @@ describe('CustomNodeV1', () => {
).toBeInTheDocument();
});
it('should not render footer when there are no children', () => {
isColumnLayerActive = true;
const mockNodeDataPropsNoChildren = {
...mockNodeDataProps,
data: {
node: {
...mockNodeDataProps.data.node,
columns: [],
},
},
};
render(
<ReactFlowProvider>
<CustomNodeV1Component {...mockNodeDataPropsNoChildren} />
</ReactFlowProvider>
);
expect(
screen.queryByTestId('children-info-dropdown-btn')
).not.toBeInTheDocument();
});
it('should render NodeChildren when column layer is applied and there are no columns', () => {
isColumnLayerActive = true;
render(
<ReactFlowProvider>
<CustomNodeV1Component {...mockNodeDataProps} />
</ReactFlowProvider>
);
expect(screen.getByTestId('column-container')).toBeInTheDocument();
});
it('should not render NodeChildren when column layer is applied but there are no columns', () => {
isColumnLayerActive = true;
const mockNodeDataPropsNoChildren = {
...mockNodeDataProps,
data: {
node: {
...mockNodeDataProps.data.node,
columns: [],
},
},
};
render(
<ReactFlowProvider>
<CustomNodeV1Component {...mockNodeDataPropsNoChildren} />
</ReactFlowProvider>
);
screen.debug(undefined, Infinity);
expect(screen.queryByTestId('column-container')).not.toBeInTheDocument();
});
it('should toggle columns list when children dropdown button is clicked', () => {
render(
<ReactFlowProvider>

View File

@ -58,8 +58,18 @@ const EntityLabel = ({ node }: LineageNodeLabelPropsExtended) => {
};
}, [node]);
const { children } = useMemo(
() => getEntityChildrenAndLabel(node),
[node.id]
);
const childrenCount = children.length;
return (
<Col className="items-center entity-label-container">
<Col
className={classNames(
'items-center entity-label-container',
childrenCount > 0 ? 'with-footer' : ''
)}>
<Col className="d-flex items-center m-b-sm" flex="auto">
<div className="d-flex entity-service-icon m-r-xs">
{getServiceIcon(node)}
@ -182,6 +192,10 @@ const EntityFooter = ({
[toggleColumnsList]
);
if (childrenCount === 0) {
return null;
}
return (
<div className="entity-footer">
<Button

View File

@ -306,8 +306,9 @@ const NodeChildren = ({
(isColumnLayerEnabled || showDataObservability || isChildrenListExpanded)
) {
return (
(isColumnLayerEnabled || isChildrenListExpanded) && (
<div className="column-container">
(isColumnLayerEnabled || isChildrenListExpanded) &&
!isEmpty(renderedColumns) && (
<div className="column-container" data-testid="column-container">
<div className="search-box">
<Input
placeholder={t('label.search-entity', {
@ -319,7 +320,7 @@ const NodeChildren = ({
onClick={(e) => e.stopPropagation()}
/>
{isChildrenListExpanded && !isEmpty(renderedColumns) && (
{isChildrenListExpanded && (
<section className="m-t-md" id="table-columns">
<div className="rounded-4 overflow-hidden">
{renderedColumns}

View File

@ -77,7 +77,6 @@
.label-container {
.custom-node-label-container {
width: 100%;
min-height: 84px;
.lineage-breadcrumb {
.lineage-breadcrumb-item {
white-space: nowrap;
@ -104,7 +103,7 @@
width: 28px;
}
&::after {
&.with-footer::after {
display: block;
width: 100%;
height: 1px;
@ -530,7 +529,7 @@
border-radius: 4px !important;
border-color: @lineage-border !important;
background: @white !important;
top: 60px !important;
top: min(58px, 50%) !important;
left: 100%;
transform: translate(-50%, -50%);
@ -574,6 +573,7 @@
border-color: @lineage-border !important;
background: @white !important;
top: 60px !important; // Need to show handles on top half
top: min(58px, 50%) !important;
svg {
color: @text-grey-muted;