File size: 1,169 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import {
EDITOR_TYPE_REQUEST,
EDITOR_TYPE_SET,
GUTENBERG_IFRAME_ELIGIBLE_SET,
} 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';
import 'calypso/state/gutenberg-iframe-eligible/init';
const noop = () => {};
const fetchGutenbergOptInData = ( action ) =>
http(
{
method: 'GET',
path: `/sites/${ action.siteId }/gutenberg`,
apiNamespace: 'wpcom/v3',
},
action
);
const setGutenbergOptInData =
( { siteId }, { editor_web: editor, eligible_gutenframe: isEligibleForGutenframe } ) =>
( dispatch ) => {
dispatch( { type: EDITOR_TYPE_SET, siteId, editor } );
dispatch( { type: GUTENBERG_IFRAME_ELIGIBLE_SET, siteId, isEligibleForGutenframe } );
};
const dispatchFetchGutenbergOptInData = dispatchRequest( {
fetch: fetchGutenbergOptInData,
onSuccess: setGutenbergOptInData,
onError: noop,
} );
registerHandlers( 'state/data-layer/wpcom/sites/gutenberg/index.js', {
[ EDITOR_TYPE_REQUEST ]: [ dispatchFetchGutenbergOptInData ],
} );
|