-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Navigation: Add the draft status to the navigation title #51967
Conversation
Size Change: +1.94 kB (0%) Total Size: 1.45 MB
ℹ️ View Unchanged
|
...dit-site/src/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js
Outdated
Show resolved
Hide resolved
import { __, sprintf } from '@wordpress/i18n'; | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
|
||
// Copied from packages/block-library/src/navigation/edit/navigation-menu-selector.js. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tracked here #51446
navigationMenu?.title, | ||
navigationMenu?.id, | ||
navigationMenu?.status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting to seem strange. It's like we should just pass the entire Post 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did wonder that too
export default function buildNavigationLabel( title, id, status ) { | ||
if ( ! title?.rendered ) { | ||
/* translators: %s is the index of the menu in the list of menus. */ | ||
return sprintf( __( '(no title %s)' ), id ); | ||
} | ||
|
||
if ( status === 'publish' ) { | ||
return decodeEntities( title?.rendered ); | ||
} | ||
|
||
return sprintf( | ||
// translators: %1s: title of the menu; %2s: status of the menu (draft, pending, etc.). | ||
__( '%1$s (%2$s)' ), | ||
decodeEntities( title?.rendered ), | ||
status | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for now but I wonder if in future we could define some of these defaults centrally in packages/core-data/src/entities.js and avoid having to repeat ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updates
…1967) * Navigation: Add the draft status to the navigation title * Move the buildNavigationLabel function to the default export
What?
Adds the
(draft)
status to the title of the Navigation area of the Site View sidebar. Fixes #51797.Why?
The status should be in both places.
How?
Extract
buildNavigationLabel
to a new file so it can be shared across all the different places it is used.Testing Instructions
(draft)
status indicator next to it in both the list view and the single view.Screenshots or screencast