Skip to content

Commit 2ed87d8

Browse files
committed
[Metrics UI] Fix inventory footer misalignment
1 parent 543109b commit 2ed87d8

File tree

3 files changed

+52
-34
lines changed

3 files changed

+52
-34
lines changed

x-pack/plugins/infra/public/pages/metrics/inventory_view/components/layout.tsx

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import React, { useCallback, useEffect } from 'react';
88
import { useInterval } from 'react-use';
99

1010
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
11+
import { AutoSizer } from '../../../../components/auto_sizer';
1112
import { convertIntervalToString } from '../../../../utils/convert_interval_to_string';
1213
import { NodesOverview } from './nodes_overview';
1314
import { calculateBoundsFromNodes } from '../lib/calculate_bounds_from_nodes';
@@ -110,37 +111,44 @@ export const Layout = () => {
110111
</EuiFlexItem>
111112
</EuiFlexGroup>
112113
</TopActionContainer>
113-
<NodesOverview
114-
nodes={nodes}
115-
options={options}
116-
nodeType={nodeType}
117-
loading={loading}
118-
reload={reload}
119-
onDrilldown={applyFilterQuery}
120-
currentTime={currentTime}
121-
view={view}
122-
autoBounds={autoBounds}
123-
boundsOverride={boundsOverride}
124-
formatter={formatter}
125-
/>
126-
<BottomActionContainer>
127-
<EuiFlexGroup justifyContent="spaceBetween">
128-
<EuiFlexItem grow={false}>
129-
<SavedViewsToolbarControls viewState={viewState} />
130-
</EuiFlexItem>
131-
<EuiFlexItem grow={false} style={{ position: 'relative', minWidth: 400 }}>
132-
<Legend
114+
<AutoSizer bounds>
115+
{({ measureRef, bounds: { height = 0 } }) => (
116+
<>
117+
<NodesOverview
118+
nodes={nodes}
119+
options={options}
120+
nodeType={nodeType}
121+
loading={loading}
122+
reload={reload}
123+
onDrilldown={applyFilterQuery}
124+
currentTime={currentTime}
125+
view={view}
126+
autoBounds={autoBounds}
127+
boundsOverride={boundsOverride}
133128
formatter={formatter}
134-
bounds={bounds}
135-
dataBounds={dataBounds}
136-
legend={options.legend}
129+
bottomMargin={height}
137130
/>
138-
</EuiFlexItem>
139-
<EuiFlexItem grow={false}>
140-
<IntervalLabel intervalAsString={intervalAsString} />
141-
</EuiFlexItem>
142-
</EuiFlexGroup>
143-
</BottomActionContainer>
131+
<BottomActionContainer ref={measureRef}>
132+
<EuiFlexGroup justifyContent="spaceBetween">
133+
<EuiFlexItem grow={false}>
134+
<SavedViewsToolbarControls viewState={viewState} />
135+
</EuiFlexItem>
136+
<EuiFlexItem grow={false} style={{ position: 'relative', minWidth: 400 }}>
137+
<Legend
138+
formatter={formatter}
139+
bounds={bounds}
140+
dataBounds={dataBounds}
141+
legend={options.legend}
142+
/>
143+
</EuiFlexItem>
144+
<EuiFlexItem grow={false}>
145+
<IntervalLabel intervalAsString={intervalAsString} />
146+
</EuiFlexItem>
147+
</EuiFlexGroup>
148+
</BottomActionContainer>
149+
</>
150+
)}
151+
</AutoSizer>
144152
</MainContainer>
145153
</PageContent>
146154
</>
@@ -159,9 +167,9 @@ const TopActionContainer = euiStyled.div`
159167
const BottomActionContainer = euiStyled.div`
160168
background-color: ${(props) => props.theme.eui.euiPageBackgroundColor};
161169
padding: ${(props) => props.theme.eui.paddingSizes.m} ${(props) =>
162-
props.theme.eui.paddingSizes.m} ${(props) => props.theme.eui.paddingSizes.s};
163-
position: absolute;
170+
props.theme.eui.paddingSizes.m};
171+
position: fixed;
164172
left: 0;
165-
bottom: 4px;
173+
bottom: 0;
166174
right: 0;
167175
`;

x-pack/plugins/infra/public/pages/metrics/inventory_view/components/nodes_overview.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface Props {
3434
boundsOverride: InfraWaffleMapBounds;
3535
autoBounds: boolean;
3636
formatter: InfraFormatter;
37+
bottomMargin: number;
3738
}
3839

3940
export const NodesOverview = ({
@@ -48,6 +49,7 @@ export const NodesOverview = ({
4849
options,
4950
formatter,
5051
onDrilldown,
52+
bottomMargin,
5153
}: Props) => {
5254
const handleDrilldown = useCallback(
5355
(filter: string) => {
@@ -118,6 +120,7 @@ export const NodesOverview = ({
118120
onFilter={handleDrilldown}
119121
bounds={bounds}
120122
dataBounds={dataBounds}
123+
bottomMargin={bottomMargin}
121124
/>
122125
</MapContainer>
123126
);

x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/map.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface Props {
2626
onFilter: (filter: string) => void;
2727
bounds: InfraWaffleMapBounds;
2828
dataBounds: InfraWaffleMapBounds;
29+
bottomMargin: number;
2930
}
3031

3132
export const Map: React.FC<Props> = ({
@@ -37,6 +38,7 @@ export const Map: React.FC<Props> = ({
3738
bounds,
3839
nodeType,
3940
dataBounds,
41+
bottomMargin,
4042
}) => {
4143
const sortedNodes = sortNodes(options.sort, nodes);
4244
const map = nodesToWaffleMap(sortedNodes);
@@ -45,7 +47,11 @@ export const Map: React.FC<Props> = ({
4547
{({ measureRef, content: { width = 0, height = 0 } }) => {
4648
const groupsWithLayout = applyWaffleMapLayout(map, width, height);
4749
return (
48-
<WaffleMapOuterContainer ref={(el: any) => measureRef(el)} data-test-subj="waffleMap">
50+
<WaffleMapOuterContainer
51+
ref={(el: any) => measureRef(el)}
52+
bottomMargin={bottomMargin}
53+
data-test-subj="waffleMap"
54+
>
4955
<WaffleMapInnerContainer>
5056
{groupsWithLayout.map((group) => {
5157
if (isWaffleMapGroupWithGroups(group)) {
@@ -86,13 +92,14 @@ export const Map: React.FC<Props> = ({
8692
);
8793
};
8894

89-
const WaffleMapOuterContainer = euiStyled.div`
95+
const WaffleMapOuterContainer = euiStyled.div<{ bottomMargin: number }>`
9096
flex: 1 0 0%;
9197
display: flex;
9298
justify-content: flex-start;
9399
flex-direction: column;
94100
overflow-x: hidden;
95101
overflow-y: auto;
102+
margin-bottom: ${(props) => props.bottomMargin}px;
96103
`;
97104

98105
const WaffleMapInnerContainer = euiStyled.div`

0 commit comments

Comments
 (0)