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

Expose preview_link through the REST API and use within client #6882

Merged
merged 3 commits into from
May 22, 2018

Conversation

danielbachhuber
Copy link
Member

Description

Exposes a preview_link value for Posts through the REST API, and then references this value when generating the "Preview" button.

Fixes #4555
Related https://core.trac.wordpress.org/ticket/44180

How has this been tested?

Manually verified the correct link is displayed when a post is in draft vs. publish:

image

image

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@danielbachhuber danielbachhuber added this to the 3.0 milestone May 21, 2018
@danielbachhuber danielbachhuber requested a review from a team May 21, 2018 22:59
Copy link
Member

@pento pento left a comment

Choose a reason for hiding this comment

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

A couple of minor tweaks, but 👍🏻once they're done.

@@ -354,12 +353,11 @@ export function getEditedPostExcerpt( state ) {
* @return {string} Preview URL.
*/
export function getEditedPostPreviewLink( state ) {
Copy link
Member

Choose a reason for hiding this comment

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

This could be simplified further, see getCurrentPostId() for an example.

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -1068,11 +1068,11 @@ describe( 'selectors', () => {
it( 'should return the correct url adding a preview parameter to the query string', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Description should be updated to match the new behaviour.

Copy link
Member Author

Choose a reason for hiding this comment

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

@danielbachhuber danielbachhuber merged commit 8c708bc into master May 22, 2018
@danielbachhuber danielbachhuber deleted the 4555-preview-link branch May 22, 2018 03:31
}

return addQueryArgs( link, { preview: 'true' } );
return getCurrentPost( state ).preview_link || null;
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to use getEditedPostAttribute( 'preview_link' ) so we could get rid of getCurrentPost at some point.

Copy link
Member

Choose a reason for hiding this comment

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

Can you make an issue for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Doing PR

Copy link
Member Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants