From 28789fc92acbac1fbff16db11ca086db05c572a0 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:37:27 +1000 Subject: [PATCH] Library: Add sync status to pattern details screen (#51954) --- .../index.js | 3 -- .../use-pattern-details.js | 44 ++++++++++++++++++- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js index 182a570d8a95d9..349cc5d43b431d 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js @@ -14,7 +14,6 @@ import SidebarButton from '../sidebar-button'; import SidebarNavigationScreen from '../sidebar-navigation-screen'; import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-entity-from-url'; import usePatternDetails from './use-pattern-details'; -import useNavigationMenuContent from './use-navigation-menu-content'; import { store as editSiteStore } from '../../store'; import { unlock } from '../../lock-unlock'; @@ -27,7 +26,6 @@ export default function SidebarNavigationScreenPattern() { useInitEditedEntityFromURL(); const patternDetails = usePatternDetails( postType, postId ); - const content = useNavigationMenuContent( postType, postId ); // The absence of a category type in the query params for template parts // indicates the user has arrived at the template part via the "manage all" @@ -47,7 +45,6 @@ export default function SidebarNavigationScreenPattern() { /> } backPath={ backPath } - content={ content } { ...patternDetails } /> ); diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js index 028b1c781f8f2c..dfc367ea0b97dc 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js @@ -11,7 +11,14 @@ import { Icon } from '@wordpress/components'; */ import { useAddedBy } from '../list/added-by'; import useEditedEntityRecord from '../use-edited-entity-record'; +import useNavigationMenuContent from './use-navigation-menu-content'; import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer'; +import { + SidebarNavigationScreenDetailsPanel, + SidebarNavigationScreenDetailsPanelRow, + SidebarNavigationScreenDetailsPanelLabel, + SidebarNavigationScreenDetailsPanelValue, +} from '../sidebar-navigation-screen-details-panel'; export default function usePatternDetails( postType, postId ) { const { getDescription, getTitle, record } = useEditedEntityRecord( @@ -82,5 +89,40 @@ export default function usePatternDetails( postType, postId ) { /> ) : null; - return { title, description, footer }; + const details = []; + + if ( postType === 'wp_block' ) { + details.push( { + label: __( 'Syncing' ), + value: + record.meta?.sync_status === 'unsynced' + ? __( 'Not synced' ) + : __( 'Fully synced' ), + } ); + } + + const content = ( + <> + { !! details.length && ( + + { details.map( ( { label, value } ) => ( + + + { label } + + + { value } + + + ) ) } + + ) } + { useNavigationMenuContent( postType, postId ) } + + ); + + return { title, description, content, footer }; }