Skip to content

Commit

Permalink
Enable save draft button for posts with custom post status (#63293)
Browse files Browse the repository at this point in the history
Unlinked contributors: agapetry.

Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: jorgefilipecosta <[email protected]>
  • Loading branch information
4 people authored Jul 9, 2024
1 parent 4c93cf2 commit f78fccd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/editor/src/components/post-saved-state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
/**
* Internal dependencies
*/
import { STATUS_OPTIONS } from '../../components/post-status';
import { store as editorStore } from '../../store';

/**
Expand Down Expand Up @@ -104,10 +105,19 @@ export default function PostSavedState( { forceIsDirty } ) {
return null;
}

// We shouldn't render the button if the post has not one of the following statuses: pending, draft, auto-draft.
// The reason for this is that this button handles the `save as pending` and `save draft` actions.
// An exception for this is when the post has a custom status and there should be a way to save changes without
// having to publish. This should be handled better in the future when custom statuses have better support.
// @see https://github.com/WordPress/gutenberg/issues/3144.
const isIneligibleStatus =
! [ 'pending', 'draft', 'auto-draft' ].includes( postStatus ) &&
STATUS_OPTIONS.map( ( { value } ) => value ).includes( postStatus );

if (
isPublished ||
isScheduled ||
! [ 'pending', 'draft', 'auto-draft' ].includes( postStatus ) ||
isIneligibleStatus ||
( postStatusHasChanged &&
[ 'pending', 'draft' ].includes( postStatus ) )
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/post-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const labels = {
publish: __( 'Published' ),
};

const STATUS_OPTIONS = [
export const STATUS_OPTIONS = [
{
label: (
<>
Expand Down

0 comments on commit f78fccd

Please sign in to comment.