Skip to content

Commit 6f9e03b

Browse files
author
Roman.Sergeenko
committed
#RI-2061 - remove resizable from Enablement Area, add control to expand/collapse
1 parent e0e5cdc commit 6f9e03b

File tree

16 files changed

+280
-167
lines changed

16 files changed

+280
-167
lines changed

redisinsight/ui/src/pages/workbench/components/enablament-area/EnablementArea/components/InternalPage/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
@mixin font{
22
font: normal normal normal 14px/24px Graphik;
33
letter-spacing: -0.14px;
4+
@media only screen and (max-width: 1440px) {
5+
font: normal normal normal 13px/18px Graphik;
6+
letter-spacing: -0.13px;
7+
}
48
@media only screen and (max-width: 992px) {
59
font: normal normal normal 12px/18px Graphik;
610
letter-spacing: -0.12px;

redisinsight/ui/src/pages/workbench/components/enablament-area/EnablementArea/styles.module.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ $paddingHorizontal: 18px;
77
overflow: hidden;
88
height: 100%;
99
padding: 0 $paddingHorizontal;
10-
background-color: var(--euiColorEmptyShade);
11-
border: 1px solid var(--euiColorLightShade) !important;
10+
flex-grow: 1;
1211
}
1312

1413
.innerContainer {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react'
2+
import { render } from 'uiSrc/utils/test-utils'
3+
import EnablementAreaCollapse from './EnablementAreaCollapse'
4+
5+
describe('EnablementAreaCollapse', () => {
6+
it('should render', () => {
7+
expect(render(<EnablementAreaCollapse isMinimized setIsMinimized={jest.fn} />)).toBeTruthy()
8+
})
9+
10+
it('should be minimized', () => {
11+
const { queryByTestId } = render(<EnablementAreaCollapse isMinimized setIsMinimized={jest.fn} />)
12+
expect(queryByTestId('expand-enablement-area')).toBeInTheDocument()
13+
})
14+
15+
it('should be expanded', () => {
16+
const { queryByTestId } = render(<EnablementAreaCollapse isMinimized={false} setIsMinimized={jest.fn} />)
17+
expect(queryByTestId('collapse-enablement-area')).toBeInTheDocument()
18+
})
19+
})
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react'
2+
import cx from 'classnames'
3+
import { EuiButtonIcon, EuiToolTip } from '@elastic/eui'
4+
5+
import styles from './styles.module.scss'
6+
7+
export interface Props {
8+
isMinimized: boolean;
9+
setIsMinimized: (value: boolean) => void;
10+
}
11+
12+
const EnablementAreaCollapse = ({ isMinimized, setIsMinimized }: Props) => (
13+
<div className={cx(styles.wrapper, { [styles.minimized]: isMinimized })}>
14+
{isMinimized ? (
15+
<EuiToolTip
16+
content="Expand"
17+
position="top"
18+
display="inlineBlock"
19+
anchorClassName="flex-row"
20+
>
21+
<EuiButtonIcon
22+
className={styles.iconBtn}
23+
iconType="menuRight"
24+
color="subdued"
25+
size="m"
26+
onClick={() => setIsMinimized(true)}
27+
data-testid="expand-enablement-area"
28+
/>
29+
</EuiToolTip>
30+
) : (
31+
<EuiToolTip
32+
content="Collapse"
33+
position="top"
34+
display="inlineBlock"
35+
anchorClassName="flex-row"
36+
>
37+
<EuiButtonIcon
38+
className={cx(styles.iconBtn, styles.btnHide)}
39+
iconType="menuLeft"
40+
color="primary"
41+
size="m"
42+
onClick={() => setIsMinimized(true)}
43+
data-testid="collapse-enablement-area"
44+
/>
45+
</EuiToolTip>
46+
)}
47+
</div>
48+
)
49+
50+
export default EnablementAreaCollapse
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.wrapper {
2+
display: flex;
3+
align-items: center;
4+
justify-content: center;
5+
6+
&:not(.minimized) {
7+
position: absolute;
8+
top: 50%;
9+
right: 0;
10+
transform: translate(50%, -50%);
11+
z-index: 1;
12+
}
13+
14+
&.minimized {
15+
border-color: transparent;
16+
height: 100%;
17+
}
18+
}
19+
20+
.iconBtn {
21+
width: 20px !important;
22+
height: 20px !important;
23+
24+
:global(.euiIcon) {
25+
width: 20px !important;
26+
height: 20px !important;
27+
}
28+
29+
&:focus {
30+
background-color: transparent !important;
31+
}
32+
33+
&.btnHide, &.btnHide:focus {
34+
width: 32px !important;
35+
height: 32px !important;
36+
background-color: var(--euiColorLightestShade) !important;
37+
border: 1px solid var(--euiColorPrimary) !important;
38+
39+
&:hover {
40+
background-color: var(--buttonIconPrimaryHover) !important;
41+
}
42+
}
43+
}

redisinsight/ui/src/pages/workbench/components/enablament-area/EnablementAreaWrapper.tsx

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useEffect } from 'react'
22
import { monaco } from 'react-monaco-editor'
3+
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'
4+
import cx from 'classnames'
35
import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api'
46
import { useDispatch, useSelector } from 'react-redux'
57
import { useParams } from 'react-router-dom'
@@ -9,14 +11,19 @@ import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
911
import { fetchEnablementArea, workbenchEnablementAreaSelector } from 'uiSrc/slices/workbench/wb-enablement-area'
1012

1113
import EnablementArea from './EnablementArea'
14+
import EnablementAreaCollapse from './EnablementAreaCollapse/EnablementAreaCollapse'
1215
import { IInternalPage } from '../../contexts/enablementAreaContext'
1316

17+
import styles from './styles.module.scss'
18+
1419
export interface Props {
20+
isMinimized: boolean;
21+
setIsMinimized: (value: boolean) => void;
1522
scriptEl: Nullable<monacoEditor.editor.IStandaloneCodeEditor>;
1623
setScript: (script: string) => void;
1724
}
1825

19-
const EnablementAreaWrapper = React.memo(({ scriptEl, setScript }: Props) => {
26+
const EnablementAreaWrapper = React.memo(({ isMinimized, setIsMinimized, scriptEl, setScript }: Props) => {
2027
const { loading, items } = useSelector(workbenchEnablementAreaSelector)
2128
const { instanceId = '' } = useParams<{ instanceId: string }>()
2229
const dispatch = useDispatch()
@@ -56,12 +63,30 @@ const EnablementAreaWrapper = React.memo(({ scriptEl, setScript }: Props) => {
5663
}
5764

5865
return (
59-
<EnablementArea
60-
items={items}
61-
loading={loading}
62-
openScript={openScript}
63-
openInternalPage={openInternalPage}
64-
/>
66+
<EuiFlexGroup
67+
className={cx(styles.areaWrapper, { [styles.minimized]: isMinimized })}
68+
onClick={() => isMinimized && setIsMinimized(false)}
69+
direction="column"
70+
gutterSize="none"
71+
>
72+
<EuiFlexItem
73+
className={cx(styles.collapseWrapper, { [styles.minimized]: isMinimized })}
74+
grow={isMinimized}
75+
>
76+
<EnablementAreaCollapse isMinimized={isMinimized} setIsMinimized={setIsMinimized} />
77+
</EuiFlexItem>
78+
<EuiFlexItem
79+
className={cx(styles.areaContentWrapper, { [styles.minimized]: isMinimized })}
80+
grow={!isMinimized}
81+
>
82+
<EnablementArea
83+
items={items}
84+
loading={loading}
85+
openScript={openScript}
86+
openInternalPage={openInternalPage}
87+
/>
88+
</EuiFlexItem>
89+
</EuiFlexGroup>
6590
)
6691
})
6792

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.areaWrapper {
2+
overflow: hidden;
3+
height: 100%;
4+
background-color: var(--euiColorEmptyShade);
5+
border: 1px solid var(--euiColorLightShade) !important;
6+
7+
&.minimized {
8+
cursor: pointer;
9+
&:hover {
10+
background-color: var(--hoverInListColorDarken);
11+
}
12+
}
13+
14+
&:not(.minimized) {
15+
&:hover {
16+
.collapseWrapper {
17+
display: flex;
18+
}
19+
}
20+
}
21+
}
22+
23+
.collapseWrapper {
24+
&:not(.minimized) {
25+
display: none;
26+
}
27+
}
28+
29+
.areaContentWrapper {
30+
&.minimized {
31+
width: 0;
32+
visibility: hidden;
33+
height: 0;
34+
}
35+
}

0 commit comments

Comments
 (0)