Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Apr 18, 2024
1 parent eb19719 commit 7342f5a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
TEMPLATE_POST_TYPE,
TEMPLATE_PART_POST_TYPE,
PATTERN_POST_TYPE,
NAVIGATION_POST_TYPE,
} from '../../store/constants';
import { store as editorStore } from '../../store';
import { unlock } from '../../lock-unlock';
Expand Down Expand Up @@ -381,6 +382,7 @@ export const viewPostAction = {
TEMPLATE_POST_TYPE,
TEMPLATE_PART_POST_TYPE,
PATTERN_POST_TYPE,
NAVIGATION_POST_TYPE,
].includes( post.type ) && post.status !== 'trash'
);
},
Expand Down
18 changes: 9 additions & 9 deletions packages/editor/src/components/post-card-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ import { unlock } from '../../lock-unlock';
import TemplateAreas from '../template-areas';
import { viewPostAction } from '../post-actions/actions';

function ActionTrigger( { action, item } ) {
if ( ! action.isEligible( item ) ) {
function ViewPostLink( { post } ) {
if ( ! viewPostAction.isEligible( post ) ) {
return null;
}
return (
<Button
label={ action.label }
icon={ action.icon }
isDestructive={ action.isDestructive }
size="compact"
onClick={ async () => {
await action.callback( [ item ] );
label={ viewPostAction.label }
icon={ viewPostAction.icon }
isDestructive={ viewPostAction.isDestructive }
size="small"
onClick={ () => {
viewPostAction.callback( [ post ] );
} }
/>
);
Expand Down Expand Up @@ -116,7 +116,7 @@ export default function PostCardPanel( { className, actions } ) {
>
{ title ? decodeEntities( title ) : __( 'No Title' ) }
</Text>
<ActionTrigger item={ post } action={ viewPostAction } />
<ViewPostLink post={ post } />
{ actions }
</HStack>
<VStack className="editor-post-card-panel__content">
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/store/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const AUTOSAVE_PROPERTIES = [ 'title', 'excerpt', 'content' ];
export const TEMPLATE_POST_TYPE = 'wp_template';
export const TEMPLATE_PART_POST_TYPE = 'wp_template_part';
export const PATTERN_POST_TYPE = 'wp_block';
export const NAVIGATION_POST_TYPE = 'wp_navigation';
export const TEMPLATE_ORIGINS = {
custom: 'custom',
theme: 'theme',
Expand Down

0 comments on commit 7342f5a

Please sign in to comment.