Skip to content

Commit

Permalink
Remove getEditedPostStatus selector
Browse files Browse the repository at this point in the history
In favor of direct `getEditedPostAttribute( state, 'status' )`
  • Loading branch information
aduth committed Jun 2, 2017
1 parent 6f8b9de commit db75748
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 45 deletions.
13 changes: 1 addition & 12 deletions editor/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,6 @@ export function getEditedPostAttribute( state, attributeName ) {
: state.editor.edits[ attributeName ];
}

/**
* Returns the current status of the post being edited, preferring the unsaved
* value if different than the saved post.
*
* @param {Object} state Global application state
* @return {String} Post status
*/
export function getEditedPostStatus( state ) {
return getEditedPostAttribute( state, 'status' );
}

/**
* Returns the current visibility of the post being edited, preferring the
* unsaved value if different than the saved post. The return value is one of
Expand All @@ -129,7 +118,7 @@ export function getEditedPostStatus( state ) {
* @return {String} Post visiblity
*/
export function getEditedPostVisibility( state ) {
const status = getEditedPostStatus( state );
const status = getEditedPostAttribute( state, 'status' );
const password = getEditedPostAttribute( state, 'password' );

if ( status === 'private' ) {
Expand Down
4 changes: 2 additions & 2 deletions editor/sidebar/post-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import './style.scss';
import PostVisibility from '../post-visibility';
import PostTrash from '../post-trash';
import PostSchedule from '../post-schedule';
import { getEditedPostStatus, getSuggestedPostFormat } from '../../selectors';
import { getEditedPostAttribute, getSuggestedPostFormat } from '../../selectors';
import { editPost } from '../../actions';

class PostStatus extends Component {
Expand Down Expand Up @@ -71,7 +71,7 @@ PostStatus.instances = 1;

export default connect(
( state ) => ( {
status: getEditedPostStatus( state ),
status: getEditedPostAttribute( state, 'status' ),
suggestedFormat: getSuggestedPostFormat( state ),
} ),
( dispatch ) => {
Expand Down
3 changes: 1 addition & 2 deletions editor/sidebar/post-visibility/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Component } from 'element';
import './style.scss';
import {
getEditedPostAttribute,
getEditedPostStatus,
getEditedPostVisibility,
} from '../../selectors';
import { editPost } from '../../actions';
Expand Down Expand Up @@ -124,7 +123,7 @@ class PostVisibility extends Component {

export default connect(
( state ) => ( {
status: getEditedPostStatus( state ),
status: getEditedPostAttribute( state, 'status' ),
visibility: getEditedPostVisibility( state ),
password: getEditedPostAttribute( state, 'password' ),
} ),
Expand Down
29 changes: 0 additions & 29 deletions editor/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
isEditedPostDirty,
getCurrentPost,
getPostEdits,
getEditedPostStatus,
getEditedPostTitle,
getEditedPostExcerpt,
getEditedPostVisibility,
Expand Down Expand Up @@ -195,34 +194,6 @@ describe( 'selectors', () => {
} );
} );

describe( 'getEditedPostStatus', () => {
it( 'should return the post saved status if the status is not edited', () => {
const state = {
currentPost: {
status: 'draft',
},
editor: {
edits: { title: 'chicken' },
},
};

expect( getEditedPostStatus( state ) ).to.equal( 'draft' );
} );

it( 'should return the edited status', () => {
const state = {
currentPost: {
status: 'draft',
},
editor: {
edits: { status: 'pending' },
},
};

expect( getEditedPostStatus( state ) ).to.equal( 'pending' );
} );
} );

describe( 'getEditedPostTitle', () => {
it( 'should return the post saved title if the title is not edited', () => {
const state = {
Expand Down

0 comments on commit db75748

Please sign in to comment.