Skip to content

Commit 7495abe

Browse files
author
AnjaBruls
committed
fix bug clickaway
1 parent 99b2468 commit 7495abe

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/Components/App/Login/Edit.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import VisibilityOff from '@material-ui/icons/VisibilityOff';
1717
const Edit = ({credentials, form, security, onChange, editField}) => {
1818
const [show, setShow] = React.useState(false);
1919
const [loginWith, setLoginWith] = React.useState(credentials.isToken? 'token':'pass');
20+
const [clickAwayActive, setClickAwayActive] = React.useState(false);
2021

2122
const showAll = editField==='all';
2223
const showAddress = editField==='address';
@@ -38,13 +39,15 @@ const Edit = ({credentials, form, security, onChange, editField}) => {
3839

3940
const handleOnChangeAddress = ({target}) => {
4041
const {value} = target;
42+
setClickAwayActive(true);
4143
onChange('form', {address: value});
4244
};
4345

4446
const handleClickAwayCheck = () => {
4547
if(showAll){
48+
setClickAwayActive(false);
4649
const tls = form.address.startsWith('https://');
47-
onChange('security', {secureConnection: tls});
50+
onChange('security', {secureConnection: tls, insecureSkipVerify: false});
4851
}
4952
};
5053

@@ -63,8 +66,13 @@ const Edit = ({credentials, form, security, onChange, editField}) => {
6366
};
6467

6568
const handleSwitchSSL = ({target}) => {
66-
const {id, checked} = target;
67-
onChange('security', {[id]: checked});
69+
const {checked} = target;
70+
onChange('security', {secureConnection: checked, insecureSkipVerify: false});
71+
};
72+
73+
const handleSwitchISV = ({target}) => {
74+
const {checked} = target;
75+
onChange('security', {insecureSkipVerify: checked});
6876
};
6977

7078
return (
@@ -84,7 +92,7 @@ const Edit = ({credentials, form, security, onChange, editField}) => {
8492
/>
8593
</Collapse>
8694
<Collapse in={showAll||showAddress} timeout="auto" unmountOnExit>
87-
<ClickAwayListener onClickAway={handleClickAwayCheck}>
95+
<ClickAwayListener onClickAway={handleClickAwayCheck} touchEvent={clickAwayActive && 'onTouchEnd'} mouseEvent={clickAwayActive && 'onClick'}>
8896
<TextField
8997
autoFocus
9098
margin="dense"
@@ -187,7 +195,7 @@ const Edit = ({credentials, form, security, onChange, editField}) => {
187195
checked={security.insecureSkipVerify}
188196
color="primary"
189197
id="insecureSkipVerify"
190-
onChange={handleSwitchSSL}
198+
onChange={handleSwitchISV}
191199
/>
192200
)}
193201
label="Allow insecure certificates"

things-gui.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@ func open(url string) error { //https://stackoverflow.com/questions/39320371/how
206206

207207
// newEditConnection saves a new connection or edits locally
208208
func (app *App) getEnvVariables() error {
209-
err := godotenv.Load(app.envPath)
210-
if err != nil {
211-
fmt.Println(err)
212-
}
209+
godotenv.Load(app.envPath)
213210
thingsguiAddress = os.Getenv("THINGSGUI_ADDRESS")
214211
thingsguiAuthMethod = os.Getenv("THINGSGUI_AUTH_METHOD")
215212
if os.Getenv("THINGSGUI_SSL") == "true" {

0 commit comments

Comments
 (0)