Skip to content

Commit d120b4a

Browse files
authored
RI-7006: Replace resize related components (#4574)
* Replace EUI panel with another libs resizable panel. * change browser panel sizes by the new array model instead of the key value object * add wrappers around the resizable components * replace the workbench view - query and result panel section * replace panels in instance page template * finish the handle design * create and replace the ResizeObserver everywhere * moved ImperativePanelGroupHandle import in resize components
1 parent 1f9c8bd commit d120b4a

File tree

27 files changed

+410
-341
lines changed

27 files changed

+410
-341
lines changed

jest.config.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module.exports = {
2626
'^uuid$': require.resolve('uuid'),
2727
msgpackr: require.resolve('msgpackr'),
2828
'brotli-dec-wasm': '<rootDir>/redisinsight/__mocks__/brotli-dec-wasm.js',
29+
'react-resizable-panels':
30+
'<rootDir>/redisinsight/__mocks__/react-resizable-panels.js',
2931
},
3032
setupFiles: [
3133
'construct-style-sheets-polyfill',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@
279279
"react-jsx-parser": "^1.28.4",
280280
"react-monaco-editor": "^0.55.0",
281281
"react-redux": "^7.2.2",
282+
"react-resizable-panels": "^3.0.2",
282283
"react-rnd": "^10.3.5",
283284
"react-router-dom": "^5.3.4",
284285
"react-virtualized": "^9.22.2",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const Panel = ({ children }) => children;
2+
export const PanelGroup = ({ children }) => children;
3+
export const PanelResizeHandle = () => 'MockPanelResizeHandle';
4+
5+
// Mock utility functions and constants
6+
export const DATA_ATTRIBUTES = {};
7+
8+
export const assert = jest.fn();
9+
export const disableGlobalCursorStyles = jest.fn();
10+
export const enableGlobalCursorStyles = jest.fn();
11+
export const getIntersectingRectangle = jest.fn();
12+
export const getPanelElement = jest.fn();
13+
export const getPanelElementsForGroup = jest.fn();
14+
export const getPanelGroupElement = jest.fn();
15+
export const getResizeHandleElement = jest.fn();
16+
export const getResizeHandleElementIndex = jest.fn();
17+
export const getResizeHandleElementsForGroup = jest.fn();
18+
export const getResizeHandlePanelIds = jest.fn();
19+
export const intersects = jest.fn();
20+
export const setNonce = jest.fn();
21+
export const usePanelGroupContext = jest.fn();
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
import HorizontalRule from './horizontal-rule/HorizontalRule'
22
import LoadingContent from './loading-content/LoadingContent'
3+
import ResizableContainer from './resize/container/ResizableContainer'
4+
import ResizablePanel from './resize/panel/ResizablePanel'
5+
import ResizablePanelHandle from './resize/handle/ResizablePanelHandle'
36

4-
export { HorizontalRule, LoadingContent }
7+
export {
8+
HorizontalRule,
9+
LoadingContent,
10+
ResizablePanel,
11+
ResizableContainer,
12+
ResizablePanelHandle,
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React, { forwardRef } from 'react'
2+
3+
import {
4+
ImperativePanelGroupHandle,
5+
PanelGroup,
6+
PanelGroupProps,
7+
} from 'react-resizable-panels'
8+
9+
const ResizableContainer = forwardRef<
10+
ImperativePanelGroupHandle,
11+
PanelGroupProps
12+
>((props, ref) => <PanelGroup ref={ref} {...props} />)
13+
14+
export default ResizableContainer
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react'
2+
import {
3+
HandleContainer,
4+
Line,
5+
ResizablePanelHandleProps,
6+
StyledPanelResizeHandle,
7+
} from './resizable-panel-handle.styles'
8+
9+
const ResizablePanelHandle = ({
10+
className,
11+
direction = 'vertical',
12+
...rest
13+
}: ResizablePanelHandleProps) => (
14+
<StyledPanelResizeHandle
15+
$direction={direction}
16+
className={className}
17+
{...rest}
18+
>
19+
<HandleContainer $direction={direction}>
20+
<Line />
21+
<Line />
22+
</HandleContainer>
23+
</StyledPanelResizeHandle>
24+
)
25+
26+
export default ResizablePanelHandle
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import {
2+
PanelResizeHandle,
3+
PanelResizeHandleProps,
4+
} from 'react-resizable-panels'
5+
import styled, { css } from 'styled-components'
6+
7+
export interface ResizablePanelHandleProps extends PanelResizeHandleProps {
8+
direction?: 'horizontal' | 'vertical'
9+
}
10+
11+
export const StyledPanelResizeHandle = styled(PanelResizeHandle)<{
12+
$direction: 'horizontal' | 'vertical'
13+
}>`
14+
${({ $direction }) =>
15+
$direction === 'vertical'
16+
? css`
17+
width: 16px;
18+
height: 100%;
19+
display: flex;
20+
flex-direction: column;
21+
justify-content: center;
22+
`
23+
: css`
24+
height: 16px;
25+
width: 100%;
26+
display: flex;
27+
flex-direction: row;
28+
justify-content: center;
29+
`}
30+
`
31+
32+
export const HandleContainer = styled.div<{
33+
$direction: 'horizontal' | 'vertical'
34+
children?: React.ReactNode
35+
}>`
36+
width: 16px;
37+
height: 16px;
38+
display: flex;
39+
flex-direction: column;
40+
justify-content: center;
41+
align-items: center;
42+
gap: 2px;
43+
44+
${({ $direction }) =>
45+
$direction === 'vertical' &&
46+
css`
47+
transform: rotate(90deg);
48+
`}
49+
`
50+
51+
export const Line = styled.div`
52+
width: 12px;
53+
height: 1px;
54+
background-color: #343741;
55+
`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ImperativePanelGroupHandle } from 'react-resizable-panels'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react'
2+
3+
import { Panel, PanelProps } from 'react-resizable-panels'
4+
5+
const ResizablePanel = (props: PanelProps) => <Panel {...props} />
6+
7+
export default ResizablePanel
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { OutsideClickDetector } from './OutsideClickDetector'
2+
export { RIResizeObserver } from './resize-observer/ResizeObserver'

0 commit comments

Comments
 (0)