summaryrefslogtreecommitdiffstats
path: root/web/react/components/access_history_modal.jsx
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-08-31 11:39:00 -0400
committerJoramWilander <jwawilander@gmail.com>2015-09-01 08:53:10 -0400
commit0b2490c689d23ebe0c1d4d86cb1c203e2d9ab8c7 (patch)
treed85b92f43556ee03a6b3b871ef70ff7ecddd8895 /web/react/components/access_history_modal.jsx
parent99911d9e4f87c4aa0dfa9a66518035c9668f193a (diff)
downloadchat-0b2490c689d23ebe0c1d4d86cb1c203e2d9ab8c7.tar.gz
chat-0b2490c689d23ebe0c1d4d86cb1c203e2d9ab8c7.tar.bz2
chat-0b2490c689d23ebe0c1d4d86cb1c203e2d9ab8c7.zip
Reformatted access_history_modal.jsx to meet style guide requirements.
Diffstat (limited to 'web/react/components/access_history_modal.jsx')
-rw-r--r--web/react/components/access_history_modal.jsx99
1 files changed, 66 insertions, 33 deletions
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>
);
}
-});
+}