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

Convert Sharing to use es6 #11724

Merged
merged 7 commits into from
Mar 3, 2017
Merged

Convert Sharing to use es6 #11724

merged 7 commits into from
Mar 3, 2017

Conversation

obenland
Copy link
Member

@obenland obenland commented Mar 2, 2017

This PR modernizes Sharing's top-level components and removes the feature flag.

After #8991 these are the remaining pieces that can be cleaned up.

To test:
Verify that My Sites > Sharing is still accessible, both the Connections and the Sharing Buttons tab.

@obenland obenland added [Feature] Sharing Features and settings for sharing posts across different platforms, including sharing buttons. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Type] Janitorial labels Mar 2, 2017
@matticbot
Copy link
Contributor

@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 2, 2017
@obenland obenland requested review from gwwar and aduth March 2, 2017 21:40
@obenland
Copy link
Member Author

obenland commented Mar 2, 2017

@aduth Can the manage/sharing feature flag be removed? It's set to true in all environments

@aduth
Copy link
Contributor

aduth commented Mar 2, 2017

@aduth Can the manage/sharing feature flag be removed? It's set to true in all environments

Yeah, would be a good idea.

var site = sites.getSelectedSite(),
pathSuffix = sites.selected ? '/' + sites.selected : '',
filters = [];
class Sharing extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given it has no state, would probably be fairly easy to express this as a function component if we're comfortable collapsing getFilters into the render logic.

};

export default connect(
( state, { site } ) => ( {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a little much to refactor in the context of this pull request, but it would be nice to drop the full site object in favor of the more specific selectors: getSiteSlug, isJetpackSite, isJetpackModuleActive, isJetpackMinimumVersion.

next();
};

export default {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the default export if we're already exporting the individual functions (appears sharing/index.js should work without the default export).

Copy link
Contributor

Choose a reason for hiding this comment

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

Good 👀. I would probably do a usage search to see if we have any usages like require( './controller' ).buttons. This should be safe to remove if we update any requires/imports to import { button } from './controller'; or import * as controller from './controller'

return (
<Main className="sharing">
<DocumentHead title={ this.props.translate( 'Sharing', { textOnly: true } ) } />
Copy link
Contributor

Choose a reason for hiding this comment

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

I know I've seen this elsewhere, but where is textOnly documented or referenced in code? It's not clear when it should be used (I seem to recall something about being auto-wrapped with span but not sure if that's still the case).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for asking that! I wondered myself but not enough to actually research it.

Before React 0.14 when ReactElements became plain objects, the option was needed to override ReactElement.prototype.toString to have control over how the object is converted to a string. The option is unused since #2455, so I'll remove it

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

aduth commented Mar 3, 2017

I'm unable to load the Sharing Buttons screen from an empty cache, but this is also the case in production, so unlikely to be related to the changes here specifically.

Warning: Failed prop type: The prop `siteId` is marked as required in `SharingButtons`, but its value is `null`.
Uncaught TypeError: Cannot convert undefined or null to object

buttons.jsx

Copy link
Contributor

@aduth aduth 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 items noted, and some breakage that already exists in master, but otherwise changes here seem sensible and test well 👍

import { renderWithReduxStore } from 'lib/react-helpers';
import { sectionify } from 'lib/route';
import Sharing from 'my-sites/sharing/main';
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Seems like in this and following imports it would be reasonable to import relative:

import Sharing from './main';


return filters;
return {
showButtons: ( siteId && canCurrentUser( state, siteId, 'manage_options' ) && ( ! isJetpack || (
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 quite the condition :D Not sure how else we might simplify it aside from maybe splitting off a few variables: canManageOptions ? supportsSharingButtons ?

obenland added 3 commits March 3, 2017 09:14
Not sure why it used absolute paths before.

See
#11724 (comment)
0
Pulls  out some of the function calls to use more concise variables in
the condition

See
#11724 (comment)
5
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 3, 2017
@obenland obenland merged commit 27e73c4 into master Mar 3, 2017
@obenland obenland deleted the update/sharing-es6 branch March 3, 2017 19:09
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 3, 2017
obenland added a commit that referenced this pull request Mar 3, 2017
None of the props are actually required, and all queries can happen one
we do have a site ID.

See
#11724 (comment)
38
obenland added a commit that referenced this pull request Mar 3, 2017
None of the props are actually required, and all queries can happen one
we do have a site ID.

See
#11724 (comment)
38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Sharing Features and settings for sharing posts across different platforms, including sharing buttons. [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.

4 participants