Remove allowed keys list for adding woocommerce_meta data (https://github.com/woocommerce/woocommerce-admin/pull/6889)
* introduce filter for wc meta preferences * package changelog * added PR number * Remove allow list for woocommerce_meta keys * Remove hooks dep * Lint js fixes * Update readme.txt * Update readme.txt * Fix test. Co-authored-by: Jeff Stieler <jeff.m.stieler@gmail.com>
This commit is contained in:
parent
060f52d938
commit
1edb849c67
|
@ -1,6 +1,7 @@
|
|||
# Unreleased
|
||||
|
||||
- Fix parsing bad JSON string data in useUserPreferences hook. #6819
|
||||
- Removed allowed keys list for adding woocommerce_meta data. #6889
|
||||
|
||||
# 1.2.0
|
||||
|
||||
|
|
|
@ -140,14 +140,11 @@ describe( 'useUserPreferences() hook', () => {
|
|||
'function'
|
||||
);
|
||||
|
||||
const updateResult = await result.current.updateUserPreferences( {
|
||||
banana: 'is not a valid meta key',
|
||||
} );
|
||||
// Passing an array, not an object.
|
||||
const updateResult = await result.current.updateUserPreferences( [] );
|
||||
|
||||
expect( updateResult ).toMatchObject( {
|
||||
error: new Error(
|
||||
'No valid woocommerce_meta keys were provided for update.'
|
||||
),
|
||||
error: new Error( 'Invalid woocommerce_meta data for update.' ),
|
||||
updatedUser: undefined,
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { mapValues, pick } from 'lodash';
|
||||
import { mapValues } from 'lodash';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
|
||||
/**
|
||||
|
@ -48,39 +48,12 @@ async function updateUserPrefs(
|
|||
) {
|
||||
// @todo Handle unresolved getCurrentUser() here.
|
||||
|
||||
// Whitelist our meta fields.
|
||||
const userDataFields = [
|
||||
'categories_report_columns',
|
||||
'coupons_report_columns',
|
||||
'customers_report_columns',
|
||||
'orders_report_columns',
|
||||
'products_report_columns',
|
||||
'revenue_report_columns',
|
||||
'taxes_report_columns',
|
||||
'variations_report_columns',
|
||||
'dashboard_sections',
|
||||
'dashboard_chart_type',
|
||||
'dashboard_chart_interval',
|
||||
'dashboard_leaderboard_rows',
|
||||
'activity_panel_inbox_last_read',
|
||||
'homepage_layout',
|
||||
'homepage_stats',
|
||||
'android_app_banner_dismissed',
|
||||
'task_list_tracked_started_tasks',
|
||||
'help_panel_highlight_shown',
|
||||
];
|
||||
|
||||
// Prep valid fields for update.
|
||||
const metaData = mapValues(
|
||||
pick( userPrefs, userDataFields ),
|
||||
JSON.stringify
|
||||
);
|
||||
// Prep fields for update.
|
||||
const metaData = mapValues( userPrefs, JSON.stringify );
|
||||
|
||||
if ( Object.keys( metaData ).length === 0 ) {
|
||||
return {
|
||||
error: new Error(
|
||||
'No valid woocommerce_meta keys were provided for update.'
|
||||
),
|
||||
error: new Error( 'Invalid woocommerce_meta data for update.' ),
|
||||
updatedUser: undefined,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
|
|||
- Dev: Use rule processing for remote payment methods #6830
|
||||
- Dev: Update E2E jest config, so it correctly creates screenshots on failure. #6858
|
||||
- Dev: Fixed storybook build script #6875
|
||||
- Dev: Removed allowed keys list for adding woocommerce_meta data. #6889 🎉 @xristos3490
|
||||
- Feature: Add recommended payment methods in payment settings. #6760
|
||||
- Fix: Disable the continue btn on OBW when requested are being made #6838
|
||||
- Fix: Event tracking for merchant email notes #6616
|
||||
|
|
Loading…
Reference in New Issue