File size: 642 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import { createSelector } from '@automattic/state-utils';
import { get } from 'lodash';
import { canCurrentUser } from 'calypso/state/selectors/can-current-user';
/**
* Returns true if user can manage plugins for at least one site and returns false otherwise
* @param {Object} state Global state tree
* @returns {boolean} Whether the user can manage plugins or not
*/
export default createSelector(
( state ) => {
const siteIds = Object.keys( get( state, 'currentUser.capabilities', {} ) );
return siteIds.some( ( siteId ) => canCurrentUser( state, siteId, 'manage_options' ) );
},
( state ) => state.currentUser.capabilities
);
|