* Settings: fix date range persistance

* set undefined on persisted on save

* add comment
This commit is contained in:
Paul Sealock 2019-11-29 09:54:15 +13:00 committed by GitHub
parent d6c77de3cd
commit a5a67b107e
2 changed files with 14 additions and 4 deletions

View File

@ -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 ) {

View File

@ -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',