react-code-dataset / wp-calypso /client /state /data-layer /wpcom /activity-log /delete-credentials /index.js
react-code-dataset / wp-calypso /client /state /data-layer /wpcom /activity-log /delete-credentials /index.js
Download wp-calypso/client/state/data-layer/wpcom/activity-log/delete-credentials/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/activity-log/delete-credentials/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/data-layer/wpcom/activity-log/delete-credentials/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/activity-log/delete-credentials/index.js
1.41 kB
| import { | |
| JETPACK_CREDENTIALS_DELETE, | |
| JETPACK_CREDENTIALS_STORE, | |
| REWIND_STATE_UPDATE, | |
| } from 'calypso/state/action-types'; | |
| import { registerHandlers } from 'calypso/state/data-layer/handler-registry'; | |
| import { transformApi } from 'calypso/state/data-layer/wpcom/sites/rewind/api-transformer'; | |
| import { http } from 'calypso/state/data-layer/wpcom-http/actions'; | |
| import { dispatchRequest } from 'calypso/state/data-layer/wpcom-http/utils'; | |
| const noop = () => {}; | |
| export const request = ( action ) => | |
| http( | |
| { | |
| apiNamespace: 'wpcom/v2', | |
| method: 'POST', | |
| path: `/sites/${ action.siteId }/rewind/credentials/delete`, | |
| body: { role: action.role }, | |
| }, | |
| { ...action } | |
| ); | |
| export const success = ( { siteId }, { rewind_state } ) => { | |
| const storeAction = { | |
| type: JETPACK_CREDENTIALS_STORE, | |
| credentials: { | |
| main: null, | |
| }, | |
| siteId, | |
| }; | |
| // the API transform could fail and the rewind data might | |
| // be unavailable so if that's the case just let it go | |
| // for now. we'll improve our rigor as time goes by. | |
| try { | |
| return [ | |
| storeAction, | |
| { | |
| type: REWIND_STATE_UPDATE, | |
| siteId, | |
| data: transformApi( rewind_state ), | |
| }, | |
| ]; | |
| } catch ( e ) { | |
| return storeAction; | |
| } | |
| }; | |
| registerHandlers( 'state/data-layer/wpcom/sites/rewind/credentials/delete', { | |
| [ JETPACK_CREDENTIALS_DELETE ]: [ | |
| dispatchRequest( { | |
| fetch: request, | |
| onSuccess: success, | |
| onError: noop, | |
| } ), | |
| ], | |
| } ); | |