Settings: Persist date range selection (https://github.com/woocommerce/woocommerce-admin/pull/3293)
* Settings: fix date range persistance * set undefined on persisted on save * add comment
This commit is contained in:
parent
d6c77de3cd
commit
a5a67b107e
|
@ -117,17 +117,18 @@ class Settings extends Component {
|
|||
* @param {object} state - State
|
||||
*/
|
||||
persistChanges( state ) {
|
||||
const settings = getSetting( 'wcAdminSetting', {} );
|
||||
const settings = getSetting( 'wcAdminSettings', {} );
|
||||
analyticsSettings.forEach( setting => {
|
||||
const updatedValue = state.settings[ setting.name ];
|
||||
settings[ setting.name ] = updatedValue;
|
||||
setting.initialValue = updatedValue;
|
||||
} );
|
||||
setSetting( 'wcAdminSetting', settings );
|
||||
setSetting( 'wcAdminSettings', settings );
|
||||
}
|
||||
|
||||
saveChanges = source => {
|
||||
const { settings } = this.state;
|
||||
const { query } = this.props;
|
||||
this.persistChanges( this.state );
|
||||
this.props.updateSettings( { wc_admin: settings } );
|
||||
|
||||
|
@ -146,6 +147,15 @@ class Settings extends Component {
|
|||
|
||||
// TODO: remove this optimistic set of isDirty to false once #2541 is resolved.
|
||||
this.setState( { saving: true, isDirty: false } );
|
||||
|
||||
// On save, reset persisted query properties of Nav Menu links to default
|
||||
query.period = undefined;
|
||||
query.compare = undefined;
|
||||
query.before = undefined;
|
||||
query.after = undefined;
|
||||
query.interval = undefined;
|
||||
query.type = undefined;
|
||||
window.wpNavMenuUrlUpdate( query );
|
||||
};
|
||||
|
||||
handleInputChange( e ) {
|
||||
|
|
|
@ -115,7 +115,7 @@ export class Controller extends Component {
|
|||
const { url, params } = match;
|
||||
const query = this.getQuery( location.search );
|
||||
|
||||
window.wpNavMenuUrlUpdate( page, query );
|
||||
window.wpNavMenuUrlUpdate( query );
|
||||
window.wpNavMenuClassChange( page, url );
|
||||
return createElement( page.container, { params, path: url, pathMatch: page.path, query } );
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ export function updateLinkHref( item, nextQuery, excludedScreens ) {
|
|||
}
|
||||
|
||||
// Update's wc-admin links in wp-admin menu
|
||||
window.wpNavMenuUrlUpdate = function( page, query ) {
|
||||
window.wpNavMenuUrlUpdate = function( query ) {
|
||||
const excludedScreens = applyFilters( TIME_EXCLUDED_SCREENS_FILTER, [
|
||||
'devdocs',
|
||||
'stock',
|
||||
|
|
Loading…
Reference in New Issue