Skip to content

Commit

Permalink
Add post status icon in post summary (#63658)
Browse files Browse the repository at this point in the history
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
  • Loading branch information
3 people committed Jul 19, 2024
1 parent a2fb0fb commit 5d4bf27
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/editor/src/components/post-last-revision/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function PrivatePostLastRevision() {
className="editor-private-post-last-revision__button"
text={ revisionsCount }
variant="tertiary"
size="compact"
/>
</PostPanelRow>
</PostLastRevisionCheck>
Expand Down
1 change: 0 additions & 1 deletion packages/editor/src/components/post-panel-row/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
white-space: normal;
text-wrap: balance; // Fallback for Safari.
text-wrap: pretty;
height: auto;
min-height: $button-size-compact;
}

Expand Down
28 changes: 18 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,14 @@ export default function PostStatus() {
variant="tertiary"
size="compact"
onClick={ onToggle }
icon={ postStatusesInfo[ status ]?.icon }
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 +298,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 5d4bf27

Please sign in to comment.