Skip to content

Commit

Permalink
Add post status icon in post summary
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Jul 17, 2024
1 parent cdf31e8 commit 0f881de
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions packages/editor/src/components/post-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import { useState, useMemo } from '@wordpress/element';
import { store as coreStore } from '@wordpress/core-data';
import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
import { useInstanceId } from '@wordpress/compose';
import {
drafts,
published,
scheduled,
pending,
notAllowed,
} from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -31,13 +38,13 @@ import PostSticky from '../post-sticky';
import { PrivatePostSchedule } from '../post-schedule';
import { store as editorStore } from '../../store';

const labels = {
'auto-draft': __( 'Draft' ),
draft: __( 'Draft' ),
pending: __( 'Pending' ),
private: __( 'Private' ),
future: __( 'Scheduled' ),
publish: __( 'Published' ),
const postStatusesInfo = {
'auto-draft': { label: __( 'Draft' ), icon: drafts },
draft: { label: __( 'Draft' ), icon: drafts },
pending: { label: __( 'Pending' ), icon: pending },
private: { label: __( 'Private' ), icon: notAllowed },
future: { label: __( 'Scheduled' ), icon: scheduled },
publish: { label: __( 'Published' ), icon: published },
};

export const STATUS_OPTIONS = [
Expand Down Expand Up @@ -200,13 +207,15 @@ export default function PostStatus() {
variant="tertiary"
size="compact"
onClick={ onToggle }
icon={ postStatusesInfo[ status ]?.icon }
iconSize="20"
aria-label={ sprintf(
// translators: %s: Current post status.
__( 'Change post status: %s' ),
labels[ status ]
postStatusesInfo[ status ]?.label
) }
>
{ labels[ status ] }
{ postStatusesInfo[ status ]?.label }
</Button>
) }
renderContent={ ( { onClose } ) => (
Expand Down Expand Up @@ -290,7 +299,7 @@ export default function PostStatus() {
/>
) : (
<div className="editor-post-status is-read-only">
{ labels[ status ] }
{ postStatusesInfo[ status ]?.label }
</div>
) }
</PostPanelRow>
Expand Down

0 comments on commit 0f881de

Please sign in to comment.