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

Chrome: Hide several Sidebar Panels if the CPT doesn't support it #4161

Merged
merged 5 commits into from
Dec 28, 2017

Conversation

youknowriad
Copy link
Contributor

@youknowriad youknowriad commented Dec 25, 2017

closes #3989

This PR hides the featured image panel on CPT not supporting it.

Testing instructions

  • Register a CPT not supporting the "thumbnail", "comments", "trackbacks", "excerpt", "revisions", "author" and "post-formats"
  • Create a new post for this CPT
  • The corresponding panel should not show up.

@youknowriad youknowriad added the General Interface Parts of the UI which don't fall neatly under other labels. label Dec 25, 2017
@youknowriad youknowriad self-assigned this Dec 25, 2017
@youknowriad youknowriad force-pushed the update/featured-image-support branch from 76b4c9e to cceab01 Compare December 25, 2017 13:04
@youknowriad youknowriad force-pushed the update/featured-image-support branch from cceab01 to 6f27c2b Compare December 25, 2017 13:35
@youknowriad youknowriad changed the title Chrome: Hide the Featured Image Panel if the CPT doesn't support it Chrome: Hide several Sidebar Panels if the CPT doesn't support it Dec 25, 2017
@youknowriad youknowriad force-pushed the update/featured-image-support branch from 7ea49bc to 097b3a0 Compare December 25, 2017 13:52
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

I tested the changes and things look as expected. Nice work 👍

@@ -16,7 +16,9 @@ import { compose } from '@wordpress/element';
import { getCurrentPostType } from '../../store/selectors';

function PostTypeSupportCheck( { postType, children, supportKey } ) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the supportKey should be named supportKeys given that we accept more than one.

@youknowriad youknowriad force-pushed the update/featured-image-support branch from 097b3a0 to 0fe2322 Compare December 28, 2017 14:34
@youknowriad youknowriad merged commit c22bc9d into master Dec 28, 2017
@youknowriad youknowriad deleted the update/featured-image-support branch December 28, 2017 14:44
function PostTypeSupportCheck( { postType, children, supportKey } ) {
const isSupported = get( postType, [ 'data', 'supports', supportKey ], false );
function PostTypeSupportCheck( { postType, children, supportKeys } ) {
const isSupported = some(
Copy link
Member

Choose a reason for hiding this comment

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

Should this be every? I could imagine a need for both cases, i.e. a component that requires post type support for both X and Y, but alternatively X or Y.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hesitated on adding an "operator". For now we only have the "or" use-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Many blocks appears in sidebar for CPTs that do not support certain features
3 participants