Skip to content

Commit c2df435

Browse files
authored
RI-7051: Replace EuiFieldPassword with PasswordInput (#4552)
* RI-7051: add PasswordInput component * RI-7051: replace EuiFieldPassword with PasswordInput * RI-7051: remove euiFieldPassword styles * RI-7051: adjust info icon in rdi form * RI-7051: change PasswordInput import path * remove leftover * RI-7051: move PasswordInput a folder level up * RI-7051: PasswordInput leftover
1 parent c9aeaf9 commit c2df435

File tree

16 files changed

+38
-291
lines changed

16 files changed

+38
-291
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React, { ComponentProps } from 'react'
2+
3+
import { PasswordInput as RedisPasswordInput } from '@redis-ui/components'
4+
5+
export type RedisPasswordInputProps = ComponentProps<typeof RedisPasswordInput>
6+
7+
export default function PasswordInput(props: RedisPasswordInputProps) {
8+
return <RedisPasswordInput {...props} />
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as PasswordInput } from './PasswordInput'

redisinsight/ui/src/components/form-dialog/styles.module.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
.euiFieldText,
5454
.euiFieldNumber,
55-
.euiFieldPassword,
5655
.euiFieldSearch,
5756
.euiSelect,
5857
.euiSuperSelectControl,
@@ -81,8 +80,7 @@
8180
.euiSuperSelectControl:not(.euiSuperSelectControl--compressed),
8281
.euiSelect:not(.euiSelect--compressed),
8382
.euiFieldText:not(.euiFieldText--compressed),
84-
.euiFieldNumber:not(.euiFieldNumber--compressed),
85-
.euiFieldPassword {
83+
.euiFieldNumber:not(.euiFieldNumber--compressed) {
8684
height: 40px !important;
8785
}
8886
}

redisinsight/ui/src/components/input-field-sentinel/InputFieldSentinel.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
EuiFieldText,
3-
EuiFieldPassword,
43
EuiIcon,
54
EuiFieldNumber,
65
} from '@elastic/eui'
@@ -9,6 +8,7 @@ import React, { useState } from 'react'
98
import cx from 'classnames'
109
import { useDebouncedEffect } from 'uiSrc/services'
1110
import { validateNumber } from 'uiSrc/utils'
11+
import { PasswordInput } from 'uiSrc/components/base/inputs'
1212

1313
import styles from './styles.module.scss'
1414

@@ -68,11 +68,10 @@ const InputFieldSentinel = (props: Props) => {
6868
/>
6969
)}
7070
{inputType === SentinelInputFieldType.Password && (
71-
<EuiFieldPassword
71+
<PasswordInput
7272
{...clearProp}
73-
compressed
7473
value={value}
75-
onChange={(e) => handleChange(e.target?.value)}
74+
onChange={(value) => handleChange(value)}
7675
data-testid="sentinel-input-password"
7776
/>
7877
)}

