Skip to content

Commit 422701a

Browse files
committed
NO-JIRA: fix: troubleshooting panel breaking into columns on resize.
Also added automatic graph resize if browser resizes.
1 parent 3c49e87 commit 422701a

3 files changed

Lines changed: 55 additions & 42 deletions

File tree

web/src/components/Korrel8rPanel.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
Form,
1414
FormGroup,
1515
Spinner,
16+
Stack,
17+
StackItem,
1618
TextArea,
1719
Title,
1820
Tooltip,
@@ -226,18 +228,18 @@ export default function Korrel8rPanel() {
226228

227229
return (
228230
<>
229-
<Flex direction={{ default: 'column' }} grow={{ default: 'grow' }}>
231+
<Stack>
230232
<Flex className="tp-plugin__panel-query-container" direction={{ default: 'row' }}>
231233
{focusButton}
232234
<FlexItem align={{ default: 'alignRight' }}>{advancedToggle}</FlexItem>
233235
{refreshButton}
234236
</Flex>
235-
<FlexItem>{advancedSection}</FlexItem>
237+
{advancedSection}
236238
<Divider />
237-
<FlexItem className="tp-plugin__panel-topology-container" grow={{ default: 'grow' }}>
239+
<StackItem className="tp-plugin__panel-topology-container" isFilled={true}>
238240
{topologySection}
239-
</FlexItem>
240-
</Flex>
241+
</StackItem>
242+
</Stack>
241243
</>
242244
);
243245
}

web/src/components/Popover.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useActivePerspective } from '@openshift-console/dynamic-plugin-sdk';
2-
import { Button, Flex, FlexItem, Title } from '@patternfly/react-core';
2+
import { Button, Flex, FlexItem, Stack, StackItem, Title } from '@patternfly/react-core';
33
import { TimesCircleIcon } from '@patternfly/react-icons';
44
import * as React from 'react';
55
import { useTranslation } from 'react-i18next';
@@ -33,11 +33,7 @@ export default function Popover() {
3333

3434
return (
3535
<>
36-
<Flex
37-
className="tp-plugin__popover"
38-
direction={{ default: 'column' }}
39-
gap={{ default: 'gapNone' }}
40-
>
36+
<Stack className="tp-plugin__popover">
4137
<Flex className="tp-plugin__popover-title-bar" gap={{ default: 'gapNone' }}>
4238
<FlexItem grow={{ default: 'grow' }}>
4339
<Title headingLevel="h1">
@@ -55,15 +51,10 @@ export default function Popover() {
5551
</Button>
5652
</FlexItem>
5753
</Flex>
58-
<Flex
59-
className="tp-plugin__popover-content"
60-
direction={{ default: 'column' }}
61-
grow={{ default: 'grow' }}
62-
gap={{ default: 'gapNone' }}
63-
>
54+
<StackItem className="tp-plugin__popover-content" isFilled={true}>
6455
<Korrel8rPanel />
65-
</Flex>
66-
</Flex>
56+
</StackItem>
57+
</Stack>
6758
</>
6859
);
6960
}

web/src/components/topology/Korrel8rTopology.tsx

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -223,29 +223,49 @@ export const Korrel8rTopology: React.FC<{
223223
return controller;
224224
}, [controller, selectionAction, componentFactory]);
225225

226+
const containerRef = React.useRef<HTMLDivElement>(null);
227+
React.useEffect(() => {
228+
const element = containerRef.current;
229+
if (!element) return;
230+
let timer: ReturnType<typeof setTimeout>;
231+
const observer = new ResizeObserver(() => {
232+
clearTimeout(timer);
233+
timer = setTimeout(() => controller.getGraph().fit(PADDING), 150);
234+
});
235+
observer.observe(element);
236+
return () => {
237+
clearTimeout(timer);
238+
observer.disconnect();
239+
};
240+
}, [controller]);
241+
226242
return (
227-
<TopologyView
228-
controlBar={
229-
<TopologyControlBar
230-
controlButtons={createTopologyControlButtons({
231-
...defaultControlButtonsOptions,
232-
zoomInCallback: action(() => {
233-
controller.getGraph().scaleBy(4 / 3);
234-
}),
235-
zoomOutCallback: action(() => {
236-
controller.getGraph().scaleBy(0.75);
237-
}),
238-
fitToScreenCallback: action(() => {
239-
controller.getGraph().fit(PADDING);
240-
}),
241-
legend: false,
242-
})}
243-
/>
244-
}
245-
>
246-
<VisualizationProvider controller={controller2}>
247-
<VisualizationSurface state={{ selectedIds }} />
248-
</VisualizationProvider>
249-
</TopologyView>
243+
<div ref={containerRef} style={{ width: '100%', height: '100%' }}>
244+
<TopologyView
245+
controlBar={
246+
<TopologyControlBar
247+
controlButtons={createTopologyControlButtons({
248+
...defaultControlButtonsOptions,
249+
zoomInCallback: action(() => {
250+
controller.getGraph().scaleBy(4 / 3);
251+
}),
252+
zoomOutCallback: action(() => {
253+
controller.getGraph().scaleBy(0.75);
254+
}),
255+
fitToScreen: false, // Same thing as resetView
256+
resetViewCallback: action(() => {
257+
controller.getGraph().reset();
258+
controller.getGraph().layout();
259+
}),
260+
legend: false,
261+
})}
262+
/>
263+
}
264+
>
265+
<VisualizationProvider controller={controller2}>
266+
<VisualizationSurface state={{ selectedIds }} />
267+
</VisualizationProvider>
268+
</TopologyView>
269+
</div>
250270
);
251271
};

0 commit comments

Comments
 (0)