diff --git a/client/my-sites/plugins-wpcom/jetpack-plugins-panel.jsx b/client/my-sites/plugins-wpcom/jetpack-plugins-panel.jsx index d0a6d64b118d3f..049deb7100edac 100644 --- a/client/my-sites/plugins-wpcom/jetpack-plugins-panel.jsx +++ b/client/my-sites/plugins-wpcom/jetpack-plugins-panel.jsx @@ -2,7 +2,6 @@ * External dependencies */ import React, { Component, PropTypes } from 'react'; -import { connect } from 'react-redux'; import { localize } from 'i18n-calypso'; import { find, @@ -30,8 +29,6 @@ import NavItem from 'components/section-nav/item'; import Search from 'components/search'; import jetpackPlugins from './jetpack-plugins'; import Tooltip from 'components/tooltip'; -import { isATEnabled } from 'lib/automated-transfer'; -import { getSelectedSite } from 'state/ui/selectors'; const filterGroup = category => group => { if ( category && category !== 'all' ) { @@ -176,26 +173,24 @@ class JetpackPluginsPanel extends Component { - { this.props.atEnabled && - - - - } + + + @@ -253,11 +248,4 @@ class JetpackPluginsPanel extends Component { } } -export default connect( - ( state ) => { - const selectedSite = getSelectedSite( state ); - return { - atEnabled: isATEnabled( selectedSite ) - }; - } -)( localize( urlSearch( JetpackPluginsPanel ) ) ); +export default localize( urlSearch( JetpackPluginsPanel ) ); diff --git a/client/my-sites/plugins-wpcom/plugin-panel.jsx b/client/my-sites/plugins-wpcom/plugin-panel.jsx index 8a14e0feba945e..ced8bb09398431 100644 --- a/client/my-sites/plugins-wpcom/plugin-panel.jsx +++ b/client/my-sites/plugins-wpcom/plugin-panel.jsx @@ -14,6 +14,7 @@ import { getSelectedSiteId } from 'state/ui/selectors'; import { getSiteSlug } from 'state/sites/selectors'; +import { canCurrentUser } from 'state/selectors'; import { isPremium, isBusiness, @@ -23,7 +24,8 @@ import JetpackPluginsPanel from './jetpack-plugins-panel'; import PageViewTracker from 'lib/analytics/page-view-tracker'; import { PLAN_BUSINESS, FEATURE_UPLOAD_PLUGINS } from 'lib/plans/constants'; import Banner from 'components/banner'; -import { isATEnabled } from 'lib/automated-transfer'; +import MainComponent from 'components/main'; +import EmptyContent from 'components/empty-content'; export const PluginPanel = ( { plan, @@ -31,19 +33,34 @@ export const PluginPanel = ( { category, search, translate, - atEnabled + canUserManageOptions, } ) => { const hasBusiness = isBusiness( plan ) || isEnterprise( plan ); const hasPremium = hasBusiness || isPremium( plan ); + if ( ! canUserManageOptions ) { + const accessError = { + title: translate( 'Not Available' ), + line: translate( 'The page you requested could not be found' ), + illustration: '/calypso/images/drake/drake-404.svg', + fullWidth: true + }; + return ( + + + + ); + } + return (
- { atEnabled && ! hasBusiness && + { ! hasBusiness && @@ -63,10 +80,11 @@ export const PluginPanel = ( { const mapStateToProps = state => { const selectedSite = getSelectedSite( state ); + const selectedSiteId = getSelectedSiteId( state ); return { - atEnabled: isATEnabled( selectedSite ), plan: get( selectedSite, 'plan', {} ), - siteSlug: getSiteSlug( state, getSelectedSiteId( state ) ) + siteSlug: getSiteSlug( state, selectedSiteId ), + canUserManageOptions: canCurrentUser( state, selectedSiteId, 'manage_options' ), }; }; diff --git a/client/my-sites/plugins/access-control.js b/client/my-sites/plugins/access-control.js index 399236c61b7265..e8103594ffb760 100644 --- a/client/my-sites/plugins/access-control.js +++ b/client/my-sites/plugins/access-control.js @@ -20,14 +20,6 @@ const hasErrorCondition = ( site, type ) => { return errorConditions[ type ]; }; -const getWpcomPluginPageError = () => { - return { - title: i18n.translate( 'Oops! Not supported' ), - line: i18n.translate( 'This site doesn\'t support installing plugins. Switch to a self-hosted site to install and manage plugins' ), - illustration: '/calypso/images/drake/drake-whoops.svg' - }; -}; - const hasRestrictedAccess = ( site ) => { site = site || sites.getSelectedSite(); @@ -54,10 +46,6 @@ const hasRestrictedAccess = ( site ) => { } ); } - - if ( ! sites.hasSiteWithPlugins() ) { - return getWpcomPluginPageError(); - } }; export default { hasRestrictedAccess }; diff --git a/client/my-sites/plugins/plugin-meta/index.jsx b/client/my-sites/plugins/plugin-meta/index.jsx index 153b7f40a4d5a2..cc5af15268dd82 100644 --- a/client/my-sites/plugins/plugin-meta/index.jsx +++ b/client/my-sites/plugins/plugin-meta/index.jsx @@ -34,8 +34,8 @@ import PluginInformation from 'my-sites/plugins/plugin-information'; import WpcomPluginInstallButton from 'my-sites/plugins-wpcom/plugin-install-button'; import PluginAutomatedTransfer from 'my-sites/plugins/plugin-automated-transfer'; import { userCan } from 'lib/site/utils'; -import UpgradeNudge from 'my-sites/upgrade-nudge'; -import { FEATURE_UPLOAD_PLUGINS } from 'lib/plans/constants'; +import Banner from 'components/banner'; +import { PLAN_BUSINESS, FEATURE_UPLOAD_PLUGINS } from 'lib/plans/constants'; import { isBusiness, isEnterprise @@ -492,11 +492,11 @@ const PluginMeta = React.createClass( { { ! get( this.props.selectedSite, 'jetpack' ) && ! this.hasBusinessPlan() && ! this.isWpcomPreinstalled() &&
-
} diff --git a/client/my-sites/plugins/plugin.jsx b/client/my-sites/plugins/plugin.jsx index 51d2e8550186c2..eaa9d09039c30e 100644 --- a/client/my-sites/plugins/plugin.jsx +++ b/client/my-sites/plugins/plugin.jsx @@ -27,13 +27,11 @@ import pluginsAccessControl from 'my-sites/plugins/access-control'; import EmptyContent from 'components/empty-content'; import FeatureExample from 'components/feature-example'; import DocumentHead from 'components/data/document-head'; -import WpcomPluginsList from 'my-sites/plugins-wpcom/plugins-list'; import { getSelectedSite, getSelectedSiteId } from 'state/ui/selectors'; import { isJetpackSite, canJetpackSiteManage, getRawSite } from 'state/sites/selectors'; import { isSiteAutomatedTransfer } from 'state/selectors'; import { recordGoogleEvent } from 'state/analytics/actions'; import QuerySites from 'components/data/query-sites'; -import { isATEnabled } from 'lib/automated-transfer'; const SinglePlugin = React.createClass( { _DEFAULT_PLUGINS_BASE_PATH: 'http://wordpress.org/plugins/', @@ -320,24 +318,7 @@ const SinglePlugin = React.createClass( { render() { const { selectedSite } = this.props; - if ( - selectedSite && - ! this.props.isJetpackSite( selectedSite.ID ) && - ! this.props.atEnabled - ) { - return ( - - { this.renderDocumentHead() } - - - - ); - } - - if ( - this.state.accessError && - ( ! selectedSite || selectedSite.jetpack ) - ) { + if ( this.state.accessError ) { return ( { this.renderDocumentHead() } @@ -433,7 +414,6 @@ export default connect( selectedSite: selectedSite, isJetpackSite: siteId => isJetpackSite( state, siteId ), canJetpackSiteManage: siteId => canJetpackSiteManage( state, siteId ), - atEnabled: isATEnabled( site ), isSiteAutomatedTransfer: isSiteAutomatedTransfer( state, get( selectedSite, 'ID' ) ), }; }, diff --git a/client/my-sites/plugins/plugins-browser/index.jsx b/client/my-sites/plugins/plugins-browser/index.jsx index 6ece10bf769f5d..7944826e7d7a10 100644 --- a/client/my-sites/plugins/plugins-browser/index.jsx +++ b/client/my-sites/plugins/plugins-browser/index.jsx @@ -29,7 +29,6 @@ import { hasTouch } from 'lib/touch-detect'; import { recordTracksEvent } from 'state/analytics/actions'; import { getSelectedSite } from 'state/ui/selectors'; import { isJetpackSite, canJetpackSiteManage } from 'state/sites/selectors'; -import { isATEnabled } from 'lib/automated-transfer'; const PluginsBrowser = React.createClass( { _SHORT_LIST_LENGTH: 6, @@ -318,16 +317,7 @@ const PluginsBrowser = React.createClass( { ! this.props.canJetpackSiteManage( selectedSite.ID ) ); - if ( - ( this.state.accessError || cantManage ) && - ( - // If automated transfer is _off_ then behave - // as normal. If it's on, then only show if we - // are getting an error on a Jetpack site - ! this.props.atEnabled || - ( selectedSite && selectedSite.jetpack ) - ) - ) { + if ( ( this.state.accessError || cantManage ) && selectedSite ) { return this.renderAccessError( selectedSite ); } @@ -347,7 +337,6 @@ export default connect( const selectedSite = getSelectedSite( state ); return { selectedSite, - atEnabled: isATEnabled( selectedSite ), isJetpackSite: siteId => isJetpackSite( state, siteId ), canJetpackSiteManage: siteId => canJetpackSiteManage( state, siteId ), }; diff --git a/client/my-sites/sidebar/sidebar.jsx b/client/my-sites/sidebar/sidebar.jsx index 01869466339a28..aab047628caca4 100644 --- a/client/my-sites/sidebar/sidebar.jsx +++ b/client/my-sites/sidebar/sidebar.jsx @@ -46,7 +46,6 @@ import { isJetpackSite } from 'state/sites/selectors'; import { getStatsPathForTab } from 'lib/route/path'; -import { isATEnabled } from 'lib/automated-transfer'; import { abtest } from 'lib/abtest'; /** @@ -203,13 +202,10 @@ export class MySitesSidebar extends Component { plugins() { const { site } = this.props; + const addPluginsLink = '/plugins/browse' + this.props.siteSuffix; let pluginsLink = '/plugins' + this.props.siteSuffix; - let addPluginsLink; - - if ( this.props.atEnabled ) { - addPluginsLink = '/plugins/browse' + this.props.siteSuffix; - } + // TODO: we can probably rip this out if ( ! config.isEnabled( 'manage/plugins' ) ) { if ( ! site ) { return null; @@ -220,12 +216,14 @@ export class MySitesSidebar extends Component { } } + // checks for manage plugins capability across all sites if ( ! this.props.canManagePlugins ) { return null; } - if ( ( this.props.siteId && this.props.isJetpack ) || ( ! this.props.siteId && this.props.hasJetpackSites ) ) { - addPluginsLink = '/plugins/browse' + this.props.siteSuffix; + // if selectedSite and cannot manage, skip plugins section + if ( this.props.siteId && ! this.props.canUserManageOptions ) { + return null; } return ( @@ -257,7 +255,7 @@ export class MySitesSidebar extends Component { return null; } - if ( this.props.isJetpack && ! this.props.atEnabled ) { + if ( this.props.isJetpack && ! this.props.isSiteAutomatedTransfer ) { return null; } @@ -594,13 +592,13 @@ function mapStateToProps( state ) { const canManagePlugins = !! getSites( state ).some( ( s ) => ( ( s.capabilities && s.capabilities.manage_options ) ) ); + // FIXME: Turn into dedicated selector const hasJetpackSites = getSites( state ).some( s => s.jetpack ); const isPreviewShowing = getCurrentLayoutFocus( state ) === 'preview'; return { - atEnabled: isATEnabled( site ), canManagePlugins, canUserEditThemeOptions: canCurrentUser( state, siteId, 'edit_theme_options' ), canUserListUsers: canCurrentUser( state, siteId, 'list_users' ),