Skip to content

Replace "Add new post" link text with more meaningful Label#59743

Closed
carstingaxion wants to merge 265 commits intoWordPress:trunkfrom
carstingaxion:feature/better-create-new-post-link
Closed

Replace "Add new post" link text with more meaningful Label#59743
carstingaxion wants to merge 265 commits intoWordPress:trunkfrom
carstingaxion:feature/better-create-new-post-link

Conversation

@carstingaxion
Copy link
Copy Markdown
Contributor

What?

This PR replaces the static "Add new post" link text inside the the query block, with a more meaningful label from the currently selected post type.

Why?

This PR is polishing the existing UI with data, that is already available, without introducing any new elements.

How?

Removes a static text string, with the add_new_item label from the currently selected post type.

Testing Instructions

  1. Open a post or page.
  2. Insert a query block.
  3. Open the inspector controls
  4. Switch the queried post type
  5. And see the link text change, depending on the selected post type, within the CreateNewPostLink element.

Testing Instructions for Keyboard

Test can be done by keyboard as well, without any additions to my Testing Instruction.

Screenshots or screencast

Before

Bildschirmaufzeichnung.vom.11.03.2024.03.51.53.mp4

After

Bildschirmaufzeichnung.vom.11.03.2024.03.56.18.mp4

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 11, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @gutenbergplugin.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: gutenbergplugin.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: draganescu <andraganescu@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: peterwilsoncc <peterwilsoncc@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: Sam-Xronn <xronn@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: SiobhyB <siobhyb@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: ajlende <ajlende@git.wordpress.org>
Co-authored-by: enejb <enej@git.wordpress.org>
Co-authored-by: TeresaGobble <teresagobble@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: mcsf <mcsf@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: Jayanth-Parthsarathy <jayanthparthsarathy@git.wordpress.org>
Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>
Co-authored-by: fluiddot <carlosgprim@git.wordpress.org>
Co-authored-by: anton-vlasenko <antonvlasenko@git.wordpress.org>
Co-authored-by: dcalhoun <dpcalhoun@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: noisysocks <noisysocks@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: afragen <afragen@git.wordpress.org>
Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: mattsherman <mattormeeple@git.wordpress.org>
Co-authored-by: DAreRodz <darerodz@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: georgestephanis <georgestephanis@git.wordpress.org>
Co-authored-by: colinduwe <colind@git.wordpress.org>
Co-authored-by: gaambo <gaambo@git.wordpress.org>
Co-authored-by: tjcafferkey <tomjcafferkey@git.wordpress.org>
Co-authored-by: sunil25393 <sunil25393@git.wordpress.org>
Co-authored-by: geriux <geriux@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: matiasbenedetto <mmaattiiaass@git.wordpress.org>
Co-authored-by: creativecoder <grantmkin@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: megane9988 <megane9988@git.wordpress.org>
Co-authored-by: enodekciw <enodekciw@git.wordpress.org>
Co-authored-by: carstingaxion <carstenbach@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Mar 11, 2024
@github-actions
Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @carstingaxion! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@torounit torounit added [Type] Enhancement A suggestion for improvement. [Block] Query Loop Affects the Query Loop Block labels Mar 23, 2024
@torounit torounit requested review from Mamaduka and t-hamano March 23, 2024 08:05
@carstingaxion
Copy link
Copy Markdown
Contributor Author

Thanks for taking a look @torounit! Please let me know if I can do, provide or change anything.

Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I think the approach itself makes sense, but I think it's recommended to use useSelect hook instead of using select() directly in React components.

const CreateNewPostLink = () => {
	// ...
	const addNewItemLabel = useSelect(
		( select ) => {
			const { getPostType } = select( coreStore );
			return getPostType( postType )?.labels?.add_new_item;
		},
		[ postType ]
	);
	// ...
};

Furthermore, in this case, it is assumed that postType is not null, so I think the following line should be removed:

Instead, I think it's better to avoid rendering the CreateNewPostLink component itself if postType is falsy:

{ !! postType && (
	<BlockInfo>
		<CreateNewPostLink postType={ postType } />
	</BlockInfo>
) }

Also notice that the prop has been changed to only postType. CreateNewPostLink component only handles postType as a prop, but this should eliminate nested destructuring of props.

If you have any questions, please feel free to comment 👍

@carstingaxion
Copy link
Copy Markdown
Contributor Author

carstingaxion commented Mar 25, 2024

Wow. Thank you @t-hamano ! Thank you very much for your detailed review and your explicit suggestions on what to improve AND why.

For sure I'll update my PR.

t-hamano and others added 19 commits March 27, 2024 17:58
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: andrewhayward <andrewhayward@git.wordpress.org>
…ress#59635)

* PoC

* Fix cmd + K with click

* Adding mutually exclusive states

* Sync internal state with format active state

* Fix broken anchors for Links

* Improve variable naming

* Normalize more variable names

* Fix sub formats breaking click to edit

* Force constrainedTabbing for link ui

* Handle nested formats

* Revert change to hasLink var

