From 7d07bf6a79c9507b2178338464f7d28ce9a9a4ac Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 31 Aug 2015 11:31:55 -0400 Subject: Refactored various React components to use ES6 syntax and to match the style guide without any errors or warnings --- web/react/components/activity_log_modal.jsx | 179 ++++++---- web/react/components/channel_header.jsx | 436 +++++++++++++++--------- web/react/components/channel_members.jsx | 280 ++++++++------- web/react/components/create_comment.jsx | 213 +++++++----- web/react/components/create_post.jsx | 267 ++++++++------- web/react/components/delete_channel_modal.jsx | 127 ++++--- web/react/components/edit_channel_modal.jsx | 181 ++++++---- web/react/components/file_upload_overlay.jsx | 14 +- web/react/components/login.jsx | 46 +-- web/react/components/member_list_team.jsx | 131 +------ web/react/components/member_list_team_item.jsx | 203 +++++++++++ web/react/components/popover_list_members.jsx | 80 +++++ web/react/components/post_body.jsx | 127 ++++--- web/react/components/rename_channel_modal.jsx | 286 ++++++++++------ web/react/components/rhs_header_post.jsx | 8 +- web/react/components/setting_item_min.jsx | 35 +- web/react/components/settings_sidebar.jsx | 60 +++- web/react/components/signup_team.jsx | 22 +- web/react/components/team_general_tab.jsx | 37 +- web/react/components/team_settings_modal.jsx | 116 ++++--- web/react/components/team_signup_email_item.jsx | 60 ++-- web/react/components/team_signup_url_page.jsx | 111 ++++-- web/react/components/team_signup_with_email.jsx | 18 +- web/react/components/textbox.jsx | 282 +++++++++------ web/react/components/user_settings_general.jsx | 2 +- 25 files changed, 2087 insertions(+), 1234 deletions(-) create mode 100644 web/react/components/member_list_team_item.jsx create mode 100644 web/react/components/popover_list_members.jsx (limited to 'web/react/components') diff --git a/web/react/components/activity_log_modal.jsx b/web/react/components/activity_log_modal.jsx index 1192a72bc..2a83b3c40 100644 --- a/web/react/components/activity_log_modal.jsx +++ b/web/react/components/activity_log_modal.jsx @@ -1,102 +1,104 @@ // Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. -var UserStore = require('../stores/user_store.jsx'); -var Client = require('../utils/client.jsx'); -var AsyncClient = require('../utils/async_client.jsx'); -var LoadingScreen = require('./loading_screen.jsx'); -var utils = require('../utils/utils.jsx'); +const UserStore = require('../stores/user_store.jsx'); +const Client = require('../utils/client.jsx'); +const AsyncClient = require('../utils/async_client.jsx'); +const LoadingScreen = require('./loading_screen.jsx'); +const Utils = require('../utils/utils.jsx'); -function getStateFromStoresForSessions() { - return { - sessions: UserStore.getSessions(), - serverError: null, - clientError: null - }; -} +export default class ActivityLogModal extends React.Component { + constructor(props) { + super(props); + + this.submitRevoke = this.submitRevoke.bind(this); + this.onListenerChange = this.onListenerChange.bind(this); + this.handleMoreInfo = this.handleMoreInfo.bind(this); -module.exports = React.createClass({ - displayName: 'ActivityLogModal', - submitRevoke: function(altId) { + this.state = this.getStateFromStores(); + this.state.moreInfo = []; + } + getStateFromStores() { + return { + sessions: UserStore.getSessions(), + serverError: null, + clientError: null + }; + } + submitRevoke(altId) { Client.revokeSession(altId, - function(data) { + function handleRevokeSuccess() { AsyncClient.getSessions(); - }.bind(this), - function(err) { - var state = getStateFromStoresForSessions(); + }, + function handleRevokeError(err) { + let state = this.getStateFromStores(); state.serverError = err; this.setState(state); }.bind(this) ); - }, - componentDidMount: function() { + } + componentDidMount() { UserStore.addSessionsChangeListener(this.onListenerChange); - $(this.refs.modal.getDOMNode()).on('shown.bs.modal', function (e) { + $(React.findDOMNode(this.refs.modal)).on('shown.bs.modal', function handleShow() { AsyncClient.getSessions(); }); - var self = this; - $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function(e) { + $(React.findDOMNode(this.refs.modal)).on('hidden.bs.modal', function handleHide() { $('#user_settings').modal('show'); - self.setState({moreInfo: []}); - }); - }, - componentWillUnmount: function() { + this.setState({moreInfo: []}); + }.bind(this)); + } + componentWillUnmount() { UserStore.removeSessionsChangeListener(this.onListenerChange); - }, - onListenerChange: function() { - var newState = getStateFromStoresForSessions(); - if (!utils.areStatesEqual(newState.sessions, this.state.sessions)) { + } + onListenerChange() { + const newState = this.getStateFromStores(); + if (!Utils.areStatesEqual(newState.sessions, this.state.sessions)) { this.setState(newState); } - }, - handleMoreInfo: function(index) { - var newMoreInfo = this.state.moreInfo; + } + handleMoreInfo(index) { + let newMoreInfo = this.state.moreInfo; newMoreInfo[index] = true; this.setState({moreInfo: newMoreInfo}); - }, - getInitialState: function() { - var initialState = getStateFromStoresForSessions(); - initialState.moreInfo = []; - return initialState; - }, - render: function() { - var activityList = []; - var serverError = this.state.serverError; - - // Squash any false-y value for server error into null - if (!serverError) { - serverError = null; - } + } + render() { + let activityList = []; - for (var i = 0; i < this.state.sessions.length; i++) { - var currentSession = this.state.sessions[i]; - var lastAccessTime = new Date(currentSession.last_activity_at); - var firstAccessTime = new Date(currentSession.create_at); - var devicePicture = ''; + for (let i = 0; i < this.state.sessions.length; i++) { + const currentSession = this.state.sessions[i]; + const lastAccessTime = new Date(currentSession.last_activity_at); + const firstAccessTime = new Date(currentSession.create_at); + let devicePicture = ''; if (currentSession.props.platform === 'Windows') { devicePicture = 'fa fa-windows'; - } - else if (currentSession.props.platform === 'Macintosh' || currentSession.props.platform === 'iPhone') { + } else if (currentSession.props.platform === 'Macintosh' || currentSession.props.platform === 'iPhone') { devicePicture = 'fa fa-apple'; - } - else if (currentSession.props.platform === 'Linux') { + } else if (currentSession.props.platform === 'Linux') { devicePicture = 'fa fa-linux'; } - var moreInfo; + let moreInfo; if (this.state.moreInfo[i]) { moreInfo = (
-
{'First time active: ' + firstAccessTime.toDateString() + ', ' + lastAccessTime.toLocaleTimeString()}
-
{'OS: ' + currentSession.props.os}
-
{'Browser: ' + currentSession.props.browser}
-
{'Session ID: ' + currentSession.alt_id}
+
{`First time active: ${firstAccessTime.toDateString()}, ${lastAccessTime.toLocaleTimeString()}`}
+
{`OS: ${currentSession.props.os}`}
+
{`Browser: ${currentSession.props.browser}`}
+
{`Session ID: ${currentSession.alt_id}`}
); } else { - moreInfo = (More info); + moreInfo = ( + + More info + + ); } activityList[i] = ( @@ -104,33 +106,62 @@ module.exports = React.createClass({
{currentSession.props.platform}
-
{'Last activity: ' + lastAccessTime.toDateString() + ', ' + lastAccessTime.toLocaleTimeString()}
+
{`Last activity: ${lastAccessTime.toDateString()}, ${lastAccessTime.toLocaleTimeString()}`}
{moreInfo}
-
+
+ +
); } - var content; + let content; if (this.state.sessions.loading) { - content = (); + content = ; } else { - content = (
{activityList}
); + content =
{activityList}
; } return (
-