Skip to content
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
29 changes: 20 additions & 9 deletions _inc/client/components/jetpack-notices/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import NoticesList from 'components/global-notices';
* Internal dependencies
*/
import JetpackStateNotices from './state-notices';
import { getSiteConnectionStatus, getSiteDevMode, isStaging, isInIdentityCrisis } from 'state/connection';
import { isDevVersion } from 'state/initial-state';
import { getSiteConnectionStatus, getSiteDevMode, isStaging, isInIdentityCrisis, isCurrentUserLinked } from 'state/connection';
import { isDevVersion, userCanManageModules, getUsername } from 'state/initial-state';
import DismissableNotices from './dismissable';
import { getConnectUrl as _getConnectUrl } from 'state/connection';
import QueryConnectUrl from 'components/data/query-connect-url';
Expand Down Expand Up @@ -159,15 +159,13 @@ export const UserUnlinked = React.createClass( {

render() {
if (
! window.Initial_State.userData.currentUser.isConnected &&
! this.props.isLinked &&
this.props.connectUrl &&
this.props.siteConnected
) {
let text;

text = __( 'You, %(userName)s, are not connected to WordPress.com.', {
const text = __( 'You, %(userName)s, are not connected to WordPress.com.', {
args: {
userName: window.Initial_State.userData.currentUser.username
userName: this.props.username
}
} );

Expand Down Expand Up @@ -215,7 +213,18 @@ const JetpackNotices = React.createClass( {
<DismissableNotices />
<UserUnlinked
connectUrl={ this.props.connectUrl }
siteConnected={ true === this.props.siteConnectionStatus } />
siteConnected={ true === this.props.siteConnectionStatus }
isLinked={ this.props.isLinked }
username={ this.props.username } />
{
( ! this.props.siteConnectionStatus && ! this.props.userCanManageModules ) && (
<SimpleNotice
showDismiss={ false }
status="is-warning"
text={ __( 'This site is not connected to WordPress.com. Please ask the site administrator to connect.' ) }
/>
)
}
</div>
);
}
Expand All @@ -226,11 +235,13 @@ export default connect(
return {
connectUrl: _getConnectUrl( state ),
siteConnectionStatus: getSiteConnectionStatus( state ),
userCanManageModules: userCanManageModules( state ),
username: getUsername( state ),
isLinked: isCurrentUserLinked( state ),
isDevVersion: isDevVersion( state ),
siteDevMode: getSiteDevMode( state ),
isStaging: isStaging( state ),
isInIdentityCrisis: isInIdentityCrisis( state )

};
}
)( JetpackNotices );
13 changes: 9 additions & 4 deletions _inc/client/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import SearchableSettings from 'settings/index.jsx';
import JetpackConnect from 'components/jetpack-connect';
import JumpStart from 'components/jumpstart';
import { getJumpStartStatus, isJumpstarting } from 'state/jumpstart';
import { getSiteConnectionStatus } from 'state/connection';
import { getSiteConnectionStatus, isCurrentUserLinked } from 'state/connection';
import {
setInitialState,
getSiteRawUrl,
Expand Down Expand Up @@ -116,6 +116,7 @@ const Main = React.createClass( {

return nextProps.siteConnectionStatus !== this.props.siteConnectionStatus ||
nextProps.jumpStartStatus !== this.props.jumpStartStatus ||
nextProps.isLinked !== this.props.isLinked ||
nextProps.route.path !== this.props.route.path ||
nextProps.searchTerm !== this.props.searchTerm;
},
Expand Down Expand Up @@ -154,19 +155,22 @@ const Main = React.createClass( {
analytics.tracks.recordEvent( 'jetpack_wpa_page_view', { path: route } );

if ( ! this.props.userCanManageModules ) {
return <NonAdminView { ...this.props } />
if ( ! this.props.siteConnectionStatus ) {
return false;
}
return <NonAdminView { ...this.props } />;
}

if ( ! this.props.siteConnectionStatus ) {
return <JetpackConnect />
return <JetpackConnect />;
}

if ( this.props.jumpStartStatus ) {
if ( '/' === route ) {
const history = createHistory();
history.push( window.location.pathname + '?page=jetpack#/jumpstart' );
} else if ( '/jumpstart' === route ) {
return <JumpStart />
return <JumpStart />;
}
}

Expand Down Expand Up @@ -241,6 +245,7 @@ export default connect(
jumpStartStatus: getJumpStartStatus( state ),
isJumpstarting: isJumpstarting( state ),
siteConnectionStatus: getSiteConnectionStatus( state ),
isLinked: isCurrentUserLinked( state ),
siteRawUrl: getSiteRawUrl( state ),
siteAdminUrl: getSiteAdminUrl( state ),
searchTerm: getSearchTerm( state ),
Expand Down