Connectors: Keep a stored API key read-only when it can't be verified - #83889
Conversation
The Connectors screen no longer submits a masked API key, as it shows a stored key read-only until it is removed, so the setting does not need to handle one: WordPress/gutenberg#83889 See #65551.
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: 0 B Total Size: 8.25 MB
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. sort patterns (Site Editor v2) in
|
The settings endpoint only returns stored API keys masked. When a stored key could not be verified, for example while the provider was unreachable, the settings form was editable and pre-filled with the mask, so saving it overwrote the stored key. Show a stored key read-only, as for a connected provider, so it has to be removed before entering a new one.
10cb3f9 to
7ead448
Compare
…WordPress#83889) Co-authored-by: jorgefilipecosta <[email protected]>
Related to https://core.trac.wordpress.org/ticket/65551 and WordPress/wordpress-develop#13870.
Currently, the API key field on the Connectors screen is only read-only while the connector shows as connected. When a stored key can't be verified, for example while the provider is unreachable, the connector shows as not connected, and the field is editable and pre-filled with the masked key the settings endpoint returns. Saving it overwrites the stored key and makes it invating.
To fix this, a stored key is now always shown read-only, as for a connected provider, so it has to be removed with "Remove and replace" before entering a new one. The settings form now remounts when it switches between read-only and editable, so the field is empty after the key is removed.
Testing Instructions
npm run test:unit -- routes/connectors-home.AI usage disclosure: fix and description drafted with AI assistance and reviewed by me.