-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Chi Kei Chan <chikeichan@gmail.com>
- Loading branch information
1 parent
f8c2cbd
commit d6a0347
Showing
7 changed files
with
160 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { Component } from "react"; | ||
import PropTypes from "prop-types"; | ||
import { withRouter } from "react-router-dom"; | ||
import { connect } from "react-redux"; | ||
import MiniModal from "../../components/Modal/MiniModal"; | ||
import { setMaxIdle } from "../../ducks/walletActions"; | ||
import "./max-idle-modal.scss"; | ||
|
||
@withRouter | ||
@connect( | ||
(state) => ({ | ||
maxIdle: state.wallet.maxIdle, | ||
}), | ||
(dispatch) => ({ | ||
setMaxIdle: (maxIdle) => dispatch(setMaxIdle(maxIdle)), | ||
}) | ||
) | ||
export default class MaxIdleModal extends Component { | ||
static propTypes = { | ||
maxIdle: PropTypes.number.isRequired, | ||
setMaxIdle: PropTypes.func.isRequired, | ||
history: PropTypes.shape({ | ||
push: PropTypes.func.isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
maxIdle: props.maxIdle, | ||
}; | ||
} | ||
|
||
onUpdateMaxIdle = async () => { | ||
try { | ||
await this.props.setMaxIdle(this.state.maxIdle); | ||
this.props.history.push("/settings"); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}; | ||
|
||
render() { | ||
return ( | ||
<MiniModal title="Change idle timeout" closeRoute="/settings" centered> | ||
<div className="max-idle-modal__instructions"> | ||
Enter the time of inactivity after which the wallet should | ||
automatically lock (0 to disable auto-lock). | ||
</div> | ||
<div className="max-idle-modal__input"> | ||
<input | ||
type="number" | ||
value={this.state.maxIdle} | ||
onChange={(e) => this.setState({ maxIdle: e.target.value >>> 0 })} | ||
placeholder="5" | ||
min="0" | ||
autoFocus | ||
/>{" "} | ||
minutes | ||
</div> | ||
<button | ||
className="max-idle-modal__submit" | ||
onClick={this.onUpdateMaxIdle} | ||
> | ||
Change timeout | ||
</button> | ||
</MiniModal> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@import "../../variables"; | ||
|
||
.max-idle-modal { | ||
&__instructions { | ||
margin-bottom: 27px; | ||
} | ||
|
||
&__input { | ||
font-size: 20px; | ||
font-weight: 500; | ||
margin-bottom: 27px; | ||
|
||
input { | ||
padding: 8px; | ||
border-radius: 3px; | ||
border: 1px solid $grey; | ||
margin-left: 3px; | ||
font-size: 16px; | ||
width: 40px; | ||
text-align: center; | ||
} | ||
} | ||
|
||
&__submit { | ||
@extend %btn-primary; | ||
} | ||
} |