Skip to content

Commit 23cbe1b

Browse files
authored
Merge pull request #4268 from RedisInsight/fe/feature/RI-6451
#RI-6451 - update add database form
2 parents 1741b54 + 854d745 commit 23cbe1b

File tree

37 files changed

+616
-284
lines changed

37 files changed

+616
-284
lines changed

redisinsight/ui/src/components/instance-header/components/instances-navigation-popover/styles.module.scss

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@
8686
}
8787
}
8888

89-
.listContainer :global(.euiListGroupItem-isActive), :global(.euiListGroupItem:hover) {
90-
background-color: var(--hoverInListColorDarken) !important;
91-
color: var(--euiTextSubduedColorHover) !important;
92-
border-left-color: var(--externalLinkColor) !important;
93-
border-left-width: 3px !important;
94-
border-left-style: solid !important;
95-
text-decoration: none !important;
89+
.listContainer {
90+
:global(.euiListGroupItem-isActive), :global(.euiListGroupItem:hover) {
91+
background-color: var(--hoverInListColorDarken) !important;
92+
color: var(--euiTextSubduedColorHover) !important;
93+
border-left-color: var(--externalLinkColor) !important;
94+
border-left-width: 3px !important;
95+
border-left-style: solid !important;
96+
text-decoration: none !important;
97+
}
9698
}
9799

98100
.footerContainer {

redisinsight/ui/src/pages/home/components/connection-url/ConnectionUrl.spec.tsx renamed to redisinsight/ui/src/pages/home/components/add-database-screen/AddDatabaseScreen.spec.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { render, screen, fireEvent, mockedStore, cleanup, act } from 'uiSrc/util
55

66
import { defaultInstanceChanging } from 'uiSrc/slices/instances/instances'
77
import { AddDbType } from 'uiSrc/pages/home/constants'
8-
import ConnectionUrl, { Props } from './ConnectionUrl'
8+
import AddDatabaseScreen, { Props } from './AddDatabaseScreen'
99

1010
const mockedProps = mock<Props>()
1111

@@ -16,13 +16,13 @@ beforeEach(() => {
1616
store.clearActions()
1717
})
1818

19-
describe('ConnectionUrl', () => {
19+
describe('AddDatabaseScreen', () => {
2020
it('should render', () => {
21-
expect(render(<ConnectionUrl {...mockedProps} />)).toBeTruthy()
21+
expect(render(<AddDatabaseScreen {...mockedProps} />)).toBeTruthy()
2222
})
2323

2424
it('should call proper actions with empty connection url', async () => {
25-
render(<ConnectionUrl {...mockedProps} />)
25+
render(<AddDatabaseScreen {...mockedProps} />)
2626

2727
await act(async () => {
2828
fireEvent.click(screen.getByTestId('btn-submit'))
@@ -32,7 +32,7 @@ describe('ConnectionUrl', () => {
3232
})
3333

3434
it('should disable test connection and submit buttons when connection url is invalid', async () => {
35-
render(<ConnectionUrl {...mockedProps} />)
35+
render(<AddDatabaseScreen {...mockedProps} />)
3636

3737
await act(async () => {
3838
fireEvent.change(
@@ -46,7 +46,7 @@ describe('ConnectionUrl', () => {
4646
})
4747

4848
it('should not disable buttons with proper connection url', async () => {
49-
render(<ConnectionUrl {...mockedProps} />)
49+
render(<AddDatabaseScreen {...mockedProps} />)
5050

5151
await act(async () => {
5252
fireEvent.change(
@@ -61,7 +61,7 @@ describe('ConnectionUrl', () => {
6161

6262
it('should call proper actions after click manual settings', async () => {
6363
const onSelectOptionMock = jest.fn()
64-
render(<ConnectionUrl {...mockedProps} onSelectOption={onSelectOptionMock} />)
64+
render(<AddDatabaseScreen {...mockedProps} onSelectOption={onSelectOptionMock} />)
6565

6666
await act(async () => {
6767
fireEvent.change(
@@ -90,7 +90,7 @@ describe('ConnectionUrl', () => {
9090

9191
it('should call proper actions after click connectivity option', async () => {
9292
const onSelectOptionMock = jest.fn()
93-
render(<ConnectionUrl {...mockedProps} onSelectOption={onSelectOptionMock} />)
93+
render(<AddDatabaseScreen {...mockedProps} onSelectOption={onSelectOptionMock} />)
9494

9595
await act(async () => {
9696
fireEvent.click(screen.getByTestId('option-btn-sentinel'))

redisinsight/ui/src/pages/home/components/connection-url/ConnectionUrl.tsx renamed to redisinsight/ui/src/pages/home/components/add-database-screen/AddDatabaseScreen.tsx

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import {
55
EuiFlexGroup,
66
EuiFlexItem,
77
EuiForm,
8-
EuiFormRow,
9-
EuiIcon,
108
EuiSpacer,
11-
EuiTextArea,
129
EuiToolTip
1310
} from '@elastic/eui'
1411
import { useFormik } from 'formik'
@@ -25,6 +22,7 @@ import {
2522
} from 'uiSrc/slices/instances/instances'
2623
import { Pages } from 'uiSrc/constants'
2724
import ConnectivityOptions from './components/connectivity-options'
25+
import ConnectionUrl from './components/connection-url'
2826

2927
import styles from './styles.module.scss'
3028

@@ -57,7 +55,7 @@ const ConnectionUrlError = (
5755
</>
5856
)
5957

60-
const ConnectionUrl = (props: Props) => {
58+
const AddDatabaseScreen = (props: Props) => {
6159
const { onSelectOption, onClose } = props
6260
const [isInvalid, setIsInvalid] = useState<Boolean>(false)
6361
const { loadingChanging: isLoading } = useSelector(instancesSelector)
@@ -100,46 +98,15 @@ const ConnectionUrl = (props: Props) => {
10098
})
10199

102100
return (
103-
<div>
101+
<div className="eui-yScroll">
104102
<EuiForm
105103
component="form"
106104
onSubmit={formik.handleSubmit}
107105
data-testid="form"
108106
>
109107
<EuiFlexGroup>
110108
<EuiFlexItem>
111-
<EuiFormRow label={(
112-
<div className={styles.connectionUrlInfo}>
113-
<div>Connection URL</div>
114-
<EuiToolTip
115-
title="The following connection URLs are supported:"
116-
className="homePage_tooltip"
117-
position="right"
118-
content={(
119-
<ul className="homePage_toolTipUl">
120-
<li><span className="dot" />redis://[[username]:[password]]@host:port</li>
121-
<li><span className="dot" />rediss://[[username]:[password]]@host:port</li>
122-
<li><span className="dot" />host:port</li>
123-
</ul>
124-
)}
125-
>
126-
<EuiIcon type="iInCircle" style={{ cursor: 'pointer' }} />
127-
</EuiToolTip>
128-
</div>
129-
)}
130-
>
131-
<EuiTextArea
132-
name="connectionURL"
133-
id="connectionURL"
134-
value={formik.values.connectionURL}
135-
onChange={formik.handleChange}
136-
fullWidth
137-
placeholder="redis://[email protected]:6379"
138-
resize="none"
139-
style={{ height: 88 }}
140-
data-testid="connection-url"
141-
/>
142-
</EuiFormRow>
109+
<ConnectionUrl value={formik.values.connectionURL} onChange={formik.handleChange} />
143110
</EuiFlexItem>
144111
</EuiFlexGroup>
145112

@@ -210,4 +177,4 @@ const ConnectionUrl = (props: Props) => {
210177
)
211178
}
212179

213-
export default ConnectionUrl
180+
export default AddDatabaseScreen
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react'
2+
import { render, screen, fireEvent } from 'uiSrc/utils/test-utils'
3+
4+
import ConnectionUrl from './ConnectionUrl'
5+
6+
describe('ConnectionUrl', () => {
7+
it('should render', () => {
8+
expect(render(<ConnectionUrl value="" onChange={() => {}} />)).toBeTruthy()
9+
})
10+
11+
it('should change connection url', () => {
12+
const onChangeMock = jest.fn()
13+
render(<ConnectionUrl value="val" onChange={onChangeMock} />)
14+
15+
expect(screen.getByTestId('connection-url')).toHaveValue('val')
16+
17+
fireEvent.change(screen.getByTestId('connection-url'), { target: { value: 'val1' } })
18+
19+
expect(onChangeMock).toBeCalled()
20+
})
21+
})
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from 'react'
2+
import { EuiFormRow, EuiIcon, EuiTextArea, EuiToolTip } from '@elastic/eui'
3+
4+
import styles from './styles.module.scss'
5+
6+
export interface Props {
7+
value: string
8+
onChange: (e: React.ChangeEvent<any>) => void
9+
}
10+
11+
const ConnectionUrl = ({ value, onChange }: Props) => (
12+
<EuiFormRow label={(
13+
<div className={styles.connectionUrlInfo}>
14+
<div>Connection URL</div>
15+
<EuiToolTip
16+
title="The following connection URLs are supported:"
17+
className="homePage_tooltip"
18+
position="right"
19+
content={(
20+
<ul className="homePage_toolTipUl">
21+
<li><span className="dot" />redis://[[username]:[password]]@host:port</li>
22+
<li><span className="dot" />rediss://[[username]:[password]]@host:port</li>
23+
<li><span className="dot" />host:port</li>
24+
</ul>
25+
)}
26+
>
27+
<EuiIcon type="iInCircle" style={{ cursor: 'pointer' }} />
28+
</EuiToolTip>
29+
</div>
30+
)}
31+
>
32+
<EuiTextArea
33+
name="connectionURL"
34+
id="connectionURL"
35+
value={value}
36+
onChange={onChange}
37+
fullWidth
38+
placeholder="redis://[email protected]:6379"
39+
resize="none"
40+
style={{ height: 88 }}
41+
data-testid="connection-url"
42+
/>
43+
</EuiFormRow>
44+
)
45+
46+
export default ConnectionUrl
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.connectionUrlInfo {
2+
display: flex;
3+
align-items: center;
4+
5+
> :global(.euiToolTipAnchor) {
6+
margin-left: 4px;
7+
}
8+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)