Skip to content

Commit

Permalink
Site Editor: Add Post Taxonomies panel (WordPress#57049)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Dec 14, 2023
1 parent 789519e commit 27ab284
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 344 deletions.
30 changes: 0 additions & 30 deletions packages/edit-post/src/components/sidebar/post-taxonomies/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import { isRTL, __ } from '@wordpress/i18n';
import { drawerLeft, drawerRight } from '@wordpress/icons';
import { store as interfaceStore } from '@wordpress/interface';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
import { store as editorStore, PostLastRevisionPanel } from '@wordpress/editor';
import {
store as editorStore,
PostLastRevisionPanel,
PostTaxonomiesPanel,
} from '@wordpress/editor';

/**
* Internal dependencies
*/
import SettingsHeader from '../settings-header';
import PostStatus from '../post-status';
import PostTaxonomies from '../post-taxonomies';
import FeaturedImage from '../featured-image';
import PostExcerpt from '../post-excerpt';
import DiscussionPanel from '../discussion-panel';
Expand Down Expand Up @@ -79,7 +82,7 @@ const SidebarContent = ( {
<PostStatus />
<PluginDocumentSettingPanel.Slot />
<PostLastRevisionPanel />
<PostTaxonomies />
<PostTaxonomiesPanel />
<FeaturedImage />
<PostExcerpt />
<DiscussionPanel />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { humanTimeDiff } from '@wordpress/date';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';
import { PostLastRevisionPanel, store as editorStore } from '@wordpress/editor';
import {
PostLastRevisionPanel,
PostTaxonomiesPanel,
store as editorStore,
} from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -95,6 +99,7 @@ export default function PagePanels() {
</PanelBody>
) }
<PostLastRevisionPanel />
<PostTaxonomiesPanel />
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
*/
import { useSelect } from '@wordpress/data';
import { PanelBody } from '@wordpress/components';
import { PostLastRevisionPanel, store as editorStore } from '@wordpress/editor';
import {
PostTaxonomiesPanel,
PostLastRevisionPanel,
store as editorStore,
} from '@wordpress/editor';
import { store as coreStore } from '@wordpress/core-data';
import { decodeEntities } from '@wordpress/html-entities';
import { navigation, symbol } from '@wordpress/icons';
Expand All @@ -15,38 +19,31 @@ import { store as editSiteStore } from '../../../store';
import TemplateActions from './template-actions';
import TemplateAreas from './template-areas';
import SidebarCard from '../sidebar-card';
import PatternCategories from './pattern-categories';
import { PATTERN_TYPES } from '../../../utils/constants';

const CARD_ICONS = {
wp_block: symbol,
wp_navigation: navigation,
};

export default function TemplatePanel() {
const { title, description, icon, record, postType } = useSelect(
( select ) => {
const { getEditedPostType, getEditedPostId } =
select( editSiteStore );
const { getEditedEntityRecord } = select( coreStore );
const { __experimentalGetTemplateInfo: getTemplateInfo } =
select( editorStore );
const { title, description, icon, record } = useSelect( ( select ) => {
const { getEditedPostType, getEditedPostId } = select( editSiteStore );
const { getEditedEntityRecord } = select( coreStore );
const { __experimentalGetTemplateInfo: getTemplateInfo } =
select( editorStore );

const type = getEditedPostType();
const postId = getEditedPostId();
const _record = getEditedEntityRecord( 'postType', type, postId );
const info = getTemplateInfo( _record );
const type = getEditedPostType();
const postId = getEditedPostId();
const _record = getEditedEntityRecord( 'postType', type, postId );
const info = getTemplateInfo( _record );

return {
title: info.title,
description: info.description,
icon: info.icon,
record: _record,
postType: type,
};
},
[]
);
return {
title: info.title,
description: info.description,
icon: info.icon,
record: _record,
};
}, [] );

if ( ! title && ! description ) {
return null;
Expand All @@ -66,11 +63,7 @@ export default function TemplatePanel() {
</SidebarCard>
</PanelBody>
<PostLastRevisionPanel />
<PanelBody>
{ postType === PATTERN_TYPES.user && (
<PatternCategories post={ record } />
) }
</PanelBody>
<PostTaxonomiesPanel />
</>
);
}
Loading

0 comments on commit 27ab284

Please sign in to comment.