Skip to content

Commit 24818d1

Browse files
authored
RI-7560: fix bottom group panel movement when expand / collapse (#5012)
* refactor the panel sizing logic to avoid movement on the bottom group section when expanded/collapsed * make key details border radius 8px to match the one of the key list on the left * move the border inline styles to a styled component and use for both panels
1 parent abf3bf2 commit 24818d1

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

redisinsight/ui/src/pages/browser/BrowserPage.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import cx from 'classnames'
55

66
import { isNumber } from 'lodash'
77
import { useTheme } from '@redis-ui/styles'
8+
import styled from 'styled-components'
9+
810
import {
911
formatLongName,
1012
getDbIndex,
@@ -66,6 +68,11 @@ const widthExplorePanel = 460
6668
export const firstPanelId = 'keys'
6769
export const secondPanelId = 'keyDetails'
6870

71+
const BorderedResizablePanel = styled(ResizablePanel)`
72+
border-radius: 8px;
73+
border: 1px solid ${({ theme }) => theme.semantic.color.border.neutral500};
74+
`
75+
6976
const isOneSideMode = (isInsightsOpen: boolean) =>
7077
globalThis.innerWidth <
7178
widthResponsiveSize + (isInsightsOpen ? widthExplorePanel : 0)
@@ -324,7 +331,7 @@ const BrowserPage = () => {
324331
direction="horizontal"
325332
onLayout={onPanelWidthChange}
326333
>
327-
<ResizablePanel
334+
<BorderedResizablePanel
328335
defaultSize={sizes && sizes[0] ? sizes[0] : 50}
329336
minSize={45}
330337
id={firstPanelId}
@@ -333,22 +340,18 @@ const BrowserPage = () => {
333340
arePanelsCollapsed ||
334341
(isBrowserFullScreen && !isRightPanelOpen),
335342
})}
336-
style={{
337-
border: `1px solid ${theme.semantic.color.border.neutral500}`,
338-
borderRadius: `8px`,
339-
}}
340343
>
341344
<BrowserLeftPanel
342345
selectedKey={selectedKey}
343346
selectKey={selectKey}
344347
removeSelectedKey={handleRemoveSelectedKey}
345348
handleAddKeyPanel={handleAddKeyPanel}
346349
/>
347-
</ResizablePanel>
350+
</BorderedResizablePanel>
348351
{!arePanelsCollapsed && !isBrowserFullScreen && (
349352
<ResizablePanelHandle />
350353
)}
351-
<ResizablePanel
354+
<BorderedResizablePanel
352355
defaultSize={sizes && sizes[1] ? sizes[1] : 50}
353356
minSize={45}
354357
id={secondPanelId}
@@ -359,10 +362,6 @@ const BrowserPage = () => {
359362
[styles.keyDetails]:
360363
arePanelsCollapsed || (isRightPanelOpen && isBrowserFullScreen),
361364
})}
362-
style={{
363-
border: `1px solid ${theme.semantic.color.border.neutral500}`,
364-
borderRadius: `5px`,
365-
}}
366365
>
367366
<BrowserRightPanel
368367
arePanelsCollapsed={arePanelsCollapsed}
@@ -375,7 +374,7 @@ const BrowserPage = () => {
375374
handleBulkActionsPanel={handleBulkActionsPanel}
376375
closeRightPanels={closeRightPanels}
377376
/>
378-
</ResizablePanel>
377+
</BorderedResizablePanel>
379378
</ResizableContainer>
380379
</div>
381380
<OnboardingStartPopover />

redisinsight/ui/src/templates/instance-page-template/InstancePageTemplate.tsx

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useCallback, useEffect, useRef, useState } from 'react'
22
import { useSelector } from 'react-redux'
3+
import styled from 'styled-components'
34

45
import InstanceHeader from 'uiSrc/components/instance-header'
56
import { ExplorePanelTemplate } from 'uiSrc/templates'
@@ -27,6 +28,10 @@ export interface Props {
2728
children: React.ReactNode
2829
}
2930

31+
const ButtonGroupResizablePanel = styled(ResizablePanel)`
32+
flex-basis: 27px !important;
33+
`
34+
3035
export const getDefaultSizes = () => {
3136
const storedSizes = localStorageService.get(
3237
BrowserStorageItem.cliResizableContainer,
@@ -35,17 +40,6 @@ export const getDefaultSizes = () => {
3540
return storedSizes && Array.isArray(storedSizes) ? storedSizes : [60, 40]
3641
}
3742

38-
export const calculateMainPanelInitialSize = () => {
39-
const total = window.innerHeight
40-
const remaining = total - 26
41-
return Math.floor((remaining / total) * 100)
42-
}
43-
44-
export const calculateBottomGroupPanelInitialSize = () => {
45-
const total = window.innerHeight
46-
return Math.ceil((26 / total) * 100)
47-
}
48-
4943
const roundUpSizes = (sizes: number[]) => [
5044
Math.floor(sizes[0]),
5145
Math.ceil(sizes[1]),
@@ -58,9 +52,6 @@ const InstancePageTemplate = (props: Props) => {
5852
const { isShowCli, isShowHelper } = useSelector(cliSettingsSelector)
5953
const { isShowMonitor } = useSelector(monitorSelector)
6054

61-
const sizeMain: number = calculateMainPanelInitialSize()
62-
const sizeBottomCollapsed: number = calculateBottomGroupPanelInitialSize()
63-
6455
const ref = useRef<ImperativePanelGroupHandle>(null)
6556

6657
useEffect(
@@ -92,7 +83,7 @@ const InstancePageTemplate = (props: Props) => {
9283
if (isShowBottomGroup) {
9384
ref.current?.setLayout(roundUpSizes(sizes))
9485
} else {
95-
ref.current?.setLayout([sizeMain, sizeBottomCollapsed])
86+
ref.current?.setLayout([100, 0])
9687
}
9788
}, [isShowBottomGroup])
9889

@@ -111,7 +102,7 @@ const InstancePageTemplate = (props: Props) => {
111102
<ResizablePanel
112103
id={firstPanelId}
113104
minSize={7}
114-
defaultSize={isShowBottomGroup ? sizes[0] : sizeMain}
105+
defaultSize={isShowBottomGroup ? sizes[0] : 100}
115106
data-testid={firstPanelId}
116107
>
117108
<AppNavigationActionsProvider
@@ -129,15 +120,15 @@ const InstancePageTemplate = (props: Props) => {
129120
data-testid="resize-btn-browser-cli"
130121
style={{ display: isShowBottomGroup ? 'inherit' : 'none' }}
131122
/>
132-
<Spacer size="m" />
133-
<ResizablePanel
123+
{!isShowBottomGroup && <Spacer size="l" />}
124+
<ButtonGroupResizablePanel
134125
id={secondPanelId}
135-
defaultSize={isShowBottomGroup ? sizes[1] : sizeBottomCollapsed}
126+
defaultSize={isShowBottomGroup ? sizes[1] : 0}
136127
minSize={isShowBottomGroup ? 20 : 0}
137128
data-testid={secondPanelId}
138129
>
139130
<BottomGroupComponents />
140-
</ResizablePanel>
131+
</ButtonGroupResizablePanel>
141132
</ResizableContainer>
142133
</>
143134
)

0 commit comments

Comments
 (0)