-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Deprecate interface package's preference APIs #39418
Conversation
Size Change: +2.77 kB (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
* preferences to migrate to the interface | ||
* package. | ||
*/ | ||
export function migrateFeaturePreferencesToInterfaceStore( |
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 function was unused, so I removed it.
@@ -384,13 +384,13 @@ describe( 'persistence', () => { | |||
} ); | |||
} ); | |||
|
|||
describe( 'migrateFeaturePreferencesToInterfaceStore', () => { |
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.
To most easily review this, toggle on 'Hide whitespace' in the little cog menu at the top.
Otherwise the diff looks worse than it is. Lots of the other tests were all incorrectly nested in this describe
, and all I did was:
- un-nest incorrectly nested tests
- delete the tests for the removed function
- add the tests for the new function.
import { isFeatureActive } from '../selectors'; | ||
|
||
describe( 'selectors', () => { | ||
describe( 'isFeatureActive', () => { |
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've deleted this as the selector is tested extensively in the actions.js test file.
1ef3e81
to
351cc81
Compare
I realised there's a bug in I've put together a fix in 0dba039. I'm including it in this PR, as otherwise the conflicts will be difficult to handle. I think it'd be best to cherry-pick this PR into the Gutenberg 12.8 release, both so that the interface APIs continue to work in that release, and also so that local storage data isn't accidentally removed. |
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.
The changes look good to me @talldan! Thanks for the explanations in the PR description and extra comments, it very much helps to wrap my head around the changes 😀 — it's testing well according to the testing steps 👍
The only feedback I noted was a few comments where the existing code uses optional chaining to set a value, but then attempts to spread the value using ...
— I suspect that there've never been any errors here because the values are always an object, rather than undefined
, and I couldn't break it during testing 🤔
Feel free to ignore those comments if they're not applicable here. If you think they should be addressed I suppose we could change them to ...( myValue || {} )
and / or add tests for calling those functions with a state that doesn't have a preferences
key?
continue; | ||
} | ||
|
||
// Skip this scope if there are no features to migrates |
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.
Tiny typo 😁
// Skip this scope if there are no features to migrates | |
// Skip this scope if there are no features to migrate. |
Thanks for the reviews. 🎉 |
* Deprecate and proxy existing feature preference API in interface package * Remove peristence of preferences reducer * Migrate third party preferences from the interface package * Improve deprecation message * Ensure non-preference data is retained after any migration
dispatch.setFeatureValue( scope, featureName, ! currentValue ); | ||
return function ( { registry } ) { | ||
deprecated( `wp.dispatch( 'core/interface' ).toggleFeature`, { | ||
version: '6.0', |
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'm not mistaken, I think you meant to use since
(version of deprecation) instead of version
(version of removal) here, right? #39640
Part of #31965
What?
Deprecates the feature preference actions and selectors in the interface store and makes them select and dispatch from the new preferences package.
Why?
In #38873 a new package was introduced which replaces what these selectors and actions do.
The editors that were previously using the interface package for feature preferences have already been migrated to use the new preferences package (#39084, #39112, #39115).
These old APIs now need to be deprecated, but they need to also still work for any third party usage.
How?
Testing Instructions
There's no user facing way to test this, the easiest option is to use the API in the browser console the way a plugin would.
trunk
and build