Download wp-calypso/client/state/selectors/can-current-user-manage-plugins.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 642 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/can-current-user-manage-plugins.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/selectors/can-current-user-manage-plugins.js
-
curl -L -o can-current-user-manage-plugins.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/can-current-user-manage-plugins.js
642 Bytes
| 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 | |
| ); | |