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

Update: For synced entities the icon should be purple. #62024

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions packages/editor/src/components/document-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useReducedMotion } from '@wordpress/compose';
/**
* Internal dependencies
*/
import { TEMPLATE_POST_TYPES, GLOBAL_POST_TYPES } from '../../store/constants';
import { store as editorStore } from '../../store';
import { unlock } from '../../lock-unlock';

Expand All @@ -39,14 +40,6 @@ const TYPE_LABELS = {
wp_template_part: __( 'Editing template part: %s' ),
};

const TEMPLATE_POST_TYPES = [ 'wp_template', 'wp_template_part' ];

const GLOBAL_POST_TYPES = [
...TEMPLATE_POST_TYPES,
'wp_block',
'wp_navigation',
];

const MotionButton = motion( Button );

/**
Expand Down
30 changes: 28 additions & 2 deletions packages/editor/src/components/post-card-panel/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* External dependencies
*/
import clsx from 'clsx';
/**
* WordPress dependencies
*/
Expand All @@ -18,11 +22,13 @@ import { store as editorStore } from '../../store';
import {
TEMPLATE_POST_TYPE,
TEMPLATE_PART_POST_TYPE,
PATTERN_POST_TYPE,
GLOBAL_POST_TYPES,
} from '../../store/constants';
import { unlock } from '../../lock-unlock';

export default function PostCardPanel( { actions } ) {
const { title, icon } = useSelect( ( select ) => {
const { title, icon, isSync } = useSelect( ( select ) => {
const {
getEditedPostAttribute,
getCurrentPostType,
Expand All @@ -36,11 +42,26 @@ export default function PostCardPanel( { actions } ) {
const _templateInfo =
[ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes( _type ) &&
__experimentalGetTemplateInfo( _record );
let _isSync = false;
if ( GLOBAL_POST_TYPES.includes( _type ) ) {
if ( PATTERN_POST_TYPE === _type ) {
// When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
const currentSyncStatus =
getEditedPostAttribute( 'meta' )?.wp_pattern_sync_status ===
'unsynced'
? 'unsynced'
: getEditedPostAttribute( 'wp_pattern_sync_status' );
_isSync = currentSyncStatus !== 'unsynced';
} else {
_isSync = true;
}
}
return {
title: _templateInfo?.title || getEditedPostAttribute( 'title' ),
icon: unlock( select( editorStore ) ).getPostIcon( _type, {
area: _record?.area,
} ),
isSync: _isSync,
};
}, [] );
return (
Expand All @@ -50,7 +71,12 @@ export default function PostCardPanel( { actions } ) {
className="editor-post-card-panel__header"
align="flex-start"
>
<Icon className="editor-post-card-panel__icon" icon={ icon } />
<Icon
className={ clsx( 'editor-post-card-panel__icon', {
'is-sync': isSync,
} ) }
icon={ icon }
/>
<Text
numberOfLines={ 2 }
truncate
Expand Down
4 changes: 4 additions & 0 deletions packages/editor/src/components/post-card-panel/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@
margin-bottom: $grid-unit-10;
}
}

.editor-post-card-panel__icon.is-sync {
fill: var(--wp-block-synced-color);
}
6 changes: 6 additions & 0 deletions packages/editor/src/store/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ export const TEMPLATE_ORIGINS = {
theme: 'theme',
plugin: 'plugin',
};
export const TEMPLATE_POST_TYPES = [ 'wp_template', 'wp_template_part' ];
export const GLOBAL_POST_TYPES = [
...TEMPLATE_POST_TYPES,
'wp_block',
'wp_navigation',
];
Loading