Skip to content

Commit

Permalink
Admin Page: ensure user caps are available when picking active… (#13689)
Browse files Browse the repository at this point in the history
Follow-up from #13541

We need to make sure this.props.userCanManageModules is available before we use it.
  • Loading branch information
jeherve authored Oct 11, 2019
1 parent 0300564 commit 70ba68d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions _inc/client/components/non-admin-view/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { connect } from 'react-redux';
* Internal dependencies
*/
import {
userCanManageModules,
userCanViewStats as _userCanViewStats,
userIsSubscriber as _userIsSubscriber,
} from 'state/initial-state';
Expand Down Expand Up @@ -47,6 +48,7 @@ class NonAdminView extends React.Component {
siteAdminUrl={ this.props.siteAdminUrl }
siteRawUrl={ this.props.siteRawUrl }
searchTerm={ this.props.searchTerm }
userCanManageModules={ this.props.userCanManageModules }
/>
);
}
Expand Down Expand Up @@ -80,5 +82,6 @@ export default connect( state => {
siteConnectionStatus: getSiteConnectionStatus( state ),
isSubscriber: _userIsSubscriber( state ),
isModuleActivated: module_name => _isModuleActivated( state, module_name ),
userCanManageModules: userCanManageModules( state ),
};
} )( NonAdminView );
1 change: 1 addition & 0 deletions _inc/client/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class Main extends React.Component {
siteRawUrl={ this.props.siteRawUrl }
searchTerm={ this.props.searchTerm }
rewindStatus={ this.props.rewindStatus }
userCanManageModules={ this.props.userCanManageModules }
/>
);
break;
Expand Down
5 changes: 3 additions & 2 deletions _inc/client/settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class extends React.Component {
route: this.props.route,
searchTerm: this.props.searchTerm,
rewindStatus: this.props.rewindStatus,
userCanManageModules: this.props.userCanManageModules,
};

return (
Expand All @@ -45,7 +46,7 @@ export default class extends React.Component {
siteRawUrl={ this.props.siteRawUrl }
active={
'/security' === this.props.route.path ||
( '/settings' === this.props.route.path && this.props.userCanManageModules )
( '/settings' === this.props.route.path && commonProps.userCanManageModules )
}
{ ...commonProps }
/>
Expand All @@ -65,7 +66,7 @@ export default class extends React.Component {
siteAdminUrl={ this.props.siteAdminUrl }
active={
'/writing' === this.props.route.path ||
( '/settings' === this.props.route.path && ! this.props.userCanManageModules )
( '/settings' === this.props.route.path && ! commonProps.userCanManageModules )
}
{ ...commonProps }
/>
Expand Down

0 comments on commit 70ba68d

Please sign in to comment.