redisinsight/ui/src/pages/home/components/cluster-connection/cluster-connection-form/ClusterConnectionForm.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { isEmpty } from 'lodash'
44
import { FormikErrors, useFormik } from 'formik'
55
import {
66
EuiFieldNumber,
7-
EuiFieldPassword,
87
EuiFieldText,
98
EuiForm,
109
EuiFormRow,
@@ -30,6 +29,7 @@ import {
3029
SecondaryButton,
3130
} from 'uiSrc/components/base/forms/buttons'
3231
import { InfoIcon } from 'uiSrc/components/base/icons'
32+
import { PasswordInput } from 'uiSrc/components/base/inputs'
3333

3434
export interface Props {
3535
host: string
@@ -300,18 +300,15 @@ const ClusterConnectionForm = (props: Props) => {
300300

301301
<FlexItem grow>
302302
<EuiFormRow label="Admin Password*">
303-
<EuiFieldPassword
303+
<PasswordInput
304304
type="dual"
305305
name="password"
306306
id="password"
307307
data-testid="password"
308-
fullWidth
309-
className="passwordField"
310308
maxLength={200}
311309
placeholder="Enter Password"
312310
value={formik.values.password}
313311
onChange={formik.handleChange}
314-
dualToggleProps={{ color: 'text' }}
315312
autoComplete="new-password"
316313
/>
317314
</EuiFormRow>

redisinsight/ui/src/pages/home/components/form/DatabaseForm.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { FormikProps } from 'formik'
44

55
import {
66
EuiFieldNumber,
7-
EuiFieldPassword,
87
EuiFieldText,
98
EuiFormRow,
109
EuiIcon,
@@ -24,6 +23,7 @@ import {
2423
} from 'uiSrc/utils'
2524
import { DbConnectionInfo } from 'uiSrc/pages/home/interfaces'
2625
import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
26+
import { PasswordInput } from 'uiSrc/components/base/inputs'
2727

2828
interface IShowFields {
2929
alias: boolean
@@ -192,27 +192,23 @@ const DatabaseForm = (props: Props) => {
192192

193193
<FlexItem grow>
194194
<EuiFormRow label="Password">
195-
<EuiFieldPassword
196-
type="password"
195+
<PasswordInput
197196
name="password"
198197
id="password"
199198
data-testid="password"
200-
fullWidth
201-
className="passwordField"
202199
maxLength={10_000}
203200
placeholder="Enter Password"
204201
value={
205202
formik.values.password === true
206203
? SECURITY_FIELD
207204
: (formik.values.password ?? '')
208205
}
209-
onChange={formik.handleChange}
206+
onChangeCapture={formik.handleChange}
210207
onFocus={() => {
211208
if (formik.values.password === true) {
212209
formik.setFieldValue('password', '')
213210
}
214211
}}
215-
dualToggleProps={{ color: 'text' }}
216212
autoComplete="new-password"
217213
disabled={isFieldDisabled('password')}
218214
/>

redisinsight/ui/src/pages/home/components/form/SSHDetails.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { ChangeEvent } from 'react'
22
import {
33
EuiCheckbox,
44
EuiFieldNumber,
5-
EuiFieldPassword,
65
EuiFieldText,
76
EuiFormRow,
87
EuiRadioGroup,
@@ -26,6 +25,7 @@ import { DbConnectionInfo } from 'uiSrc/pages/home/interfaces'
2625

2726
import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
2827
import { Spacer } from 'uiSrc/components/base/layout/spacer'
28+
import { PasswordInput } from 'uiSrc/components/base/inputs'
2929
import styles from '../styles.module.scss'
3030

3131
export interface Props {
@@ -164,21 +164,18 @@ const SSHDetails = (props: Props) => {
164164
<Row gap="m" responsive className={flexGroupClassName}>
165165
<FlexItem grow className={flexItemClassName}>
166166
<EuiFormRow label="Password">
167-
<EuiFieldPassword
168-
type="password"
167+
<PasswordInput
169168
name="sshPassword"
170169
id="sshPassword"
171170
data-testid="sshPassword"
172-
fullWidth
173-
className="passwordField"
174171
maxLength={10_000}
175172
placeholder="Enter SSH Password"
176173
value={
177174
formik.values.sshPassword === true
178175
? SECURITY_FIELD
179176
: (formik.values.sshPassword ?? '')
180177
}
181-
onChange={formik.handleChange}
178+
onChangeCapture={formik.handleChange}
182179
onFocus={() => {
183180
if (formik.values.sshPassword === true) {
184181
formik.setFieldValue('sshPassword', '')
@@ -201,7 +198,6 @@ const SSHDetails = (props: Props) => {
201198
id="sshPrivateKey"
202199
data-testid="sshPrivateKey"
203200
fullWidth
204-
className="passwordField"
205201
maxLength={50_000}
206202
placeholder="Enter SSH Private Key in PEM format"
207203
value={
@@ -225,21 +221,18 @@ const SSHDetails = (props: Props) => {
225221
<Row gap="m" responsive className={flexGroupClassName}>
226222
<FlexItem grow className={flexItemClassName}>
227223
<EuiFormRow label="Passphrase">
228-
<EuiFieldPassword
229-
type="password"
224+
<PasswordInput
230225
name="sshPassphrase"
231226
id="sshPassphrase"
232227
data-testid="sshPassphrase"
233-
fullWidth
234-
className="passwordField"
235228
maxLength={50_000}
236229
placeholder="Enter Passphrase for Private Key"
237230
value={
238231
formik.values.sshPassphrase === true
239232
? SECURITY_FIELD
240233
: (formik.values.sshPassphrase ?? '')
241234
}
242-
onChange={formik.handleChange}
235+
onChangeCapture={formik.handleChange}
243236
onFocus={() => {
244237
if (formik.values.sshPassphrase === true) {
245238
formik.setFieldValue('sshPassphrase', '')

redisinsight/ui/src/pages/home/components/form/sentinel/SentinelMasterDatabase.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
22
import {
3-
EuiFieldPassword,
43
EuiFieldText,
54
EuiFormRow,
65
EuiText,
@@ -11,6 +10,7 @@ import { FormikProps } from 'formik'
1110
import { Nullable } from 'uiSrc/utils'
1211
import { SECURITY_FIELD } from 'uiSrc/constants'
1312
import { DbConnectionInfo } from 'uiSrc/pages/home/interfaces'
13+
import { PasswordInput } from 'uiSrc/components/base/inputs'
1414

1515
import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
1616
import styles from '../../styles.module.scss'
@@ -59,27 +59,24 @@ const SentinelMasterDatabase = (props: Props) => {
5959

6060
<FlexItem grow className={flexItemClassName}>
6161
<EuiFormRow label="Password">
62-
<EuiFieldPassword
62+
<PasswordInput
6363
type="password"
6464
name="sentinelMasterPassword"
6565
id="sentinelMasterPassword"
6666
data-testid="sentinel-master-password"
67-
fullWidth
68-
className="passwordField"
6967
maxLength={200}
7068
placeholder="Enter Password"
7169
value={
7270
formik.values.sentinelMasterPassword === true
7371
? SECURITY_FIELD
7472
: (formik.values.sentinelMasterPassword ?? '')
7573
}
76-
onChange={formik.handleChange}
74+
onChangeCapture={formik.handleChange}
7775
onFocus={() => {
7876
if (formik.values.sentinelMasterPassword === true) {
7977
formik.setFieldValue('sentinelMasterPassword', '')
8078
}
8179
}}
82-
dualToggleProps={{ color: 'text' }}
8380
autoComplete="new-password"
8481
/>
8582
</EuiFormRow>

redisinsight/ui/src/pages/rdi/home/connection-form/ConnectionForm.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
EuiFieldPassword,
32
EuiFieldText,
43
EuiForm,
54
EuiFormRow,
@@ -33,6 +32,7 @@ import {
3332
SecondaryButton,
3433
} from 'uiSrc/components/base/forms/buttons'
3534
import { InfoIcon } from 'uiSrc/components/base/icons'
35+
import { PasswordInput } from 'uiSrc/components/base/inputs'
3636
import ValidationTooltip from './components/ValidationTooltip'
3737

3838
import styles from './styles.module.scss'
@@ -231,7 +231,14 @@ const ConnectionForm = (props: Props) => {
231231
</EuiFormRow>
232232
</FlexItem>
233233
<FlexItem grow={1}>
234-
<EuiFormRow label="Password">
234+
<EuiFormRow
235+
label={
236+
<>
237+
Password
238+
<AppendInfo content="The RDI REST API authentication is using the RDI Redis username and password." />
239+
</>
240+
}
241+
>
235242
<Field name="password">
236243
{({
237244
field,
@@ -242,13 +249,12 @@ const ConnectionForm = (props: Props) => {
242249
form: FormikHelpers<string>
243250
meta: FieldMetaProps<string>
244251
}) => (
245-
<EuiFieldPassword
252+
<PasswordInput
246253
data-testid="connection-form-password-input"
247-
className={styles.passwordField}
248-
fullWidth
249254
placeholder="Enter the RDI Redis password"
250255
maxLength={500}
251256
{...field}
257+
onChangeCapture={field.onChange}
252258
value={
253259
isNull(field.value) ? SECURITY_FIELD : field.value
254260
}
@@ -257,9 +263,6 @@ const ConnectionForm = (props: Props) => {
257263
form.setFieldValue('password', '')
258264
}
259265
}}
260-
append={
261-
<AppendInfo content="The RDI REST API authentication is using the RDI Redis username and password." />
262-
}
263266
/>
264267
)}
265268
</Field>

redisinsight/ui/src/pages/rdi/home/connection-form/styles.module.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
margin: 0 !important;
1414
}
1515

16-
.passwordField {
17-
padding-left: 12px !important;
18-
}
19-
2016
.testConnectionBtn {
2117
border-color: transparent !important;
2218
}

0 commit comments

Comments
 (0)