Skip to content

Commit 72efc32

Browse files
committed
#RI-6451 - update add database form
1 parent 5502c95 commit 72efc32

23 files changed

+528
-255
lines changed

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: 4 additions & 37 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)
@@ -108,38 +106,7 @@ const ConnectionUrl = (props: Props) => {
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: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 = (props: Props) => {
12+
const { value, onChange } = props
13+
14+
return (
15+
<EuiFormRow label={(
16+
<div className={styles.connectionUrlInfo}>
17+
<div>Connection URL</div>
18+
<EuiToolTip
19+
title="The following connection URLs are supported:"
20+
className="homePage_tooltip"
21+
position="right"
22+
content={(
23+
<ul className="homePage_toolTipUl">
24+
<li><span className="dot" />redis://[[username]:[password]]@host:port</li>
25+
<li><span className="dot" />rediss://[[username]:[password]]@host:port</li>
26+
<li><span className="dot" />host:port</li>
27+
</ul>
28+
)}
29+
>
30+
<EuiIcon type="iInCircle" style={{ cursor: 'pointer' }} />
31+
</EuiToolTip>
32+
</div>
33+
)}
34+
>
35+
<EuiTextArea
36+
name="connectionURL"
37+
id="connectionURL"
38+
value={value}
39+
onChange={onChange}
40+
fullWidth
41+
placeholder="redis://[email protected]:6379"
42+
resize="none"
43+
style={{ height: 88 }}
44+
data-testid="connection-url"
45+
/>
46+
</EuiFormRow>
47+
)
48+
}
49+
50+
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.
File renamed without changes.

0 commit comments

Comments
 (0)