scroll import action to import section of settings page
This commit is contained in:
parent
d3c1d34a60
commit
d2b48f0fcd
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { Button } from '@wordpress/components';
|
||||
import { Component, Fragment } from '@wordpress/element';
|
||||
import { Component, Fragment, createRef } from '@wordpress/element';
|
||||
import { compose } from '@wordpress/compose';
|
||||
import { partial, remove, transform } from 'lodash';
|
||||
import { withDispatch } from '@wordpress/data';
|
||||
|
@ -39,12 +39,15 @@ class Settings extends Component {
|
|||
isDirty: false,
|
||||
};
|
||||
|
||||
this.importRef = createRef();
|
||||
this.handleInputChange = this.handleInputChange.bind( this );
|
||||
this.warnIfUnsavedChanges = this.warnIfUnsavedChanges.bind( this );
|
||||
this.scrollToImport = this.scrollToImport.bind( this );
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
window.addEventListener( 'beforeunload', this.warnIfUnsavedChanges );
|
||||
setTimeout( this.scrollToImport, 250 );
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
@ -162,6 +165,13 @@ class Settings extends Component {
|
|||
this.setState( { settings, isDirty: true } );
|
||||
}
|
||||
|
||||
scrollToImport() {
|
||||
const { query } = this.props;
|
||||
if ( query.import === 'true' ) {
|
||||
window.scrollTo( 0, this.importRef.current.offsetTop );
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { createNotice } = this.props;
|
||||
const { hasError } = this.state;
|
||||
|
@ -190,6 +200,7 @@ class Settings extends Component {
|
|||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<span ref={ this.importRef } />
|
||||
<HistoricalData createNotice={ createNotice } />
|
||||
</Fragment>
|
||||
);
|
||||
|
|
|
@ -52,7 +52,7 @@ class WC_Admin_Notes_Historical_Data {
|
|||
$note->add_action(
|
||||
'get-started',
|
||||
__( 'Get Started', 'woocommerce-admin' ),
|
||||
'?page=wc-admin&path=/analytics/settings',
|
||||
'?page=wc-admin&path=/analytics/settings&import=true',
|
||||
'actioned',
|
||||
true
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue