From 1675adcc7a30cec836c00d35b0624aa35d373eed Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Fri, 30 Oct 2015 10:45:54 -0400
Subject: Ported AccessHistoryModal and ActivityLogModal to React-Bootstrap

---
 .../user_settings/user_settings_security.jsx       | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)

(limited to 'web/react/components/user_settings/user_settings_security.jsx')

diff --git a/web/react/components/user_settings/user_settings_security.jsx b/web/react/components/user_settings/user_settings_security.jsx
index 983a10df0..4d414008e 100644
--- a/web/react/components/user_settings/user_settings_security.jsx
+++ b/web/react/components/user_settings/user_settings_security.jsx
@@ -3,6 +3,8 @@
 
 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 Client = require('../../utils/client.jsx');
 var AsyncClient = require('../../utils/async_client.jsx');
 var Constants = require('../../utils/constants.jsx');
@@ -18,7 +20,10 @@ export default class SecurityTab extends React.Component {
         this.handleClose = this.handleClose.bind(this);
         this.setupInitialState = this.setupInitialState.bind(this);
 
-        this.state = this.setupInitialState();
+        const state = this.setupInitialState();
+        state.showAccessHistoryModal = false;
+        state.showActivityLogModal = false;
+        this.state = state;
     }
     submitPassword(e) {
         e.preventDefault();
@@ -75,12 +80,6 @@ export default class SecurityTab extends React.Component {
     updateConfirmPassword(e) {
         this.setState({confirmPassword: e.target.value});
     }
-    handleHistoryOpen() {
-        $('#user_settings').modal('hide');
-    }
-    handleDevicesOpen() {
-        $('#user_settings').modal('hide');
-    }
     handleClose() {
         $(ReactDOM.findDOMNode(this)).find('.form-control').each(function resetValue() {
             this.value = '';
@@ -253,25 +252,29 @@ export default class SecurityTab extends React.Component {
                     <div className='divider-dark'/>
                     <br></br>
                     <a
-                        data-toggle='modal'
                         className='security-links theme'
-                        data-target='#access-history'
                         href='#'
-                        onClick={this.handleHistoryOpen}
+                        onClick={() => this.setState({showAccessHistoryModal: true})}
                     >
                         <i className='fa fa-clock-o'></i>View Access History
                     </a>
                     <b> </b>
                     <a
-                        data-toggle='modal'
                         className='security-links theme'
-                        data-target='#activity-log'
                         href='#'
-                        onClick={this.handleDevicesOpen}
+                        onClick={() => this.setState({showActivityLogModal: true})}
                     >
                         <i className='fa fa-globe'></i>View and Logout of Active Sessions
                     </a>
                 </div>
+                <AccessHistoryModal
+                    show={this.state.showAccessHistoryModal}
+                    onModalDismissed={() => this.setState({showAccessHistoryModal: false})}
+                />
+                <ActivityLogModal
+                    show={this.state.showActivityLogModal}
+                    onModalDismissed={() => this.setState({showActivityLogModal: false})}
+                />
             </div>
         );
     }
-- 
cgit v1.2.3-1-g7c22


From e56d21a9208209d515b645f95d293eae51f51f8d Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Fri, 30 Oct 2015 16:33:51 -0400
Subject: Added a confirmation dialog for unsaved theme changes and removed
 unnecessary dialog close handling

---
 .../components/user_settings/user_settings_security.jsx  | 16 ----------------
 1 file changed, 16 deletions(-)

(limited to 'web/react/components/user_settings/user_settings_security.jsx')

diff --git a/web/react/components/user_settings/user_settings_security.jsx b/web/react/components/user_settings/user_settings_security.jsx
index 4d414008e..d4d6bf035 100644
--- a/web/react/components/user_settings/user_settings_security.jsx
+++ b/web/react/components/user_settings/user_settings_security.jsx
@@ -17,7 +17,6 @@ export default class SecurityTab extends React.Component {
         this.updateCurrentPassword = this.updateCurrentPassword.bind(this);
         this.updateNewPassword = this.updateNewPassword.bind(this);
         this.updateConfirmPassword = this.updateConfirmPassword.bind(this);
-        this.handleClose = this.handleClose.bind(this);
         this.setupInitialState = this.setupInitialState.bind(this);
 
         const state = this.setupInitialState();
@@ -80,24 +79,9 @@ export default class SecurityTab extends React.Component {
     updateConfirmPassword(e) {
         this.setState({confirmPassword: e.target.value});
     }
-    handleClose() {
-        $(ReactDOM.findDOMNode(this)).find('.form-control').each(function resetValue() {
-            this.value = '';
-        });
-        this.setState({currentPassword: '', newPassword: '', confirmPassword: '', serverError: null, passwordError: null});
-
-        this.props.updateTab('general');
-    }
     setupInitialState() {
         return {currentPassword: '', newPassword: '', confirmPassword: ''};
     }
-    componentDidMount() {
-        $('#user_settings').on('hidden.bs.modal', this.handleClose);
-    }
-    componentWillUnmount() {
-        $('#user_settings').off('hidden.bs.modal', this.handleClose);
-        this.props.updateSection('');
-    }
     render() {
         var serverError;
         if (this.state.serverError) {
-- 
cgit v1.2.3-1-g7c22


From 02b9414e0f0169c99044ad96456290766ffcd585 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Fri, 30 Oct 2015 17:26:39 -0400
Subject: Added handling of keyboard focus to UserSettingsModal and its
 children

---
 .../user_settings/user_settings_security.jsx       | 29 ++++++++++++++++++----
 1 file changed, 24 insertions(+), 5 deletions(-)

(limited to 'web/react/components/user_settings/user_settings_security.jsx')

diff --git a/web/react/components/user_settings/user_settings_security.jsx b/web/react/components/user_settings/user_settings_security.jsx
index d4d6bf035..c2b8a0093 100644
--- a/web/react/components/user_settings/user_settings_security.jsx
+++ b/web/react/components/user_settings/user_settings_security.jsx
@@ -13,6 +13,9 @@ 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);
@@ -24,6 +27,21 @@ export default class SecurityTab extends React.Component {
         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
+        });
+    }
     submitPassword(e) {
         e.preventDefault();
 
@@ -238,7 +256,7 @@ export default class SecurityTab extends React.Component {
                     <a
                         className='security-links theme'
                         href='#'
-                        onClick={() => this.setState({showAccessHistoryModal: true})}
+                        onClick={this.showAccessHistoryModal}
                     >
                         <i className='fa fa-clock-o'></i>View Access History
                     </a>
@@ -246,18 +264,18 @@ export default class SecurityTab extends React.Component {
                     <a
                         className='security-links theme'
                         href='#'
-                        onClick={() => this.setState({showActivityLogModal: true})}
+                        onClick={this.showActivityLogModal}
                     >
                         <i className='fa fa-globe'></i>View and Logout of Active Sessions
                     </a>
                 </div>
                 <AccessHistoryModal
                     show={this.state.showAccessHistoryModal}
-                    onModalDismissed={() => this.setState({showAccessHistoryModal: false})}
+                    onModalDismissed={this.hideModals}
                 />
                 <ActivityLogModal
                     show={this.state.showActivityLogModal}
-                    onModalDismissed={() => this.setState({showActivityLogModal: false})}
+                    onModalDismissed={this.hideModals}
                 />
             </div>
         );
@@ -272,5 +290,6 @@ SecurityTab.propTypes = {
     user: React.PropTypes.object,
     activeSection: React.PropTypes.string,
     updateSection: React.PropTypes.func,
-    updateTab: React.PropTypes.func
+    updateTab: React.PropTypes.func,
+    setEnforceFocus: React.PropTypes.func.isRequired
 };
-- 
cgit v1.2.3-1-g7c22


From a7ceba2e57f5b693afa51b0aefd04081646c6948 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Tue, 3 Nov 2015 14:09:09 -0500
Subject: Fixed theme confirmation dialog to work in all cases and removed some
 jquery magic related to it

---
 web/react/components/user_settings/user_settings_security.jsx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'web/react/components/user_settings/user_settings_security.jsx')

diff --git a/web/react/components/user_settings/user_settings_security.jsx b/web/react/components/user_settings/user_settings_security.jsx
index c2b8a0093..61d13ed8b 100644
--- a/web/react/components/user_settings/user_settings_security.jsx
+++ b/web/react/components/user_settings/user_settings_security.jsx
@@ -237,14 +237,19 @@ export default class SecurityTab extends React.Component {
                         className='close'
                         data-dismiss='modal'
                         aria-label='Close'
+                        onClick={this.props.closeModal}
                     >
-                        <span aria-hidden='true'>&times;</span>
+                        <span aria-hidden='true'>{'×'}</span>
                     </button>
                     <h4
                         className='modal-title'
                         ref='title'
                     >
-                        <i className='modal-back'></i>Security Settings
+                        <i
+                            className='modal-back'
+                            onClick={this.props.collapseModal}
+                        />
+                        {'Security Settings'}
                     </h4>
                 </div>
                 <div className='user-settings'>
@@ -291,5 +296,7 @@ SecurityTab.propTypes = {
     activeSection: React.PropTypes.string,
     updateSection: React.PropTypes.func,
     updateTab: React.PropTypes.func,
+    closeModal: React.PropTypes.func.isRequired,
+    collapseModal: React.PropTypes.func.isRequired,
     setEnforceFocus: React.PropTypes.func.isRequired
 };
-- 
cgit v1.2.3-1-g7c22

