From bbd02dda810427d69255fd3ab64dc2d18a685f1a Mon Sep 17 00:00:00 2001 From: okbel Date: Mon, 30 Apr 2018 23:14:47 -0300 Subject: [PATCH] Finished with crossed steps --- .../components/ChangeUsernameContentDialog.js | 1 - .../components/ConfirmChangesDialog.js | 31 ++++++++-------- .../profile-settings/components/Profile.js | 35 +++++++++---------- .../talk-plugin-auth/client/translations.yml | 2 +- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/plugins/talk-plugin-auth/client/profile-settings/components/ChangeUsernameContentDialog.js b/plugins/talk-plugin-auth/client/profile-settings/components/ChangeUsernameContentDialog.js index f06fe5acd..408f3d836 100644 --- a/plugins/talk-plugin-auth/client/profile-settings/components/ChangeUsernameContentDialog.js +++ b/plugins/talk-plugin-auth/client/profile-settings/components/ChangeUsernameContentDialog.js @@ -32,7 +32,6 @@ class ChangeUsernameContentDialog extends React.Component { await this.props.save(); this.props.next(); - this.props.closeDialog(); }; formHasError = () => diff --git a/plugins/talk-plugin-auth/client/profile-settings/components/ConfirmChangesDialog.js b/plugins/talk-plugin-auth/client/profile-settings/components/ConfirmChangesDialog.js index a69a869ab..59eac894f 100644 --- a/plugins/talk-plugin-auth/client/profile-settings/components/ConfirmChangesDialog.js +++ b/plugins/talk-plugin-auth/client/profile-settings/components/ConfirmChangesDialog.js @@ -34,27 +34,28 @@ class ConfirmChangesDialog extends React.Component { this.props.finish(); }; + renderSteps = () => { + const steps = React.Children.toArray(this.props.children) + .filter(child => child.props.enable) + .filter((_, i) => i === this.state.step); + + return steps.map(child => { + return React.cloneElement(child, { + goToNextStep: this.goToNextStep, + clear: this.clear, + cancel: this.cancel, + next: this.state.step === steps.length ? this.finish : this.continue, + }); + }); + }; + render() { - const totalSteps = React.Children.count(this.props.children); - - if (!totalSteps) return null; - return ( - {React.Children.map(this.props.children, (child, i) => { - const totalSteps = React.Children.count(this.props.children); - if (i !== this.state.step) return; - return React.cloneElement(child, { - goToNextStep: this.goToNextStep, - clear: this.clear, - cancel: this.cancel, - next: - this.state.step === totalSteps - 1 ? this.finish : this.continue, - }); - })} + {this.renderSteps()} ); } diff --git a/plugins/talk-plugin-auth/client/profile-settings/components/Profile.js b/plugins/talk-plugin-auth/client/profile-settings/components/Profile.js index 536fd0d8a..c40494506 100644 --- a/plugins/talk-plugin-auth/client/profile-settings/components/Profile.js +++ b/plugins/talk-plugin-auth/client/profile-settings/components/Profile.js @@ -176,25 +176,22 @@ class Profile extends React.Component { closeDialog={this.closeDialog} finish={this.finish} > - {username !== formData.newUsername && ( - - )} - - {emailAddress !== formData.newEmail && ( - - )} + + {editing ? ( diff --git a/plugins/talk-plugin-auth/client/translations.yml b/plugins/talk-plugin-auth/client/translations.yml index d8d140a34..17fba29c8 100644 --- a/plugins/talk-plugin-auth/client/translations.yml +++ b/plugins/talk-plugin-auth/client/translations.yml @@ -155,6 +155,7 @@ en: confirm_changes: "Confirm Changes" username_does_not_match: "Username does not match" cant_be_equal: "Your new {0} must be different to your current one" + change_username_attempt: "Username can't be updated. Usernames can be changed every 14 days" change_email: confirm_email_change: "Confirm Email Address Change" description: "You are attempting to change your email address. Your new email address will be used for your login and to receive account notifications." @@ -166,7 +167,6 @@ en: cancel: "Cancel" change_email_msg: "Email Address Changed - Your email address has been successfully changed. This email address will now be used for signing in and email notifications" changed_username_success_msg: "Username Changed - Your username has been successfully changed. You will not be able to change your user name for 14 days." - change_username_attempt: "Username can't be updated. Usernames can be changed every 14 days" de: talk-plugin-auth: login: