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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/my-sites/sharing/connections/service-example.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = React.createClass( {
src: React.PropTypes.string,
alt: React.PropTypes.string
} ),
label: React.PropTypes.oneOfType( [ React.PropTypes.string, React.PropTypes.element, React.PropTypes.object ] ),
label: React.PropTypes.node,
single: React.PropTypes.bool
},

Expand Down
39 changes: 29 additions & 10 deletions client/my-sites/sharing/connections/services-group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
var React = require( 'react' ),
get = require( 'lodash/object/get' ),
classNames = require( 'classnames' );

/**
Expand Down Expand Up @@ -43,18 +44,36 @@ module.exports = React.createClass( {
},

getEligibleServices: function() {
// Currently, we only filter services by Jetpack support. If the site
// isn't a Jetpack site, we can be assured all services are supported.
if ( ! this.props.site || ! this.props.site.jetpack ) {
return this.props.services;
const { site, services } = this.props;

if ( ! site ) {
return services;
}

return this.props.services.filter( function( service ) {
// Omit the service if it doesn't support Jetpack or if the
// required Jetpack module is not currently active
return service.jetpack_support && ( ! service.jetpack_module_required ||
this.props.site.isModuleActive( service.jetpack_module_required ) );
}, this );
return services.filter( function( service ) {
// Omit if the site is Jetpack and service doesn't support Jetpack
if ( site.jetpack && ! service.jetpack_support ) {
return false;
}

// Omit if Jetpack module not activated
if ( site.jetpack && service.jetpack_module_required &&
! site.isModuleActive( service.jetpack_module_required ) ) {
return false;
}

// Omit if service is settings-oriented and user cannot manage
if ( 'eventbrite' === service.name && ! site.user_can_manage ) {
return false;
}

// Omit if Publicize service and user cannot publish
if ( 'publicize' === service.type && ! get( site, 'capabilities.publish_posts' ) ) {
return false;
}

return true;
} );
},

renderService: function( service ) {
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/sharing/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {

titleActions.setTitle( i18n.translate( 'Sharing', { textOnly: true } ), { siteID: siteUrl } );

if ( site && ! site.settings ) {
if ( site && ! site.settings && site.user_can_manage ) {
site.fetchSettings();
}

Expand Down