1
1
import React , { useCallback , useEffect , useRef , useState } from 'react'
2
2
import { useSelector } from 'react-redux'
3
+ import styled from 'styled-components'
3
4
4
5
import InstanceHeader from 'uiSrc/components/instance-header'
5
6
import { ExplorePanelTemplate } from 'uiSrc/templates'
@@ -27,6 +28,10 @@ export interface Props {
27
28
children : React . ReactNode
28
29
}
29
30
31
+ const ButtonGroupResizablePanel = styled ( ResizablePanel ) `
32
+ flex-basis: 27px !important;
33
+ `
34
+
30
35
export const getDefaultSizes = ( ) => {
31
36
const storedSizes = localStorageService . get (
32
37
BrowserStorageItem . cliResizableContainer ,
@@ -35,17 +40,6 @@ export const getDefaultSizes = () => {
35
40
return storedSizes && Array . isArray ( storedSizes ) ? storedSizes : [ 60 , 40 ]
36
41
}
37
42
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
-
49
43
const roundUpSizes = ( sizes : number [ ] ) => [
50
44
Math . floor ( sizes [ 0 ] ) ,
51
45
Math . ceil ( sizes [ 1 ] ) ,
@@ -58,9 +52,6 @@ const InstancePageTemplate = (props: Props) => {
58
52
const { isShowCli, isShowHelper } = useSelector ( cliSettingsSelector )
59
53
const { isShowMonitor } = useSelector ( monitorSelector )
60
54
61
- const sizeMain : number = calculateMainPanelInitialSize ( )
62
- const sizeBottomCollapsed : number = calculateBottomGroupPanelInitialSize ( )
63
-
64
55
const ref = useRef < ImperativePanelGroupHandle > ( null )
65
56
66
57
useEffect (
@@ -92,7 +83,7 @@ const InstancePageTemplate = (props: Props) => {
92
83
if ( isShowBottomGroup ) {
93
84
ref . current ?. setLayout ( roundUpSizes ( sizes ) )
94
85
} else {
95
- ref . current ?. setLayout ( [ sizeMain , sizeBottomCollapsed ] )
86
+ ref . current ?. setLayout ( [ 100 , 0 ] )
96
87
}
97
88
} , [ isShowBottomGroup ] )
98
89
@@ -111,7 +102,7 @@ const InstancePageTemplate = (props: Props) => {
111
102
< ResizablePanel
112
103
id = { firstPanelId }
113
104
minSize = { 7 }
114
- defaultSize = { isShowBottomGroup ? sizes [ 0 ] : sizeMain }
105
+ defaultSize = { isShowBottomGroup ? sizes [ 0 ] : 100 }
115
106
data-testid = { firstPanelId }
116
107
>
117
108
< AppNavigationActionsProvider
@@ -129,15 +120,15 @@ const InstancePageTemplate = (props: Props) => {
129
120
data-testid = "resize-btn-browser-cli"
130
121
style = { { display : isShowBottomGroup ? 'inherit' : 'none' } }
131
122
/>
132
- < Spacer size = "m " />
133
- < ResizablePanel
123
+ { ! isShowBottomGroup && < Spacer size = "l " /> }
124
+ < ButtonGroupResizablePanel
134
125
id = { secondPanelId }
135
- defaultSize = { isShowBottomGroup ? sizes [ 1 ] : sizeBottomCollapsed }
126
+ defaultSize = { isShowBottomGroup ? sizes [ 1 ] : 0 }
136
127
minSize = { isShowBottomGroup ? 20 : 0 }
137
128
data-testid = { secondPanelId }
138
129
>
139
130
< BottomGroupComponents />
140
- </ ResizablePanel >
131
+ </ ButtonGroupResizablePanel >
141
132
</ ResizableContainer >
142
133
</ >
143
134
)
0 commit comments