Skip to content

Fix schedule and then publish flow#11013

Merged
oandregal merged 12 commits intomasterfrom
fix/schedule-past-date
Oct 25, 2018
Merged

Fix schedule and then publish flow#11013
oandregal merged 12 commits intomasterfrom
fix/schedule-past-date

Conversation

@oandregal
Copy link
Copy Markdown
Member

Fixes #10930

There was a bug that happened when:

- a post was scheduled for a future date from now
- then the data changed to a past date from now

At this point, the post couldn't be published directly
by clicking the "Publish" button. This component
would show the post-publish panel with a "Post scheduled" status.
@oandregal oandregal self-assigned this Oct 24, 2018
@oandregal oandregal added [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release labels Oct 24, 2018
@oandregal oandregal added this to the 4.2 milestone Oct 24, 2018
@oandregal oandregal added the [Status] In Progress Tracking issues with work in progress label Oct 24, 2018
};
}

static getDerivedStateFromProps( props, state ) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@oandregal oandregal changed the title Fix schedule / publish flow Fix schedule and then publish flow Oct 24, 2018
Copy link
Copy Markdown
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great! When I test this locally I'm unable to reproduce the bug by following the steps in #10930.

Thanks for adding unit tests and for simplifying PostPublishPanel. It's a lot easier to understand how the component works now that there's no state 😍🌈

I left some minor comments which should be fixed up before merging. Giving you the 👍 though so that you're not blocked on me re-reviewing.

} = select( 'core/editor' );
const { isPublishSidebarEnabled } = select( 'core/editor' );
return {
postType: getCurrentPostType(),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, was a leftover.

isPublished: isCurrentPostPublished(),
isScheduled: isCurrentPostScheduled(),
isSaving: isSavingPost(),
isBeingScheduled: isEditedPostBeingScheduled(),
Copy link
Copy Markdown
Member Author

@oandregal oandregal Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the component, we were using only isScheduled to determine whether a post is scheduled, but we also need to take into account whether the date scheduled is > now (which is what isBeingScheduled does).

if (
state.submitted ||
props.isSaving ||
( ! props.isPublished && ! props.isScheduled )
Copy link
Copy Markdown
Member Author

@oandregal oandregal Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic wasn't accounting for the fact that an user can:

  • schedule a post with a date in the future
  • change its mind and modify the date to be in the past

After the second step, the user should be able to publish directly but wasn't.

@oandregal
Copy link
Copy Markdown
Member Author

When I test this locally I'm unable to reproduce the bug by following the steps in #10930.

mmm, I could repro that the bug exists and that this PR fixes it.

Giving you the +1 though so that you're not blocked on me re-reviewing.

ha, Australia-Spain connection, antipodean collaboration, the best kind of async! ⌚ 🌏

@oandregal oandregal merged commit 09a9f8e into master Oct 25, 2018
@oandregal oandregal deleted the fix/schedule-past-date branch October 25, 2018 08:27
@noisysocks
Copy link
Copy Markdown
Member

mmm, I could repro that the bug exists and that this PR fixes it

Yes, to clarify, I meant that I could not reproduce the bug when running this branch which fixes it 😀

antpb pushed a commit to antpb/gutenberg that referenced this pull request Oct 26, 2018
* Use props instead of derived state to render the component.

There was a bug that happened when:

- a post was scheduled for a future date from now
- then the data changed to a past date from now

At this point, the post couldn't be published directly
by clicking the "Publish" button. This component
would show the post-publish panel with a "Post scheduled" status.

* Test: check that pre-publish panel is shown

* Test: check that post-publish panel is shown if post is published

* Test: check that post-publish panel is shown if post is scheduled

* Test: isScheduled is true, but isBeingScheduled false

Although the post status is 'future', the data is before now,
so we should show the pre-publish panel with the Publish button.

* Fix isSaving logic

* Update snapshots

* Test: check that spinner is shown if post is being saved

* Remove unused prop

* Name spinner component so snapshot test is more semantic

* Fix typo

* Update snapshot
@mtias mtias added the [Feature] Document Settings Document settings experience label Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Document Settings Document settings experience [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants