From 1c7f0be268046d2b509e23268eebcbbef78c5a24 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Thu, 9 Jul 2015 15:49:23 -0400
Subject: Renamed all clientside references from full_name to nickname

---
 web/react/components/user_settings.jsx | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

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

diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx
index 38e4b1aea..9ec7f64c9 100644
--- a/web/react/components/user_settings.jsx
+++ b/web/react/components/user_settings.jsx
@@ -316,8 +316,8 @@ var NotificationsTab = React.createClass({
         if (this.props.activeSection === 'keys') {
             var user = this.props.user;
             var first_name = "";
-            if (user.full_name.length > 0) {
-                first_name = user.full_name.split(' ')[0];
+            if (user.nickname.length > 0) {
+                first_name = user.nickname.split(' ')[0];
             }
 
             var inputs = [];
@@ -399,7 +399,7 @@ var NotificationsTab = React.createClass({
             if (this.state.first_name_key) {
                 var first_name = "";
                 var user = this.props.user;
-                if (user.full_name.length > 0) first_name = user.full_name.split(' ')[0];
+                if (user.nickname.length > 0) first_name = user.nickname.split(' ')[0];
                 if (first_name != "") keys.push(first_name);
             }
             if (this.state.username_key) keys.push(this.props.user.username);
@@ -761,12 +761,12 @@ var GeneralTab = React.createClass({
 
         var fullName = firstName + ' ' + lastName;
 
-        if (user.full_name === fullName) {
+        if (user.nickname === fullName) {
             this.setState({client_error: "You must submit a new name"})
             return;
         }
 
-        user.full_name = fullName;
+        user.nickname = fullName;
 
         this.submitUser(user);
     },
@@ -861,7 +861,7 @@ var GeneralTab = React.createClass({
     getInitialState: function() {
         var user = this.props.user;
 
-        var splitStr = user.full_name.split(' ');
+        var splitStr = user.nickname.split(' ');
         var firstName = splitStr.shift();
         var lastName = splitStr.join(' ');
 
@@ -913,7 +913,7 @@ var GeneralTab = React.createClass({
             nameSection = (
                 <SettingItemMin
                     title="Name"
-                    describe={UserStore.getCurrentUser().full_name}
+                    describe={UserStore.getCurrentUser().nickname}
                     updateSection={function(){self.updateSection("name");}}
                 />
             );
-- 
cgit v1.2.3-1-g7c22


From 8dbf03bd10a440db3896c046de7332806f96e889 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Thu, 9 Jul 2015 17:20:18 -0400
Subject: Add interface to edit a user's nickname directly

---
 web/react/components/user_settings.jsx | 55 +++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

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

diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx
index 9ec7f64c9..c1ea367f2 100644
--- a/web/react/components/user_settings.jsx
+++ b/web/react/components/user_settings.jsx
@@ -752,6 +752,21 @@ var GeneralTab = React.createClass({
 
         this.submitUser(user);
     },
+    submitNickname: function(e) {
+        e.preventDefault();
+
+        var user = UserStore.getCurrentUser();
+        var nickname = this.state.nickname.trim();
+
+        if (user.nickname === nickname) {
+            this.setState({client_error: "You must submit a new nickname"})
+            return;
+        }
+
+        user.nickname = nickname;
+
+        this.submitUser(user);
+    },
     submitName: function(e) {
         e.preventDefault();
 
@@ -839,6 +854,9 @@ var GeneralTab = React.createClass({
     updateLastName: function(e) {
         this.setState({ last_name: e.target.value});
     },
+    updateNickname: function(e) {
+        this.setState({nickname: e.target.value});
+    },
     updateEmail: function(e) {
         this.setState({ email: e.target.value});
     },
@@ -865,7 +883,7 @@ var GeneralTab = React.createClass({
         var firstName = splitStr.shift();
         var lastName = splitStr.join(' ');
 
-        return { username: user.username, first_name: firstName, last_name: lastName,
+        return { username: user.username, first_name: firstName, last_name: lastName, nickname: user.nickname,
                  email: user.email, picture: null };
     },
     render: function() {
@@ -919,6 +937,39 @@ var GeneralTab = React.createClass({
             );
         }
 
+        var nicknameSection;
+        if (this.props.activeSection === 'nickname') {
+            var inputs = [];
+
+            inputs.push(
+                <div className="form-group">
+                    <label className="col-sm-5 control-label">{utils.isMobile() ? "": "Nickname"}</label>
+                    <div className="col-sm-7">
+                        <input className="form-control" type="text" onChange={this.updateNickname} value={this.state.nickname}/>
+                    </div>
+                </div>
+            );
+
+            nicknameSection = (
+                <SettingItemMax
+                    title="Nickname"
+                    inputs={inputs}
+                    submit={this.submitNickname}
+                    server_error={server_error}
+                    client_error={client_error}
+                    updateSection={function(e){self.updateSection("");e.preventDefault();}}
+                />
+            );
+        } else {
+            nicknameSection = (
+                <SettingItemMin
+                    title="Nickname"
+                    describe={UserStore.getCurrentUser().nickname}
+                    updateSection={function(){self.updateSection("nickname");}}
+                />
+            );
+        }
+
         var usernameSection;
         if (this.props.activeSection === 'username') {
             var inputs = [];
@@ -1026,6 +1077,8 @@ var GeneralTab = React.createClass({
                     <div className="divider-light"/>
                     {usernameSection}
                     <div className="divider-light"/>
+                    {nicknameSection}
+                    <div className="divider-light"/>
                     {emailSection}
                     <div className="divider-light"/>
                     {pictureSection}
-- 
cgit v1.2.3-1-g7c22


From b620960cdefe87d9e96958ab526c294ee6502a90 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Fri, 10 Jul 2015 15:51:45 -0400
Subject: Fix migration code so that LastName is populated correctly for users
 who only have one word in their FullName

---
 web/react/components/user_settings.jsx | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

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

diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx
index c1ea367f2..e6eb2b451 100644
--- a/web/react/components/user_settings.jsx
+++ b/web/react/components/user_settings.jsx
@@ -774,14 +774,13 @@ var GeneralTab = React.createClass({
         var firstName = this.state.first_name.trim();
         var lastName = this.state.last_name.trim();
 
-        var fullName = firstName + ' ' + lastName;
-
-        if (user.nickname === fullName) {
-            this.setState({client_error: "You must submit a new name"})
+        if (user.first_name === firstName && user.last_name === lastName) {
+            this.setState({client_error: "You must submit a new first or last name"})
             return;
         }
 
-        user.nickname = fullName;
+        user.first_name = firstName;
+        user.last_name = lastName;
 
         this.submitUser(user);
     },
@@ -879,11 +878,7 @@ var GeneralTab = React.createClass({
     getInitialState: function() {
         var user = this.props.user;
 
-        var splitStr = user.nickname.split(' ');
-        var firstName = splitStr.shift();
-        var lastName = splitStr.join(' ');
-
-        return { username: user.username, first_name: firstName, last_name: lastName, nickname: user.nickname,
+        return { username: user.username, first_name: user.first_name, last_name: user.last_name, nickname: user.nickname,
                  email: user.email, picture: null };
     },
     render: function() {
@@ -919,7 +914,7 @@ var GeneralTab = React.createClass({
 
             nameSection = (
                 <SettingItemMax
-                    title="Name"
+                    title="Full Name"
                     inputs={inputs}
                     submit={this.submitName}
                     server_error={server_error}
@@ -928,10 +923,20 @@ var GeneralTab = React.createClass({
                 />
             );
         } else {
+            var full_name = "";
+
+            if (user.first_name && user.last_name) {
+                full_name = user.first_name + " " + user.last_name;
+            } else if (user.first_name) {
+                full_name = user.first_name;
+            } else if (user.last_name) {
+                full_name = user.last_name;
+            }
+
             nameSection = (
                 <SettingItemMin
-                    title="Name"
-                    describe={UserStore.getCurrentUser().nickname}
+                    title="Full Name"
+                    describe={full_name}
                     updateSection={function(){self.updateSection("name");}}
                 />
             );
-- 
cgit v1.2.3-1-g7c22


From 079538d9e7d22cd8d5f782f4f7434858bd80d914 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Mon, 13 Jul 2015 15:39:53 -0400
Subject: Use User.FirstName for notifications instead of trying to determine
 it from User.Nickname

---
 web/react/components/user_settings.jsx | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

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

diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx
index e6eb2b451..59c97c309 100644
--- a/web/react/components/user_settings.jsx
+++ b/web/react/components/user_settings.jsx
@@ -156,6 +156,8 @@ var NotificationsTab = React.createClass({
 
         var self = this;
 
+        var user = this.props.user;
+
         var desktopSection;
         if (this.props.activeSection === 'desktop') {
             var notifyActive = [false, false, false];
@@ -314,20 +316,14 @@ var NotificationsTab = React.createClass({
 
         var keysSection;
         if (this.props.activeSection === 'keys') {
-            var user = this.props.user;
-            var first_name = "";
-            if (user.nickname.length > 0) {
-                first_name = user.nickname.split(' ')[0];
-            }
-
             var inputs = [];
 
-            if (first_name != "") {
+            if (user.first_name) {
                 inputs.push(
                     <div>
                         <div className="checkbox">
                             <label>
-                                <input type="checkbox" checked={this.state.first_name_key} onChange={function(e){self.updateFirstNameKey(e.target.checked);}}>{'Your case sensitive first name "' + first_name + '"'}</input>
+                                <input type="checkbox" checked={this.state.first_name_key} onChange={function(e){self.updateFirstNameKey(e.target.checked);}}>{'Your case sensitive first name "' + user.first_name + '"'}</input>
                             </label>
                         </div>
                     </div>
@@ -396,14 +392,9 @@ var NotificationsTab = React.createClass({
             );
         } else {
             var keys = [];
-            if (this.state.first_name_key) {
-                var first_name = "";
-                var user = this.props.user;
-                if (user.nickname.length > 0) first_name = user.nickname.split(' ')[0];
-                if (first_name != "") keys.push(first_name);
-            }
-            if (this.state.username_key) keys.push(this.props.user.username);
-            if (this.state.mention_key) keys.push('@'+this.props.user.username);
+            if (this.state.first_name_key) keys.push(user.first_name);
+            if (this.state.username_key) keys.push(user.username);
+            if (this.state.mention_key) keys.push('@'+user.username);
             if (this.state.all_key) keys.push('@all');
             if (this.state.channel_key) keys.push('@channel');
             if (this.state.custom_keys.length > 0) keys = keys.concat(this.state.custom_keys.split(','));
-- 
cgit v1.2.3-1-g7c22

