Skip to content

Commit

Permalink
Create preferences package
Browse files Browse the repository at this point in the history
Add initial README

Add changelog

Add store

Update a few things

Update edit-widgets to use preferences store

Update customize-widgets to use preferences store

Update edit-post to use preferences store

Update e2e-tests to use preferences store

Fixes to preferences

Move components to preferences

Fix package.json

Fix classnames

Fix exports

Fix stylesheet imports

Fix scss issues

Fix code examples

Update more menu component usage

Fix e2e test selector

Update package-lock file

Re-update package-lock

Are we nearly there yet

Deprecate old selectors and actions and move tests over

Update persisted data migration to migrate from interface

Update comment

Fix typo

Flatten preference store state

Fix test

Fix tests again

Fix persistence

Remove useThunks property from preferences store config

Simplify preferences store API

Update preferences store usage for new api

Add autogenerated API docs

Update preferences README with new autogenerated API docs

Move more menu back to the interface package

Rename MoreMenuPreferenceToggle to PreferenceToggleMenuItem

Add preference label to spoken message
  • Loading branch information
talldan committed Feb 28, 2022
1 parent 709e294 commit a1c200a
Show file tree
Hide file tree
Showing 26 changed files with 250 additions and 656 deletions.
6 changes: 5 additions & 1 deletion docs/reference-guides/data/data-core-edit-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,11 @@ _Returns_

### switchEditorMode

Undocumented declaration.
Triggers an action used to switch editor mode.

_Parameters_

- _mode_ `string`: The editor mode.

### toggleEditorPanelEnabled

Expand Down
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/base-styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ $z-layers: (
// ...Except for popovers immediately beneath wp-admin menu on large breakpoints
".components-popover.block-editor-inserter__popover": 99999,
".components-popover.table-of-contents__popover": 99998,
".components-popover.edit-post-more-menu__content": 99998,
".components-popover.edit-site-more-menu__content": 99998,
".components-popover.interface-more-menu__content": 99998,
".components-popover.block-editor-rich-text__inline-format-toolbar": 99998,
Expand Down
52 changes: 4 additions & 48 deletions packages/data/src/plugins/persistence/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,53 +296,6 @@ export function migrateFeaturePreferencesToPreferencesStore(
}
}

/**
* Move the 'features' object in local storage from the sourceStoreName to the
* interface store.
*
* @param {Object} persistence The persistence interface.
* @param {string} sourceStoreName The name of the store that has persisted
* preferences to migrate to the interface
* package.
*/
export function migrateFeaturePreferencesToInterfaceStore(
persistence,
sourceStoreName
) {
const interfaceStoreName = 'core/interface';
const state = persistence.get();
const sourcePreferences = state[ sourceStoreName ]?.preferences;
const sourceFeatures = sourcePreferences?.features;

if ( sourceFeatures ) {
const targetFeatures =
state[ interfaceStoreName ]?.preferences?.features;

// Avoid migrating features again if they've previously been migrated.
if ( ! targetFeatures?.[ sourceStoreName ] ) {
// Set the feature values in the interface store, the features
// object is keyed by 'scope', which matches the store name for
// the source.
persistence.set( interfaceStoreName, {
preferences: {
features: {
...targetFeatures,
[ sourceStoreName ]: sourceFeatures,
},
},
} );

// Remove feature preferences from the source.
persistence.set( sourceStoreName, {
preferences: {
...sourcePreferences,
features: undefined,
},
} );
}
}
}

/**
* Deprecated: Remove this function and the code in WordPress Core that calls
* it once WordPress 6.0 is released.
Expand All @@ -359,7 +312,10 @@ persistencePlugin.__unstableMigrate = ( pluginOptions ) => {
persistence,
'core/customize-widgets'
);
migrateFeaturePreferencesToInterfaceStore( persistence, 'core/edit-post' );
migrateFeaturePreferencesToPreferencesStore(
persistence,
'core/edit-post'
);
};

export default persistencePlugin;
Loading

0 comments on commit a1c200a

Please sign in to comment.