From 0b2490c689d23ebe0c1d4d86cb1c203e2d9ab8c7 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Mon, 31 Aug 2015 11:39:00 -0400
Subject: Reformatted access_history_modal.jsx to meet style guide
 requirements.

---
 web/react/components/access_history_modal.jsx | 99 ++++++++++++++++++---------
 1 file changed, 66 insertions(+), 33 deletions(-)

(limited to 'web/react/components/access_history_modal.jsx')

diff --git a/web/react/components/access_history_modal.jsx b/web/react/components/access_history_modal.jsx
index a19e5c16e..217b96d0b 100644
--- a/web/react/components/access_history_modal.jsx
+++ b/web/react/components/access_history_modal.jsx
@@ -6,46 +6,48 @@ var AsyncClient = require('../utils/async_client.jsx');
 var LoadingScreen = require('./loading_screen.jsx');
 var utils = require('../utils/utils.jsx');
 
-function getStateFromStoresForAudits() {
-    return {
-        audits: UserStore.getAudits()
-    };
-}
+export default class AccessHistoryModal extends React.Component {
+    constructor(props) {
+        super(props);
+
+        this.onAuditChange = this.onAuditChange.bind(this);
+        this.handleMoreInfo = this.handleMoreInfo.bind(this);
 
-module.exports = React.createClass({
-    displayName: 'AccessHistoryModal',
-    componentDidMount: function() {
-        UserStore.addAuditsChangeListener(this.onListenerChange);
-        $(this.refs.modal.getDOMNode()).on('shown.bs.modal', function() {
+        this.state = this.getStateFromStoresForAudits();
+        this.state.moreInfo = [];
+    }
+    getStateFromStoresForAudits() {
+        return {
+            audits: UserStore.getAudits()
+        };
+    }
+    componentDidMount() {
+        UserStore.addAuditsChangeListener(this.onAuditChange);
+        $(this.refs.modal.getDOMNode()).on('shown.bs.modal', function show() {
             AsyncClient.getAudits();
         });
 
         var self = this;
-        $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function() {
+        $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function hide() {
             $('#user_settings').modal('show');
             self.setState({moreInfo: []});
         });
-    },
-    componentWillUnmount: function() {
-        UserStore.removeAuditsChangeListener(this.onListenerChange);
-    },
-    onListenerChange: function() {
-        var newState = getStateFromStoresForAudits();
+    }
+    componentWillUnmount() {
+        UserStore.removeAuditsChangeListener(this.onAuditChange);
+    }
+    onAuditChange() {
+        var newState = this.getStateFromStoresForAudits();
         if (!utils.areStatesEqual(newState.audits, this.state.audits)) {
             this.setState(newState);
         }
-    },
-    handleMoreInfo: function(index) {
+    }
+    handleMoreInfo(index) {
         var newMoreInfo = this.state.moreInfo;
         newMoreInfo[index] = true;
         this.setState({moreInfo: newMoreInfo});
-    },
-    getInitialState: function() {
-        var initialState = getStateFromStoresForAudits();
-        initialState.moreInfo = [];
-        return initialState;
-    },
-    render: function() {
+    }
+    render() {
         var accessList = [];
         var currentHistoryDate = null;
 
@@ -63,7 +65,16 @@ module.exports = React.createClass({
                 currentAudit.session_id = 'N/A (Login attempt)';
             }
 
-            var moreInfo = (<a href='#' className='theme' onClick={this.handleMoreInfo.bind(this, i)}>More info</a>);
+            var moreInfo = (
+                <a
+                    href='#'
+                    className='theme'
+                    onClick={this.handleMoreInfo.bind(this, i)}
+                >
+                    More info
+                </a>
+            );
+
             if (this.state.moreInfo[i]) {
                 moreInfo = (
                     <div>
@@ -75,7 +86,7 @@ module.exports = React.createClass({
 
             var divider = null;
             if (i < this.state.audits.length - 1) {
-                divider = (<div className='divider-light'></div>)
+                divider = (<div className='divider-light'></div>);
             }
 
             accessList[i] = (
@@ -102,14 +113,36 @@ module.exports = React.createClass({
 
         return (
             <div>
-                <div className='modal fade' ref='modal' id='access-history' tabIndex='-1' role='dialog' aria-hidden='true'>
+                <div
+                    className='modal fade'
+                    ref='modal'
+                    id='access-history'
+                    tabIndex='-1'
+                    role='dialog'
+                    aria-hidden='true'
+                >
                     <div className='modal-dialog modal-lg'>
                         <div className='modal-content'>
                             <div className='modal-header'>
-                                <button type='button' className='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
-                                <h4 className='modal-title' id='myModalLabel'>Access History</h4>
+                                <button
+                                    type='button'
+                                    className='close'
+                                    data-dismiss='modal'
+                                    aria-label='Close'
+                                >
+                                    <span aria-hidden='true'>&times;</span>
+                                </button>
+                                <h4
+                                    className='modal-title'
+                                    id='myModalLabel'
+                                >
+                                    Access History
+                                </h4>
                             </div>
-                            <div ref='modalBody' className='modal-body'>
+                            <div
+                                ref='modalBody'
+                                className='modal-body'
+                            >
                                 {content}
                             </div>
                         </div>
@@ -118,4 +151,4 @@ module.exports = React.createClass({
             </div>
         );
     }
-});
+}
-- 
cgit v1.2.3-1-g7c22


From 31519f7c88d61bc2828275b1be273cd97c8af4bb Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Wed, 2 Sep 2015 08:40:25 -0400
Subject: Changed imports to be upper case for multiple files.

---
 web/react/components/access_history_modal.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'web/react/components/access_history_modal.jsx')

diff --git a/web/react/components/access_history_modal.jsx b/web/react/components/access_history_modal.jsx
index 217b96d0b..bdf9bd9a4 100644
--- a/web/react/components/access_history_modal.jsx
+++ b/web/react/components/access_history_modal.jsx
@@ -4,7 +4,7 @@
 var UserStore = require('../stores/user_store.jsx');
 var AsyncClient = require('../utils/async_client.jsx');
 var LoadingScreen = require('./loading_screen.jsx');
-var utils = require('../utils/utils.jsx');
+var Utils = require('../utils/utils.jsx');
 
 export default class AccessHistoryModal extends React.Component {
     constructor(props) {
@@ -38,7 +38,7 @@ export default class AccessHistoryModal extends React.Component {
     }
     onAuditChange() {
         var newState = this.getStateFromStoresForAudits();
-        if (!utils.areStatesEqual(newState.audits, this.state.audits)) {
+        if (!Utils.areStatesEqual(newState.audits, this.state.audits)) {
             this.setState(newState);
         }
     }
-- 
cgit v1.2.3-1-g7c22


From 86b474666ca0f25af2ddb808fc618517292e865a Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Wed, 2 Sep 2015 10:19:31 -0400
Subject: Remove getDOMNode usage and self assign in access_modal_history.jsx

---
 web/react/components/access_history_modal.jsx | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

(limited to 'web/react/components/access_history_modal.jsx')

diff --git a/web/react/components/access_history_modal.jsx b/web/react/components/access_history_modal.jsx
index bdf9bd9a4..9c8e7c6c3 100644
--- a/web/react/components/access_history_modal.jsx
+++ b/web/react/components/access_history_modal.jsx
@@ -23,15 +23,14 @@ export default class AccessHistoryModal extends React.Component {
     }
     componentDidMount() {
         UserStore.addAuditsChangeListener(this.onAuditChange);
-        $(this.refs.modal.getDOMNode()).on('shown.bs.modal', function show() {
+        $(React.findDOMNode(this.refs.modal)).on('shown.bs.modal', function show() {
             AsyncClient.getAudits();
         });
 
-        var self = this;
-        $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function hide() {
+        $(React.findDOMNode(this.refs.modal)).on('hidden.bs.modal', function hide() {
             $('#user_settings').modal('show');
-            self.setState({moreInfo: []});
-        });
+            this.setState({moreInfo: []});
+        }.bind(this));
     }
     componentWillUnmount() {
         UserStore.removeAuditsChangeListener(this.onAuditChange);
-- 
cgit v1.2.3-1-g7c22

