Skip to content

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

Merged
danielbachhuber merged 3 commits intomasterfrom
4555-preview-link
May 22, 2018
Merged

Expose preview_link through the REST API and use within client#6882
danielbachhuber merged 3 commits intomasterfrom
4555-preview-link

Conversation

@danielbachhuber
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

4 participants