Skip to content

Commit

Permalink
Swith constant name from MODULE_KEY to STORE_KEY
Browse files Browse the repository at this point in the history
  • Loading branch information
nerrad committed Feb 28, 2019
1 parent ff70f2b commit 1c11a5b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
38 changes: 19 additions & 19 deletions packages/editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
apiFetch,
} from './controls';
import {
MODULE_KEY,
STORE_KEY,
POST_UPDATE_TRANSACTION_ID,
SAVE_POST_NOTICE_ID,
TRASH_POST_NOTICE_ID,
Expand Down Expand Up @@ -222,14 +222,14 @@ export function __experimentalOptimisticUpdatePost( edits ) {
*/
export function* savePost( options = {} ) {
const isEditedPostSaveable = yield select(
MODULE_KEY,
STORE_KEY,
'isEditedPostSaveable'
);
if ( ! isEditedPostSaveable ) {
return;
}
let edits = yield select(
MODULE_KEY,
STORE_KEY,
'getPostEdits'
);
const isAutosave = !! options.isAutosave;
Expand All @@ -239,7 +239,7 @@ export function* savePost( options = {} ) {
}

const isEditedPostNew = yield select(
MODULE_KEY,
STORE_KEY,
'isEditedPostNew',
);

Expand All @@ -259,12 +259,12 @@ export function* savePost( options = {} ) {
}

const post = yield select(
MODULE_KEY,
STORE_KEY,
'getCurrentPost'
);

const editedPostContent = yield select(
MODULE_KEY,
STORE_KEY,
'getEditedPostContent'
);

Expand All @@ -275,7 +275,7 @@ export function* savePost( options = {} ) {
};

const currentPostType = yield select(
MODULE_KEY,
STORE_KEY,
'getCurrentPostType'
);

Expand All @@ -286,7 +286,7 @@ export function* savePost( options = {} ) {
);

yield dispatch(
MODULE_KEY,
STORE_KEY,
'__experimentalRequestPostUpdateStart',
options,
);
Expand All @@ -295,7 +295,7 @@ export function* savePost( options = {} ) {
// will be updated. See below logic in success resolution for revert
// if the autosave is applied as a revision.
yield dispatch(
MODULE_KEY,
STORE_KEY,
'__experimentalOptimisticUpdatePost',
toSend
);
Expand All @@ -304,7 +304,7 @@ export function* savePost( options = {} ) {
let method = 'PUT';
if ( isAutosave ) {
const autoSavePost = yield select(
MODULE_KEY,
STORE_KEY,
'getAutosave',
);
// Ensure autosaves contain all expected fields, using autosave or
Expand Down Expand Up @@ -337,10 +337,10 @@ export function* savePost( options = {} ) {
} );
const resetAction = isAutosave ? 'resetAutosave' : 'resetPost';

yield dispatch( MODULE_KEY, resetAction, newPost );
yield dispatch( STORE_KEY, resetAction, newPost );

yield dispatch(
MODULE_KEY,
STORE_KEY,
'__experimentalRequestPostUpdateSuccess',
{
previousPost: post,
Expand Down Expand Up @@ -369,7 +369,7 @@ export function* savePost( options = {} ) {
}
} catch ( error ) {
yield dispatch(
MODULE_KEY,
STORE_KEY,
'__experimentalRequestPostUpdateFailure',
{ post, edits, error, options }
);
Expand All @@ -393,11 +393,11 @@ export function* savePost( options = {} ) {
*/
export function* refreshPost() {
const post = yield select(
MODULE_KEY,
STORE_KEY,
'getCurrentPost'
);
const postTypeSlug = yield select(
MODULE_KEY,
STORE_KEY,
'getCurrentPostType'
);
const postType = yield resolveSelect(
Expand All @@ -414,7 +414,7 @@ export function* refreshPost() {
}
);
yield dispatch(
MODULE_KEY,
STORE_KEY,
'resetPost',
newPost
);
Expand All @@ -425,7 +425,7 @@ export function* refreshPost() {
*/
export function* trashPost() {
const postTypeSlug = yield select(
MODULE_KEY,
STORE_KEY,
'getCurrentPostType'
);
const postType = yield resolveSelect(
Expand All @@ -440,7 +440,7 @@ export function* trashPost() {
);
try {
const post = yield select(
MODULE_KEY,
STORE_KEY,
'getCurrentPost'
);
yield apiFetch(
Expand All @@ -453,7 +453,7 @@ export function* trashPost() {
// TODO: This should be an updatePost action (updating subsets of post
// properties), but right now editPost is tied with change detection.
yield dispatch(
MODULE_KEY,
STORE_KEY,
'resetPost',
{ ...post, status: 'trash' }
);
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/store/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const EDIT_MERGE_PROPERTIES = new Set( [
* Constant for the store module (or reducer) key.
* @type {string}
*/
export const MODULE_KEY = 'core/editor';
export const STORE_KEY = 'core/editor';

export const POST_UPDATE_TRANSACTION_ID = 'post-update';
export const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID';
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import applyMiddlewares from './middlewares';
import * as selectors from './selectors';
import * as actions from './actions';
import controls from './controls';
import { MODULE_KEY } from './constants';
import { STORE_KEY } from './constants';

const store = registerStore( MODULE_KEY, {
const store = registerStore( STORE_KEY, {
reducer,
selectors,
actions,
Expand Down
40 changes: 20 additions & 20 deletions packages/editor/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { BEGIN, COMMIT, REVERT } from 'redux-optimist';
import generatorActions, * as actions from '../actions';
import { select, dispatch, apiFetch, resolveSelect } from '../controls';
import {
MODULE_KEY,
STORE_KEY,
SAVE_POST_NOTICE_ID,
TRASH_POST_NOTICE_ID,
POST_UPDATE_TRANSACTION_ID,
Expand Down Expand Up @@ -152,7 +152,7 @@ describe( 'Post generator actions', () => {
reset( isAutosave );
const { value } = fulfillment.next();
expect( value ).toEqual(
select( MODULE_KEY, 'isEditedPostSaveable' )
select( STORE_KEY, 'isEditedPostSaveable' )
);
},
],
Expand All @@ -162,7 +162,7 @@ describe( 'Post generator actions', () => {
() => {
const { value } = fulfillment.next( true );
expect( value ).toEqual(
select( MODULE_KEY, 'getPostEdits' )
select( STORE_KEY, 'getPostEdits' )
);
},
],
Expand All @@ -172,7 +172,7 @@ describe( 'Post generator actions', () => {
() => {
const { value } = fulfillment.next( edits() );
expect( value ).toEqual(
select( MODULE_KEY, 'isEditedPostNew' )
select( STORE_KEY, 'isEditedPostNew' )
);
},
],
Expand All @@ -182,7 +182,7 @@ describe( 'Post generator actions', () => {
() => {
const { value } = fulfillment.next( isEditedPostNew );
expect( value ).toEqual(
select( MODULE_KEY, 'getCurrentPost' )
select( STORE_KEY, 'getCurrentPost' )
);
},
],
Expand All @@ -192,7 +192,7 @@ describe( 'Post generator actions', () => {
() => {
const { value } = fulfillment.next( currentPost() );
expect( value ).toEqual(
select( MODULE_KEY, 'getEditedPostContent' )
select( STORE_KEY, 'getEditedPostContent' )
);
},
],
Expand All @@ -202,7 +202,7 @@ describe( 'Post generator actions', () => {
() => {
const { value } = fulfillment.next( editedPostContent );
expect( value ).toEqual(
select( MODULE_KEY, 'getCurrentPostType' )
select( STORE_KEY, 'getCurrentPostType' )
);
},
],
Expand All @@ -223,7 +223,7 @@ describe( 'Post generator actions', () => {
const { value } = fulfillment.next( postType );
expect( value ).toEqual(
dispatch(
MODULE_KEY,
STORE_KEY,
'__experimentalRequestPostUpdateStart',
{ isAutosave }
)
Expand All @@ -237,7 +237,7 @@ describe( 'Post generator actions', () => {
const { value } = fulfillment.next();
expect( value ).toEqual(
dispatch(
MODULE_KEY,
STORE_KEY,
'__experimentalOptimisticUpdatePost',
editPostToSendOptimistic()
)
Expand Down Expand Up @@ -279,7 +279,7 @@ describe( 'Post generator actions', () => {
const { value } = fulfillment.next();
expect( value ).toEqual(
select(
MODULE_KEY,
STORE_KEY,
'getAutosave'
)
);
Expand All @@ -301,7 +301,7 @@ describe( 'Post generator actions', () => {
}
expect( value ).toEqual(
dispatch(
MODULE_KEY,
STORE_KEY,
'__experimentalRequestPostUpdateFailure',
{
post: currentPost(),
Expand Down Expand Up @@ -359,7 +359,7 @@ describe( 'Post generator actions', () => {
const { value } = fulfillment.next( savedPost() );
expect( value ).toEqual(
dispatch(
MODULE_KEY,
STORE_KEY,
isAutosave ? 'resetAutosave' : 'resetPost',
savedPost()
)
Expand All @@ -372,7 +372,7 @@ describe( 'Post generator actions', () => {
const { value } = fulfillment.next();
expect( value ).toEqual(
dispatch(
MODULE_KEY,
STORE_KEY,
'__experimentalRequestPostUpdateSuccess',
{
previousPost: currentPost(),
Expand Down Expand Up @@ -428,7 +428,7 @@ describe( 'Post generator actions', () => {
reset( false );
const { value } = fulfillment.next();
expect( value ).toEqual(
select( MODULE_KEY, 'isEditedPostSaveable' )
select( STORE_KEY, 'isEditedPostSaveable' )
);
} );
it( 'if edited post is not saveable then bails', () => {
Expand Down Expand Up @@ -518,7 +518,7 @@ describe( 'Post generator actions', () => {
reset();
const { value } = fulfillment.next();
expect( value ).toEqual( select(
MODULE_KEY,
STORE_KEY,
'getCurrentPostType',
) );
}
Expand All @@ -543,7 +543,7 @@ describe( 'Post generator actions', () => {
it( 'yields expected action for selecting the currentPost', () => {
const { value } = fulfillment.next();
expect( value ).toEqual( select(
MODULE_KEY,
STORE_KEY,
'getCurrentPost'
) );
} );
Expand Down Expand Up @@ -575,7 +575,7 @@ describe( 'Post generator actions', () => {
it( 'yields expected dispatch action for resetting the post', () => {
const { value } = fulfillment.next();
expect( value ).toEqual( dispatch(
MODULE_KEY,
STORE_KEY,
'resetPost',
{ ...currentPost, status: 'trash' }
) );
Expand All @@ -590,14 +590,14 @@ describe( 'Post generator actions', () => {
reset();
const { value } = fulfillment.next();
expect( value ).toEqual( select(
MODULE_KEY,
STORE_KEY,
'getCurrentPost',
) );
} );
it( 'yields expected action for selecting the current post type', () => {
const { value } = fulfillment.next( currentPost );
expect( value ).toEqual( select(
MODULE_KEY,
STORE_KEY,
'getCurrentPostType'
) );
} );
Expand All @@ -621,7 +621,7 @@ describe( 'Post generator actions', () => {
it( 'yields expected action for dispatching the reset of the post', () => {
const { value } = fulfillment.next( currentPost );
expect( value ).toEqual( dispatch(
MODULE_KEY,
STORE_KEY,
'resetPost',
currentPost
) );
Expand Down

0 comments on commit 1c11a5b

Please sign in to comment.