Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable save draft button for posts with custom post status #63293

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading