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

Projects
None yet
4 participants
@danielbachhuber
Member

danielbachhuber commented May 21, 2018

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 WordPress/gutenberg-core May 21, 2018

@pento

pento approved these changes May 22, 2018

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 ) {

This comment has been minimized.

@pento

pento May 22, 2018

Member

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

This comment has been minimized.

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

This comment has been minimized.

@pento

pento May 22, 2018

Member

Description should be updated to match the new behaviour.

This comment has been minimized.

@danielbachhuber

@danielbachhuber danielbachhuber merged commit 8c708bc into master May 22, 2018

2 checks passed

codecov/project Absolute coverage decreased by -0.01% but relative coverage increased by +53.56% compared to e245ea2
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@danielbachhuber danielbachhuber deleted the 4555-preview-link branch May 22, 2018

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

This comment has been minimized.

@gziolo

gziolo May 22, 2018

Member

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

This comment has been minimized.

@mtias

mtias May 22, 2018

Contributor

Can you make an issue for this?

This comment has been minimized.

@danielbachhuber

This comment has been minimized.

@danielbachhuber
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment