diff --git a/projects/plugins/jetpack/_inc/client/components/navigation-settings/index.jsx b/projects/plugins/jetpack/_inc/client/components/navigation-settings/index.jsx index d2a0116df37a0..b269d8b7df954 100644 --- a/projects/plugins/jetpack/_inc/client/components/navigation-settings/index.jsx +++ b/projects/plugins/jetpack/_inc/client/components/navigation-settings/index.jsx @@ -106,7 +106,7 @@ export const NavigationSettings = createReactClass( { }, render: function () { - let navItems, sharingTab; + let navItems, sharingTab, writingTab; if ( this.props.userCanManageModules ) { navItems = ( @@ -192,6 +192,7 @@ export const NavigationSettings = createReactClass( { } else if ( this.props.isSubscriber ) { navItems = false; } else { + // Show a sharing tab if the Publicize module is active and the user can publish. if ( ! this.props.isModuleActivated( 'publicize' ) || ! this.props.userCanPublish ) { sharingTab = ''; } else { @@ -199,30 +200,34 @@ export const NavigationSettings = createReactClass( { { _x( 'Sharing', 'Navigation item.', 'jetpack' ) } ); } + + // Show a Writing tab if the Post By Email module is active and the user can publish. + if ( ! this.props.isModuleActivated( 'post-by-email' ) || ! this.props.userCanPublish ) { + writingTab = ''; + } else { + writingTab = this.props.hasAnyOfTheseModules( [ 'post-by-email' ] ) && ( + + { _x( 'Writing', 'Navigation item.', 'jetpack' ) } + + ); + } navItems = ( - { this.props.hasAnyOfTheseModules( [ 'post-by-email' ] ) && ( - - { _x( 'Writing', 'Navigation item.', 'jetpack' ) } - - ) } - { - // Give only Publicize to non admin users - sharingTab - } + { writingTab } + { sharingTab } ); } diff --git a/projects/plugins/jetpack/_inc/client/settings/index.jsx b/projects/plugins/jetpack/_inc/client/settings/index.jsx index 119d7fd4a1b32..db953b16b1c29 100644 --- a/projects/plugins/jetpack/_inc/client/settings/index.jsx +++ b/projects/plugins/jetpack/_inc/client/settings/index.jsx @@ -1,11 +1,10 @@ /** * External dependencies - * - * @format */ - import React from 'react'; import { __, sprintf } from '@wordpress/i18n'; +import { connect } from 'react-redux'; +import { withRouter } from 'react-router-dom'; /** * Internal dependencies @@ -18,71 +17,87 @@ import Security from 'security'; import Sharing from 'sharing'; import Traffic from 'traffic'; import Writing from 'writing'; -import { withRouter } from 'react-router-dom'; +import { isModuleActivated as isModuleActivatedSelector } from 'state/modules'; class Settings extends React.Component { static displayName = 'SearchableSettings'; render() { + const { + location = { pathname: '' }, + rewindStatus, + searchTerm, + siteAdminUrl, + siteRawUrl, + userCanManageModules, + } = this.props; + const { pathname } = location; const commonProps = { - searchTerm: this.props.searchTerm, - rewindStatus: this.props.rewindStatus, - userCanManageModules: this.props.userCanManageModules, + searchTerm, + rewindStatus, + userCanManageModules, }; return (
- { commonProps.searchTerm + { searchTerm ? sprintf( /* translators: placeholder is a searchterm entered in searchform. */ __( 'No search results found for %s', 'jetpack' ), - commonProps.searchTerm + searchTerm ) : __( 'Enter a search term to find settings or close search.', 'jetpack' ) }
- + - - + +
); } } -export default withRouter( Settings ); +export default connect( state => { + return { + isModuleActivated: module => isModuleActivatedSelector( state, module ), + }; +} )( withRouter( Settings ) );