Skip to content

Commit

Permalink
Support User: Add Gravatar and user details to Restore User
Browse files Browse the repository at this point in the history
Stores a copy of the user data when a change is anticipated; uses this
to display the original user’s data on the “Restore User” modal.
  • Loading branch information
jmdodd authored and jordwest committed Dec 18, 2015
1 parent dd083b2 commit a43a727
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions client/components/support-user/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@ module.exports = React.createClass( {
getInitialState: function() {
return {
supportUser: null,
supportPassword: null,
isSupportUser: false,
showDialog: false,
errorMessage: null
errorMessage: null,
user: null
};
},

isEnabled: function() {
if ( this.state.isSupportUser ) {
return true;
}

if ( ! userSettings.hasSettings() ) {
userSettings.fetchSettings();
return false;
Expand All @@ -65,15 +71,19 @@ module.exports = React.createClass( {
supportPassword: null,
isSupportUser: false,
showDialog: true,
errorMessage: error.message
errorMessage: error.message,
user: null
} );
},

onChangeUser: function( e ) {
e.preventDefault();

let user = new User();
let myUser = Object.assign( {}, user.data );
this.setState( { user: myUser } );

if ( this.state.supportUser && this.state.supportPassword ) {
let user = new User();
user.clear();
user.changeUser(
this.state.supportUser,
Expand All @@ -89,15 +99,18 @@ module.exports = React.createClass( {
},

onRestoreUser: function( e ) {
if ( this.state.isSupportUser && this.state.restoreUser ) {
e.preventDefault();

if ( this.state.isSupportUser ) {
let user = new User();
user.clear().fetch();
this.setState( {
supportUser: null,
supportPassword: null,
isSupportUser: false,
showDialog: false,
errorMessage: null
errorMessage: null,
user: null
} );
window.location.reload.bind( window.location );
}
Expand Down Expand Up @@ -152,19 +165,21 @@ module.exports = React.createClass( {
buttons={ this.getButtonsRestoreUser() }
additionalClassNames="support-user__dialog"
>
<FormFieldset>
<div className="support-user__people-profile">
<div className="support-user__gravatar">
<img className="gravatar" src="https://0.gravatar.com/avatar/3c063e69ebd9a94b87a36749505b5561?s=96&d=mm&r=G" />
<Gravatar user={ this.state.user } size={ 96 } />
</div>
<div className="support-user__detail">
<div className="support-user__username">
Eduardo Villuendas
{ this.state.user.display_name }
</div>
<div className="support-user__login">
<span>@evilluendas</span>
<span>@{ this.state.user.username }</span>
</div>
</div>
</div>
</FormFieldset>
</Dialog>
);
} else {
Expand Down

0 comments on commit a43a727

Please sign in to comment.