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

Reusable blocks: Don't show trashed blocks in the editor or frontend #12345

Merged
merged 1 commit into from Nov 28, 2018

Conversation

Projects
None yet
4 participants
@noisysocks
Copy link
Member

noisysocks commented Nov 27, 2018

Fixes #12339.

Changes the logic surrounding reusable blocks so that we:

  • Do not render a reusable block in the editor if it is trashed.
  • Do not render a reusable block on the frontend if it is non-published or password protected.

This matches one's intuition about what Trashing something does.

Testing

  1. Create a new post
  2. Insert a block
  3. Convert the block to a reusable block
  4. Go to Manage All Reusable Blocks
  5. Trash the reusable block you created
  6. Go back to the post you created. The reusable block should appear as Deleted or unavailable
  7. Preview the post. The reusable block should not appear
}

const results = compact( map( posts, ( post ) => {
if ( post.status === 'trash' ) {

This comment has been minimized.

@youknowriad

youknowriad Nov 27, 2018

Contributor

Should we match the check in the backend (status publish and no password)?

This comment has been minimized.

@noisysocks

noisysocks Nov 27, 2018

Member

My thought was that having it this way would allow for some advanced functionality, e.g. marking a reusable block as private means that it becomes an editor only block.

After considering it some more, I think you're right. Let's keep it simple for now and we can enable more advanced functionality in future releases if needed.

I've updated the check.

@noisysocks noisysocks force-pushed the fix/trashed-reusable-blocks branch from 8ab2fcb to db47db0 Nov 27, 2018

Reusable blocks: Don't show trashed blocks in the editor or frontend
Don't render a reusable block in the editor or frontend if it is
non-published or password protected.

@noisysocks noisysocks force-pushed the fix/trashed-reusable-blocks branch from db47db0 to 614fd21 Nov 27, 2018

@noisysocks noisysocks merged commit 6e3bb74 into master Nov 28, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@noisysocks noisysocks deleted the fix/trashed-reusable-blocks branch Nov 28, 2018

dd32 added a commit to dd32/gutenberg that referenced this pull request Nov 29, 2018

Reusable blocks: Don't show trashed blocks in the editor or frontend (W…
…ordPress#12345)

Don't render a reusable block in the editor or frontend if it is
non-published or password protected.

@mtias mtias modified the milestones: 4.6, 4.7 Nov 29, 2018

grey-rsi pushed a commit to OnTheGoSystems/gutenberg that referenced this pull request Jan 4, 2019

Reusable blocks: Don't show trashed blocks in the editor or frontend (W…
…ordPress#12345)

Don't render a reusable block in the editor or frontend if it is
non-published or password protected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment