Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Janitorial: Refactor site-redirect domain management component #16549

Merged
merged 2 commits into from
Jul 26, 2017

Conversation

aidvu
Copy link
Contributor

@aidvu aidvu commented Jul 25, 2017

  • ES6ify
  • Use Redux actions for tracking
  • Remove unnecessary file
  • Fix broken input and loading placeholders

- ES6ify
- Use Redux actions for tracking
- Remove unnecessary file
- Fix broken input and loading placeholders
@aidvu aidvu added [Feature Group] Emails & Domains Features related to email integrations and domain management. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Type] Janitorial labels Jul 25, 2017
@aidvu aidvu self-assigned this Jul 25, 2017
@matticbot
Copy link
Contributor

@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Jul 25, 2017
Copy link
Contributor

@klimeryk klimeryk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor nitpicks, but otherwise LGTM 👍 Thanks for all these refactor PRs 🙇


handleChange( event ) {
handleChange = ( event ) => {
let location = event.target.value;

// Removes the protocol part
location = location.replace( /.*:\/\//, '' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good idea to also use withoutHttp here, like it was done in https://github.com/Automattic/wp-calypso/pull/16193/files#diff-6564d86c047bc86c6f216e59c29aee42R79.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only problem is that in theory the redirect could be to any protocol. Gah, maybe we should make stripProtocol/withoutProtocol?

};

state = {
location: this.props.location.value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, location is both in the state and props? 🤦‍♂️ Maybe we could at least name them differently? The one in state could be something like locationValue.

let classes = classNames(
const { location, translate } = this.props;
const { isUpdating, notice } = location;
const isFetching = location.isFetching || this.state.location === null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example where the props vs state location gets confusing - my initial reaction was "oh, he did not re-use the destructured location he got from props"... then I facepalmed ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.


<Main className="domain-management-site-redirect">
{
notice &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The notice should probably be inside Main, possibly under Header, so that it's the same width as the rest of the view. Otherwise it looks a bit off:
screen shot 2017-07-26 at 00 02 56

Quick test with the above suggestion:
screen shot 2017-07-26 at 00 07 41

name="destination"
noWrap
onChange={ this.handleChange }
onFocus={ this.handleFocus }
prefix="http://"
type="text"
value={ this.state.location } />
value={ this.state.location || '' } />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this logic should be moved to initializing state above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is that then we loose the null. :) Well, in theory, empty state should also be invalid. Will try.

</FormLabel>

<FormTextInputWithAffixes
disabled={ this.props.location.isFetching || this.props.location.isUpdating }
disabled={ isFetching || isUpdating }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

onClick={ this.handleClick }>
{ this.translate( 'Update Site Redirect' ) }
{ translate( 'Update Site Redirect' ) }
</FormButton>

<FormButton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an UX perspective, it might be good to disable the Cancel button too, when we're updating - otherwise, it might seem to the user that it's the button to cancel the update, when in fact it will just navigate away.

@klimeryk klimeryk added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jul 25, 2017
@klimeryk
Copy link
Contributor

Also: fixes #3148 🎉

@aidvu aidvu merged commit 16c33cc into master Jul 26, 2017
@aidvu aidvu deleted the update/refactor-domains-site-redirect branch July 26, 2017 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature Group] Emails & Domains Features related to email integrations and domain management. [Size] XL Probably needs to be broken down into multiple smaller issues [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants