From 2589142109ea3a9fbfb2a370506098f85b821c45 Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Tue, 4 Aug 2015 09:40:58 -0700
Subject: Added cosmetic refactoring

---
 web/react/components/sidebar_header.jsx | 94 +++++++++++++++++----------------
 1 file changed, 49 insertions(+), 45 deletions(-)

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

diff --git a/web/react/components/sidebar_header.jsx b/web/react/components/sidebar_header.jsx
index 4cea43688..ba8f9bacd 100644
--- a/web/react/components/sidebar_header.jsx
+++ b/web/react/components/sidebar_header.jsx
@@ -23,9 +23,11 @@ var NavbarDropdown = React.createClass({
         TeamStore.addChangeListener(this.onListenerChange);
 
         var self = this;
-        $(this.refs.dropdown.getDOMNode()).on('hide.bs.dropdown', function(e) {
+        $(this.refs.dropdown.getDOMNode()).on('hide.bs.dropdown', function() {
             self.blockToggle = true;
-            setTimeout(function(){self.blockToggle = false;}, 100);
+            setTimeout(function() {
+                self.blockToggle = false;
+            }, 100);
         });
     },
     componentWillUnmount: function() {
@@ -46,63 +48,65 @@ var NavbarDropdown = React.createClass({
         return getStateFromStores();
     },
     render: function() {
-        var team_link = "";
-        var invite_link = "";
-        var manage_link = "";
-        var rename_link = "";
+        var teamLink = '';
+        var inviteLink = '';
+        var manageLink = '';
+        var renameLink = '';
         var currentUser = UserStore.getCurrentUser();
         var isAdmin = false;
+        var teamSettings = null;
 
         if (currentUser != null) {
-            isAdmin = currentUser.roles.indexOf("admin") > -1;
+            isAdmin = currentUser.roles.indexOf('admin') > -1;
 
-            invite_link = ( <li> <a href="#" data-toggle="modal" data-target="#invite_member">Invite New Member</a> </li>);
+            inviteLink = (<li> <a href='#' data-toggle='modal' data-target='#invite_member'>Invite New Member</a> </li>);
 
-            if (this.props.teamType == "O") {
-                team_link = (
+            if (this.props.teamType === 'O') {
+                teamLink = (
                     <li>
-                        <a href="#" data-toggle="modal" data-target="#get_link" data-title="Team Invite" data-value={location.origin+"/signup_user_complete/?id="+currentUser.team_id}>Get Team Invite Link</a>
+                        <a href='#' data-toggle='modal' data-target='#get_link' data-title='Team Invite' data-value={location.origin + '/signup_user_complete/?id=' + currentUser.team_id}>Get Team Invite Link</a>
                     </li>
                 );
             }
         }
 
         if (isAdmin) {
-            manage_link = ( <li> <a href="#" data-toggle="modal" data-target="#team_members">Manage Team</a> </li>);
-            rename_link = ( <li> <a href="#" data-toggle="modal" data-target="#rename_team_link">Rename</a> </li>);
+            manageLink = (<li> <a href='#' data-toggle='modal' data-target='#team_members'>Manage Team</a> </li>);
+            renameLink = (<li> <a href='#' data-toggle='modal' data-target='#rename_team_link'>Rename</a> </li>);
+            teamSettings = (<li> <a href='#' data-toggle='modal' data-target='#team_settings'>Team Settings</a> </li>);
         }
 
         var teams = [];
 
-        teams.push(<li className="divider" key="div"></li>);
+        teams.push(<li className='divider' key='div'></li>);
         if (this.state.teams.length > 1 && this.state.currentTeam) {
             var curTeamName = this.state.currentTeam.name;
             this.state.teams.forEach(function(teamName) {
                 if (teamName !== curTeamName) {
-                    teams.push(<li key={ teamName }><a href={utils.getWindowLocationOrigin() + "/" + teamName }>Switch to { teamName }</a></li>);
+                    teams.push(<li key={teamName}><a href={utils.getWindowLocationOrigin() + '/' + teamName}>Switch to {teamName}</a></li>);
                 }
             });
         }
-        teams.push(<li><a href={utils.getWindowLocationOrigin() + "/signup_team" }>Create a New Team</a></li>);
+        teams.push(<li><a href={utils.getWindowLocationOrigin() + '/signup_team'}>Create a New Team</a></li>);
 
         return (
-            <ul className="nav navbar-nav navbar-right">
-                <li ref="dropdown" className="dropdown">
-                    <a href="#" className="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
-                        <span className="dropdown__icon" dangerouslySetInnerHTML={{__html: Constants.MENU_ICON }} />
+            <ul className='nav navbar-nav navbar-right'>
+                <li ref='dropdown' className='dropdown'>
+                    <a href='#' className='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded='false'>
+                        <span className='dropdown__icon' dangerouslySetInnerHTML={{__html: Constants.MENU_ICON}} />
                     </a>
-                    <ul className="dropdown-menu" role="menu">
-                        <li><a href="#" data-toggle="modal" data-target="#user_settings1">Account Settings</a></li>
-                        { isAdmin ? <li><a href="#" data-toggle="modal" data-target="#team_settings">Team Settings</a></li> : null }
-                        { invite_link }
-                        { team_link }
-                        { manage_link }
-                        { rename_link }
-                        <li><a href="#" onClick={this.handleLogoutClick}>Logout</a></li>
-                        { teams }
-                        <li className="divider"></li>
-                        <li><a target="_blank" href={config.HelpLink}>Help</a></li>
-                        <li><a target="_blank" href={config.ReportProblemLink}>Report a Problem</a></li>
+                    <ul className='dropdown-menu' role='menu'>
+                        <li><a href='#' data-toggle='modal' data-target='#user_settings1'>Account Settings</a></li>
+                        {teamSettings}
+                        {inviteLink}
+                        {teamLink}
+                        {manageLink}
+                        {renameLink}
+                        <li><a href='#' onClick={this.handleLogoutClick}>Logout</a></li>
+                        {teams}
+                        <li className='divider'></li>
+                        <li><a target='_blank' href={config.HelpLink}>Help</a></li>
+                        <li><a target='_blank' href={config.ReportProblemLink}>Report a Problem</a></li>
                     </ul>
                 </li>
             </ul>
@@ -112,14 +116,13 @@ var NavbarDropdown = React.createClass({
 
 module.exports = React.createClass({
     displayName: 'SidebarHeader',
-
     getDefaultProps: function() {
         return {
             teamDisplayName: config.SiteName
         };
     },
 
-    toggleDropdown: function(e) {
+    toggleDropdown: function() {
         if (this.refs.dropdown.blockToggle) {
             this.refs.dropdown.blockToggle = false;
             return;
@@ -129,25 +132,26 @@ module.exports = React.createClass({
 
     render: function() {
         var me = UserStore.getCurrentUser();
+        var profilePicture = null;
 
         if (!me) {
             return null;
         }
 
+        if (me.last_picture_update) {
+            profilePicture = (<img className='user__picture' src={'/api/v1/users/' + me.id + '/image?time=' + me.update_at} />);
+        }
+
         return (
-            <div className="team__header theme">
-                <a href="#" onClick={this.toggleDropdown}>
-                    { me.last_picture_update ?
-                    <img className="user__picture" src={"/api/v1/users/" + me.id + "/image?time=" + me.update_at} />
-                    :
-                    null
-                    }
-                    <div className="header__info">
-                        <div className="user__name">{ '@' + me.username}</div>
-                        <div className="team__name">{ this.props.teamDisplayName }</div>
+            <div className='team__header theme'>
+                <a href='#' onClick={this.toggleDropdown}>
+                    {profilePicture}
+                    <div className='header__info'>
+                        <div className='user__name'>{'@' + me.username}</div>
+                        <div className='team__name'>{this.props.teamDisplayName }</div>
                     </div>
                 </a>
-                <NavbarDropdown ref="dropdown" teamType={this.props.teamType} />
+                <NavbarDropdown ref='dropdown' teamType={this.props.teamType} />
             </div>
         );
     }
-- 
cgit v1.2.3-1-g7c22

