-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Show "Publish: Immediately" for new drafts by inferring floating date #9967
Conversation
Move logic to determine whether a post should be considered to have a floating date from the PostScheduleLabel component into a new selector isEditedPostDateFloating.
@youknowriad I have added a commit to introduce a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update, Code looks good, I'll just do some testing a bit after (unless someone beats me to it) and approve.
dateI18n( settings.formats.datetime, date ) : | ||
__( 'Immediately' ); | ||
} | ||
|
||
export default withSelect( ( select ) => { | ||
return { | ||
date: select( 'core/editor' ).getEditedPostAttribute( 'date' ), | ||
floating: select( 'core/editor' ).isEditedPostDateFloating(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: maybe isFloating to clarify that it's a boolean?
Good point about the property naming, I have made that change 👍 |
* | ||
* @return {boolean} Whether the edited post has a floating date value. | ||
*/ | ||
export function isEditedPostDateFloating( state ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect this new selector to generate some changes in the docs if you run npm run docs:build
. Can you commit these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect this new selector to generate some changes in the docs if you run
npm run docs:build
. Can you commit these changes?
This was never done and there are local changes to commit on master after running the command.
Please review #10234
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😬 my bad, @aduth , hadn't had time to circle back to this and had missed that piece of feedback. I'll know for next time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries @kadamwhite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thanks for the work here @kadamwhite. |
Description
This addresses the post date label issue described in #7195 with an alternative to the previously-proposed solution in PR #8395.
Rather than forcing a new property into the API to work around the nuances of how dates are stored in the database, we can use what @earnjam and @TimothyBJacobs proposed in https://core.trac.wordpress.org/ticket/39953 and infer that a post's date is "floating" (i.e. that it should be published immediately) by comparing the date modified to the listed publish date. In that Trac thread @TimothyBJacobs explained,
Note that this works in Gutenberg because on save, we only send back values which have been edited. To fully address this issue throughout WordPress, changes will be needed in Trac to ensure that we apply the same logic when preparing posts to be saved to the database.
How has this been tested?
I created this patch with @earnjam at the WCNYC contributor day, and I have tested it by creating several posts to ensure various combinations of draft and auto-draft correctly reflect manually-specified dates and the Immediately placeholder. To reproduce these tests,
Screenshots
Types of changes
Bug fix for PostScheduleLabel component.
Adds unit tests for PostScheduleLabel component.
Checklist: