Skip to content

Commit

Permalink
Tags panel: control visibility
Browse files Browse the repository at this point in the history
Do not show it if post has some tag assigned.
  • Loading branch information
oandregal committed Aug 1, 2018
1 parent 1236a76 commit e927c9a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const TagsPanel = () => <PanelBody initialOpen={ true } title={ [
<FlatTermSelector slug={ 'post_tag' } />
</PanelBody>;

const MaybeTagsPanel = ( { hasTags } ) => {
if ( ! hasTags ) {
const MaybeTagsPanel = ( { isPostTypeSupported, hasTags } ) => {
if ( ! isPostTypeSupported || hasTags ) {
return null;
}
return ( <TagsPanel /> );
Expand All @@ -29,8 +29,10 @@ export default compose( [
withSelect( ( select ) => {
const postType = select( 'core/editor' ).getCurrentPostType();
const tags = select( 'core' ).getTaxonomy( 'post_tag' );
const terms = select( 'core/editor' ).getEditedPostAttribute( tags.rest_base );
return {
hasTags: tags && tags.types.some( ( type ) => type === postType ),
hasTags: tags && terms && terms.length > 0,
isPostTypeSupported: tags && tags.types.some( ( type ) => type === postType ),
};
} ),
] )( MaybeTagsPanel );

0 comments on commit e927c9a

Please sign in to comment.