Skip to content

Commit

Permalink
Editor store: remove createUndoLevel and refreshPost actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Feb 7, 2022
1 parent 48da1d9 commit 0f95628
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 87 deletions.
13 changes: 0 additions & 13 deletions docs/reference-guides/data/data-core-editor.md
Expand Up @@ -1041,15 +1041,6 @@ _Related_

- clearSelectedBlock in core/block-editor store.

### createUndoLevel

Returns an action object used in signalling that undo history record should
be created.

_Returns_

- `Object`: Action object.

### disablePublishSidebar

Returns an action object used in signalling that the user has disabled the
Expand Down Expand Up @@ -1219,10 +1210,6 @@ _Related_
Returns an action object used in signalling that undo history should
restore last popped state.

### refreshPost

Action generator for handling refreshing the current post.

### removeBlock

_Related_
Expand Down
34 changes: 0 additions & 34 deletions packages/editor/src/store/actions.js
Expand Up @@ -279,30 +279,6 @@ export function* savePost( options = {} ) {
}
}

/**
* Action generator for handling refreshing the current post.
*/
export function* refreshPost() {
const post = yield controls.select( STORE_NAME, 'getCurrentPost' );
const postTypeSlug = yield controls.select(
STORE_NAME,
'getCurrentPostType'
);
const postType = yield controls.resolveSelect(
coreStore,
'getPostType',
postTypeSlug
);
const newPost = yield apiFetch( {
// Timestamp arg allows caller to bypass browser caching, which is
// expected for this specific function.
path:
`/wp/v2/${ postType.rest_base }/${ post.id }` +
`?context=edit&_timestamp=${ Date.now() }`,
} );
yield controls.dispatch( STORE_NAME, 'resetPost', newPost );
}

/**
* Action generator for trashing the current post in the editor.
*/
Expand Down Expand Up @@ -403,16 +379,6 @@ export function* undo() {
yield controls.dispatch( coreStore, 'undo' );
}

/**
* Returns an action object used in signalling that undo history record should
* be created.
*
* @return {Object} Action object.
*/
export function createUndoLevel() {
return { type: 'CREATE_UNDO_LEVEL' };
}

/**
* Returns an action object used to lock the editor.
*
Expand Down
40 changes: 0 additions & 40 deletions packages/editor/src/store/test/actions.js
Expand Up @@ -358,46 +358,6 @@ describe( 'Post generator actions', () => {
} );
} );
} );
describe( 'refreshPost()', () => {
let fulfillment;
const currentPost = { id: 10, content: 'foo' };
const reset = () => ( fulfillment = actions.refreshPost() );
it( 'yields expected action for selecting the currentPost', () => {
reset();
const { value } = fulfillment.next();
expect( value ).toEqual(
controls.select( STORE_NAME, 'getCurrentPost' )
);
} );
it( 'yields expected action for selecting the current post type', () => {
const { value } = fulfillment.next( currentPost );
expect( value ).toEqual(
controls.select( STORE_NAME, 'getCurrentPostType' )
);
} );
it( 'yields expected action for selecting the post type object', () => {
const { value } = fulfillment.next( postTypeSlug );
expect( value ).toEqual(
controls.resolveSelect( 'core', 'getPostType', postTypeSlug )
);
} );
it( 'yields expected action for the api fetch call', () => {
const { value } = fulfillment.next( postType );
// since the timestamp is a computed value we can't do a direct comparison.
// so we'll just see if the path has most of the value.
expect( value.request.path ).toEqual(
expect.stringContaining(
`/wp/v2/${ postType.rest_base }/${ currentPost.id }?context=edit&_timestamp=`
)
);
} );
it( 'yields expected action for dispatching the reset of the post', () => {
const { value } = fulfillment.next( currentPost );
expect( value ).toEqual(
controls.dispatch( STORE_NAME, 'resetPost', currentPost )
);
} );
} );
} );

describe( 'Editor actions', () => {
Expand Down

0 comments on commit 0f95628

Please sign in to comment.