Repository navigation
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Settings API utilities and migration popup src/util/admin.js, src/plugins/v2-migration-popup/*, src/deprecated/v2/init.php, src/init.php, src/welcome/index.php, jest.config.js, src/test/wp-api-stub.js |
fetchSettings retrieves settings through apiFetch, and the new saveSettings function posts settings through apiFetch. The migration popup also retrieves settings through apiFetch and ignores failed requests. Script dependencies and the Jest mapping are updated to remove the WordPress API model dependency. |
Global settings persistence src/plugins/global-settings/* |
Global block styles, color schemes, colors, typography, and block layout settings use saveSettings. Existing debounce timing and described store updates remain. |
Component and welcome settings src/components/base-control2/label-tooltip.js, src/components/guided-modal-tour/index.js, src/deprecated/v2/welcome/admin.js, src/lazy-components/cimo/index.js, src/welcome/admin.js, src/welcome/import-export/index.js |
Tooltip, guided-tour, Cimo notice, optimization, welcome, and imported settings use saveSettings instead of WordPress Settings models. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers: bfintal, kaeizen
Merge Risk: 
Minimal · up to 9efd6
-
No actionable regression remains in the reviewed settings migration; it is ready for normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "fix: migrate wp-api to wp-api-fetch" matches the main change. The PR replaces the deprecated
@wordpress/apimodels (wp-api) with apiFetch-based calls (wp-api-fetch) across many files. It adds a saveSettings helper in src/util/admin.js and removes wp-api from the script dependencies. The title is short and names the primary change. It does not mention the saveSettings helper or the failed-save handling, but the task says it need not cover every detail.
Full details: Linked Issues check
-
Explanation
The changes satisfy the coding requirements for
#3768. Settings reads and writes now useapiFetchthroughfetchSettingsandsaveSettings. The migration popup reads and saves/wp/v2/settingswith the same permission model. Its rejected-save path clears the busy state. The changed call sites remove the old@wordpress/apimodel usage. No additional automated-test requirement is stated.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within
#3768. The shared settings helper, migrated save call sites,wp-api-fetchdependencies, migration-popup error handling, and removal of the obsolete API test stub all support the settings API migration. No unrelated change is identified.
-
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
🤖 Pull request artifacts
|
|
Size Change: -112 B (0%) Total Size: 2.64 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Changes requested. Details are on #3768. The v2 migration popup in Please keep the read and the save on the same permission, and turn the spinner off when the save fails. Also add one |
bfintal
left a comment
There was a problem hiding this comment.
Thanks, this is a clean change.
Every new models.Settings( ... ).save() is now a single saveSettings() helper that uses apiFetch, and no @wordpress/api usage is left in src/.
Settings save to the same /wp/v2/settings endpoint as before, so nothing changes for users.
All CI passes here and in the premium PR bfintal/Stackable-Premium#412.
Two small suggestions, neither blocks this:
[Minor] Failed saves are silently ignored
Most calls now end with .catch( () => {} ).
That matches the old behavior (Backbone also failed quietly), so this isn't a regression.
But if a save fails, the user changes a global color and it's gone after a reload, with no message.
Later, it would help to log the error (console.error) or show a notice in one place inside saveSettings().
[Nit] One call has no .catch()
See the inline comment.
Because this touches every place that saves a setting, QA should quickly check a few of them: global colors, typography, block styles, the settings page, and import/export.
| saveTimeout = setTimeout( () => { | ||
| const settings = new models.Settings( { [ optionName ]: newSettings } ) // eslint-disable-line camelcase | ||
| settings.save() | ||
| saveWPSettings( { [ optionName ]: newSettings } ) |
There was a problem hiding this comment.
[Nit] This is the only saveSettings call here without .catch().
If the request fails, the browser console shows an "Uncaught (in promise)" error.
Add .catch( () => {} ) like the other calls, so they all behave the same.
fixes #3768
Summary by CodeRabbit
Improvements
Bug Fixes