File tree Expand file tree Collapse file tree 3 files changed +46
-5
lines changed
screens/HomeScreen/ConnectionConfigEditor Expand file tree Collapse file tree 3 files changed +46
-5
lines changed Original file line number Diff line number Diff line change 1+ import { faEye , faEyeSlash } from '@fortawesome/free-solid-svg-icons' ;
2+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
3+ import { useState } from 'react' ;
4+ import TextField , { TextFieldCommonProps } from 'renderer/components/TextField' ;
5+
6+ export default function PasswordField ( {
7+ label,
8+ value,
9+ autoFocus,
10+ onChange,
11+ placeholder,
12+ readOnly,
13+ } : TextFieldCommonProps ) {
14+ const props = {
15+ label,
16+ value,
17+ autoFocus,
18+ onChange,
19+ placeholder,
20+ readOnly,
21+ } ;
22+ const [ showPassword , setShowPassword ] = useState ( false ) ;
23+
24+ return (
25+ < TextField
26+ type = { showPassword ? 'text' : 'password' }
27+ actionClick = { ( ) => setShowPassword ( ! showPassword ) }
28+ actionIcon = {
29+ showPassword ? (
30+ < FontAwesomeIcon icon = { faEye } />
31+ ) : (
32+ < FontAwesomeIcon icon = { faEyeSlash } />
33+ )
34+ }
35+ { ...props }
36+ />
37+ ) ;
38+ }
Original file line number Diff line number Diff line change 11import { ReactElement } from 'react' ;
22import styles from './styles.module.scss' ;
33
4- interface TextFieldProps {
4+ export interface TextFieldCommonProps {
5+ readOnly ?: boolean ;
6+ onChange ?: ( value : string ) => void ;
57 label ?: string ;
68 value ?: string ;
79 autoFocus ?: boolean ;
810 placeholder ?: string ;
11+ }
12+
13+ interface TextFieldProps extends TextFieldCommonProps {
914 multipleLine ?: boolean ;
1015 type ?: 'text' | 'password' ;
11- onChange ?: ( value : string ) => void ;
1216 actionIcon ?: ReactElement ;
1317 actionClick ?: ( ) => void ;
14- readOnly ?: boolean ;
1518}
1619
1720export default function TextField ( {
Original file line number Diff line number Diff line change 44} from 'drivers/SQLLikeConnection' ;
55import Stack from 'renderer/components/Stack' ;
66import TextField from 'renderer/components/TextField' ;
7+ import PasswordField from 'renderer/components/PasswordField' ;
78
89export default function MySQLConnectionEditor ( {
910 config,
@@ -31,8 +32,7 @@ export default function MySQLConnectionEditor({
3132 value = { config ?. user }
3233 onChange = { ( value ) => onChange ( { ...config , user : value } ) }
3334 />
34- < TextField
35- type = "password"
35+ < PasswordField
3636 label = "Password"
3737 value = { config ?. password }
3838 onChange = { ( value ) => onChange ( { ...config , password : value } ) }
You can’t perform that action at this time.
0 commit comments