react-code-dataset / wp-calypso /client /state /data-layer /wpcom /sites /rewind /capabilities /index.js
react-code-dataset / wp-calypso /client /state /data-layer /wpcom /sites /rewind /capabilities /index.js
Download wp-calypso/client/state/data-layer/wpcom/sites/rewind/capabilities/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/sites/rewind/capabilities/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/data-layer/wpcom/sites/rewind/capabilities/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/sites/rewind/capabilities/index.js
1.02 kB
| import { | |
| REWIND_CAPABILITIES_REQUEST, | |
| REWIND_CAPABILITIES_UPDATE, | |
| } from 'calypso/state/action-types'; | |
| import { registerHandlers } from 'calypso/state/data-layer/handler-registry'; | |
| import { http } from 'calypso/state/data-layer/wpcom-http/actions'; | |
| import { dispatchRequest } from 'calypso/state/data-layer/wpcom-http/utils'; | |
| const fetchCapabilities = ( action ) => | |
| http( | |
| { | |
| apiNamespace: 'wpcom/v2', | |
| method: 'GET', | |
| path: `/sites/${ action.siteId }/rewind/capabilities`, | |
| query: { | |
| force: 'wpcom', | |
| }, | |
| }, | |
| action | |
| ); | |
| const updateCapabilities = ( { siteId }, data ) => { | |
| return { | |
| type: REWIND_CAPABILITIES_UPDATE, | |
| siteId, | |
| data: data.capabilities, | |
| }; | |
| }; | |
| const onError = ( { siteId } ) => { | |
| return { | |
| type: REWIND_CAPABILITIES_UPDATE, | |
| siteId, | |
| data: [], | |
| }; | |
| }; | |
| registerHandlers( 'state/data-layer/wpcom/sites/rewind/capabilities', { | |
| [ REWIND_CAPABILITIES_REQUEST ]: [ | |
| dispatchRequest( { | |
| fetch: fetchCapabilities, | |
| onSuccess: updateCapabilities, | |
| onError, | |
| } ), | |
| ], | |
| } ); | |