* Locate const at top of file

* Improve comment

* Add test for editing text

* Improve var naming

* Correct comments

* Make new prop unstable

* Revert useAnchor API

---------

Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: draganescu <andraganescu@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: bacoords <bacoords@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
* don't set creating menu flag on menu switch

* return Promises from the navigation menu ref changing functions to be able to clean state after ref is updated

* update tests

* await the menu creation

* stub test updates

* revert test changes and remove decorative promises

* do not disable the UI when changing the navigation, disable the UI based on resolving menus

* block the UI for menu switching too, update tests with some comments, undo the focus update

* properly disable menu choices via their choices prop

Co-authored-by: draganescu <andraganescu@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
* Change callout to an alert.
* Update intro, remove TOC, and change headings
* Update Installation and Quick Start Guide sections.

Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: justintadlock <greenshady@git.wordpress.org>
…ress#59750)

Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: ajlende <ajlende@git.wordpress.org>
…dPress#59397)

* Block Editor: Don't memoize callbacks in 'BlockSettingsDropdown'
* Don't pass argument to 'updateSelectionAfterRemove'

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: peterwilsoncc <peterwilsoncc@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
…ordPress#59769)

Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@outlook.com>
)

Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
Unlinked contributors: Sam-Xronn, AnukratiMehta.

Co-authored-by: colinduwe <colind@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
)

Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
ntsekouras and others added 24 commits March 27, 2024 18:00
WordPress#60215)

Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
…dPress#60182)

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
* Add tests (failing)

* CustomSelectControlV2: Fix hint behavior in legacy

* Add changelog

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
…ess#60223)

* Add new template variable called namespacePascalCase and fix namespaceSnakeCase that was incorrecly using the slug instead of the namespace.

* Use new namespacePascalCase template variable and remove some extraneous whitespace

* Update changelog

Co-authored-by: ryanwelcher <welcher@git.wordpress.org>
Co-authored-by: justintadlock <greenshady@git.wordpress.org>
…60106)

Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
* Refactor global styles and refactor existing background components
* Porting over existing hook code to shared, global styles component.
* Move tests, move styles, remove duplicate code from block support hook
* Pull over changes to background.js from WordPress#59557
* Add default control values for block supports. The default backgroundSize value for block backgrounds is 'cover'
* Resetting position if it's center and size is not contain.
* Add background-image to INDIRECT_PROPERTIES_METADATA because the value is "indirectly" stored in an array, at least determined by multiple values in an array.

---------

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
…an the focused item (WordPress#59978)

* List View: Add keyboard shortcut to collapse list view items other than the focused item

* Remove keyboard shortcut info from customize-widgets as there is no list view in that context

* Add e2e test coverage

* Try adding some state to get it working from the editor canvas

* Skip keyboard shortcut in the editor canvas if the event is fired from a text field

* Add a few tests

Unlinked contributors: jarekmorawski.

Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
…ess#60229)

* Adding "background" top-level styles to the possible change list values. Updates tests.


Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
…ess#60068)

Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: noisysocks <noisysocks@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
* Block Editor: Expose inserter search term normalization utils

* Edit Site: Use search term normalization utils from block editor

* Edit Site: Remove remove-accents dependency

Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
…ss/compose` (WordPress#60168)

* Use useReducedMotion() from @wordpress/compose

* CHANGELOG

Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
…#60235)

Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
…ess#60225)

* Move useZoomout check up to PatternCategeryPreviewsPanel wrapper

Previously, the useZoomOut check was within the category previews rather than the panel. This meant when the category changed, the zoom out check ran again. We only want the zoom out mode check to happen when the panel itself is mounted.

* Simplify useZoomOut logic

The useRef wasn't necessary, as it was running before the other useEffect that could set it to true.
* CustomSelectControlV2: Rename for consistency

* Add changelog

* Improve naming consistency in tests

* Simply subcomponent composition and exports

* Apply suggestions to readme

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
…s#60190)

* NavigatorProvider: move all state management to one reducer

* Changelog update

* Move types together

Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
* Image: Use the new 'useUploadMediaFromBlobURL' hook
* Leverage temporaryURL initial state

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
@carstingaxion
Copy link
Copy Markdown
Contributor Author

OH no.

@t-hamano
Copy link
Copy Markdown
Contributor

Hi @carstingaxion,

Don't worry about a lot of commit history being added to this PR or a lot of people being notified 😄

If you are concerned about making new changes to this PR, you can close this PR, check out the latest trunk branch again, and submit a new PR with your changes.

@carstingaxion
Copy link
Copy Markdown
Contributor Author

carstingaxion commented May 3, 2024

Don't worry about a lot of commit history being added to this PR or a lot of people being notified 😄

Thank you for your empathic comment @t-hamano , yes I was a little thrilled.

If you are concerned about making new changes to this PR, you can close this PR, check out the latest trunk branch again, and submit a new PR with your changes.

That is, what I'll do now.

@carstingaxion carstingaxion deleted the feature/better-create-new-post-link branch June 4, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Query Loop Affects the Query Loop Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.