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

Sharing: prevent notice for non-admins #1653

Merged
merged 3 commits into from
Dec 18, 2015
Merged

Conversation

jkudish
Copy link
Contributor

@jkudish jkudish commented Dec 16, 2015

Currently non-admins (specifically authors and editors) receive the following notice when visiting /sharing:

screenshot from 2015-12-15 16-11-53

We only need site settings for buttons, not for connections. So this PR seeks to move the call to fetch the site settings to the buttons controller. This prevents the unnecessary notice for non-admins.

cc @aduth for review

@jkudish jkudish added [Type] Bug [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. labels Dec 16, 2015
@jkudish jkudish self-assigned this Dec 16, 2015
@aduth
Copy link
Contributor

aduth commented Dec 16, 2015

The connections page needs to have access to site settings for Eventbrite:

getConnections: function( connections, serviceName, siteId ) {
var site = siteId ? sites.getSite( siteId ) : sites.getSelectedSite();
if ( ! site || ! site.settings ) {
return [];
}
return connections.filter( function( connection ) {
return site.settings.eventbrite_api_token === connection.keyring_connection_ID;
} );
},

I think what we need to do is perform fetchSettings and show the Eventbrite connection option only if site.user_can_manage is true.

@jkudish
Copy link
Contributor Author

jkudish commented Dec 16, 2015

Ah good point, missed the EB part of this. Any idea how to make the request without showing the notice and without doing a huge refactor of how the Site object currently works?

@aduth
Copy link
Contributor

aduth commented Dec 16, 2015

@jkudish - I pushed revisions to exclude the Eventbrite service from the Connections screen if the user cannot manage site settings: 6a09680

@jkudish
Copy link
Contributor Author

jkudish commented Dec 16, 2015

Noting that with #1700 applied, I am getting this warning on the post editor as well (with an a user who's an author). That was without this PR applied. Going to check the combination of both shortly.

@jkudish
Copy link
Contributor Author

jkudish commented Dec 16, 2015

With this and #1700 both applied, as an author on a Jetpack site:

  • I can fully manage my connections w/out a notice 👍 :
  • I still get a notice in the Post Editor 👎

screenshot from 2015-12-16 13-56-17

@jkudish
Copy link
Contributor Author

jkudish commented Dec 16, 2015

Testing as an Editor on a JP Site, I get the following warning in the console:

Warning: Failed propType: Invalid prop `label` supplied to `SharingServiceExample`. Check the render method of `SharingServiceExamples`.

@jkudish
Copy link
Contributor Author

jkudish commented Dec 16, 2015

Testing as a Contributor on a JP site. I wouldn't expect the /sharing page to load at all, but it does. However, it doesn't appear in the sidebar, and I cannot actually add connections:

screenshot from 2015-12-16 14-03-47

I think we just need to add an error message/block the page from loading services when ! current_user_can( 'publish_posts' )

@jkudish
Copy link
Contributor Author

jkudish commented Dec 16, 2015

As an Author on a WP.com site, I still see Eventbrite on the connections page. However, it correctly doesn't let me add the connection:

screenshot from 2015-12-16 14-08-04

Confirming that as an Administrator I can still manage everything as expected, however.

@aduth
Copy link
Contributor

aduth commented Dec 17, 2015

I still get a notice in the Post Editor 👎

Let's address this separately.

Testing as an Editor on a JP Site, I get the following warning in the console:

This is also true in master, so let's similarly address separately.

Testing as a Contributor on a JP site. I wouldn't expect the /sharing page to load at all, but it does. However, it doesn't appear in the sidebar, and I cannot actually add connections:

This is partially covered by #429, but I think we can do a bit more here with the filtering of eligible services since we're already making changes anyways. I'll look to update shortly.

As an Author on a WP.com site, I still see Eventbrite on the connections page. However, it correctly doesn't let me add the connection:

This sounds like a bug. I'll take a look.

@aduth
Copy link
Contributor

aduth commented Dec 17, 2015

As an Author on a WP.com site, I still see Eventbrite on the connections page. However, it correctly doesn't let me add the connection:

Can you double-check this? I'm unable to reproduce, and have found sometimes in testing my extra accounts I accidentally test against WordPress.com instead of calypso.localhost .

@aduth
Copy link
Contributor

aduth commented Dec 17, 2015

Now hiding Publicize services for contributors in 4ac7b95.

@aduth aduth force-pushed the fix/sharing-notice-for-non-admins branch from 4ac7b95 to 77cf51a Compare December 18, 2015 14:11
@aduth
Copy link
Contributor

aduth commented Dec 18, 2015

Rebased and squashed a few commits. I decided to go ahead and fix #1750 here since it was a very simple fix. See 77cf51a (and docs on PropTypes.node).

@jkudish
Copy link
Contributor Author

jkudish commented Dec 18, 2015

Re-tested this PR with the latest code and all the different combinations of WP.com/Jetpack site + different permissions. It now works exactly as expected everywhere. Thanks for pushing through on this.

Reviewed the code too, LGTM 🚢

I think it'd be good to update the REST API's /meta/external-services endpoint to return required_capability so that we don't have to hardcode these values in Calypso. Of course, this would be addressed separately.

@jkudish jkudish 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 Dec 18, 2015
@aduth
Copy link
Contributor

aduth commented Dec 18, 2015

I think it'd be good to update the REST API's /meta/external-services endpoint to return required_capability so that we don't have to hardcode these values in Calypso. Of course, this would be addressed separately.

Yeah, that sounds like a good idea.

aduth added a commit that referenced this pull request Dec 18, 2015
…dmins

Sharing: prevent notice for non-admins
@aduth aduth merged commit 3f9ef7b into master Dec 18, 2015
@aduth aduth deleted the fix/sharing-notice-for-non-admins branch December 18, 2015 20:40
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. [Type] Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants