summaryrefslogtreecommitdiffstats
path: root/web/react/components/user_settings
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/components/user_settings')
-rw-r--r--web/react/components/user_settings/user_settings_modal.jsx21
-rw-r--r--web/react/components/user_settings/user_settings_security.jsx48
2 files changed, 25 insertions, 44 deletions
diff --git a/web/react/components/user_settings/user_settings_modal.jsx b/web/react/components/user_settings/user_settings_modal.jsx
index 4dcf32cb9..776201295 100644
--- a/web/react/components/user_settings/user_settings_modal.jsx
+++ b/web/react/components/user_settings/user_settings_modal.jsx
@@ -10,6 +10,7 @@ export default class UserSettingsModal extends React.Component {
constructor(props) {
super(props);
+ this.handleShow = this.handleShow.bind(this);
this.handleHide = this.handleHide.bind(this);
this.handleHidden = this.handleHidden.bind(this);
this.handleCollapse = this.handleCollapse.bind(this);
@@ -33,12 +34,22 @@ export default class UserSettingsModal extends React.Component {
this.requireConfirm = false;
}
+ componentDidMount() {
+ if (this.props.show) {
+ this.handleShow();
+ }
+ }
+
componentDidUpdate(prevProps) {
- if (!prevProps.show && this.props.show) {
- $(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 300);
- if ($(window).width() > 768) {
- $(ReactDOM.findDOMNode(this.refs.modalBody)).perfectScrollbar();
- }
+ if (this.props.show && !prevProps.show) {
+ this.handleShow();
+ }
+ }
+
+ handleShow() {
+ $(ReactDOM.findDOMNode(this.refs.modalBody)).css('max-height', $(window).height() - 300);
+ if ($(window).width() > 768) {
+ $(ReactDOM.findDOMNode(this.refs.modalBody)).perfectScrollbar();
}
}
diff --git a/web/react/components/user_settings/user_settings_security.jsx b/web/react/components/user_settings/user_settings_security.jsx
index 61d13ed8b..16ace0abc 100644
--- a/web/react/components/user_settings/user_settings_security.jsx
+++ b/web/react/components/user_settings/user_settings_security.jsx
@@ -5,6 +5,7 @@ var SettingItemMin = require('../setting_item_min.jsx');
var SettingItemMax = require('../setting_item_max.jsx');
var AccessHistoryModal = require('../access_history_modal.jsx');
var ActivityLogModal = require('../activity_log_modal.jsx');
+var ToggleModalButton = require('../toggle_modal_button.jsx');
var Client = require('../../utils/client.jsx');
var AsyncClient = require('../../utils/async_client.jsx');
var Constants = require('../../utils/constants.jsx');
@@ -13,34 +14,13 @@ export default class SecurityTab extends React.Component {
constructor(props) {
super(props);
- this.showAccessHistoryModal = this.showAccessHistoryModal.bind(this);
- this.showActivityLogModal = this.showActivityLogModal.bind(this);
- this.hideModals = this.hideModals.bind(this);
this.submitPassword = this.submitPassword.bind(this);
this.updateCurrentPassword = this.updateCurrentPassword.bind(this);
this.updateNewPassword = this.updateNewPassword.bind(this);
this.updateConfirmPassword = this.updateConfirmPassword.bind(this);
this.setupInitialState = this.setupInitialState.bind(this);
- const state = this.setupInitialState();
- state.showAccessHistoryModal = false;
- state.showActivityLogModal = false;
- this.state = state;
- }
- showAccessHistoryModal() {
- this.props.setEnforceFocus(false);
- this.setState({showAccessHistoryModal: true});
- }
- showActivityLogModal() {
- this.props.setEnforceFocus(false);
- this.setState({showActivityLogModal: true});
- }
- hideModals() {
- this.props.setEnforceFocus(true);
- this.setState({
- showAccessHistoryModal: false,
- showActivityLogModal: false
- });
+ this.state = this.setupInitialState();
}
submitPassword(e) {
e.preventDefault();
@@ -258,30 +238,20 @@ export default class SecurityTab extends React.Component {
{passwordSection}
<div className='divider-dark'/>
<br></br>
- <a
+ <ToggleModalButton
className='security-links theme'
- href='#'
- onClick={this.showAccessHistoryModal}
+ dialogType={AccessHistoryModal}
>
<i className='fa fa-clock-o'></i>View Access History
- </a>
+ </ToggleModalButton>
<b> </b>
- <a
+ <ToggleModalButton
className='security-links theme'
- href='#'
- onClick={this.showActivityLogModal}
+ dialogType={ActivityLogModal}
>
- <i className='fa fa-globe'></i>View and Logout of Active Sessions
- </a>
+ <i className='fa fa-clock-o'></i>{'View and Logout of Active Sessions'}
+ </ToggleModalButton>
</div>
- <AccessHistoryModal
- show={this.state.showAccessHistoryModal}
- onModalDismissed={this.hideModals}
- />
- <ActivityLogModal
- show={this.state.showActivityLogModal}
- onModalDismissed={this.hideModals}
- />
</div>
);
}