Merge pull request woocommerce/woocommerce-admin#2799 from woocommerce/fix/2243

scroll import action to import section of settings page
This commit is contained in:
Ron Rennick 2019-09-03 14:16:58 -03:00 committed by GitHub
commit 6fc5dc22ee
6 changed files with 63 additions and 9 deletions

View File

@ -12,7 +12,7 @@ import { withDispatch } from '@wordpress/data';
/** /**
* WooCommerce dependencies * WooCommerce dependencies
*/ */
import { SectionHeader, useFilters } from '@woocommerce/components'; import { SectionHeader, useFilters, ScrollTo } from '@woocommerce/components';
/** /**
* Internal dependencies * Internal dependencies
@ -163,7 +163,7 @@ class Settings extends Component {
} }
render() { render() {
const { createNotice } = this.props; const { createNotice, query } = this.props;
const { hasError } = this.state; const { hasError } = this.state;
if ( hasError ) { if ( hasError ) {
return null; return null;
@ -190,7 +190,13 @@ class Settings extends Component {
</Button> </Button>
</div> </div>
</div> </div>
<HistoricalData createNotice={ createNotice } /> { query.import === 'true' ? (
<ScrollTo offset="-56">
<HistoricalData createNotice={ createNotice } />
</ScrollTo>
) : (
<HistoricalData createNotice={ createNotice } />
) }
</Fragment> </Fragment>
); );
} }

View File

@ -186,10 +186,7 @@ class BusinessDetails extends Component {
<p>{ benefit.description }</p> <p>{ benefit.description }</p>
</div> </div>
<div className="woocommerce-profile-wizard__benefit-toggle"> <div className="woocommerce-profile-wizard__benefit-toggle">
<FormToggle <FormToggle checked={ values[ benefit.slug ] } { ...getInputProps( benefit.slug ) } />
checked={ values[ benefit.slug ] }
{ ...getInputProps( benefit.slug ) }
/>
</div> </div>
</div> </div>
) ) } ) ) }

View File

@ -1,5 +1,6 @@
# 4.0.0 # 4.0.0
- Changed the <List /> `description` prop to `content` and allowed content nodes to be passed in addition to strings. - Added a new `<ScrollTo />` component.
- Changed the `<List />` `description` prop to `content` and allowed content nodes to be passed in addition to strings.
# 3.2.0 # 3.2.0
- AdvancedFilters component: fire `onAdvancedFilterAction` for match changes. - AdvancedFilters component: fire `onAdvancedFilterAction` for match changes.

View File

@ -42,6 +42,7 @@ export { default as SearchListControl } from './search-list-control';
export { default as SearchListItem } from './search-list-control/item'; export { default as SearchListItem } from './search-list-control/item';
export { default as SectionHeader } from './section-header'; export { default as SectionHeader } from './section-header';
export { default as SegmentedSelection } from './segmented-selection'; export { default as SegmentedSelection } from './segmented-selection';
export { default as ScrollTo } from './scroll-to';
export { default as SimpleSelectControl } from './simple-select-control'; export { default as SimpleSelectControl } from './simple-select-control';
export { default as SplitButton } from './split-button'; export { default as SplitButton } from './split-button';
export { default as Spinner } from './spinner'; export { default as Spinner } from './spinner';

View File

@ -0,0 +1,49 @@
/** @format */
/**
* External dependencies
*/
import { Component, createRef } from '@wordpress/element';
import PropTypes from 'prop-types';
class ScrollTo extends Component {
constructor( props ) {
super( props );
this.scrollTo = this.scrollTo.bind( this );
}
componentDidMount() {
setTimeout( this.scrollTo, 250 );
}
scrollTo() {
const { offset } = this.props;
if ( this.ref.current && this.ref.current.offsetTop ) {
window.scrollTo( 0, this.ref.current.offsetTop + parseInt( offset ) );
} else {
setTimeout( this.scrollTo, 250 );
}
}
render() {
const { children } = this.props;
this.ref = createRef();
return (
<span ref={ this.ref }>
{ children }
</span>
);
}
}
ScrollTo.propTypes = {
/**
* The offset from the top of the component.
*/
offset: PropTypes.string,
};
ScrollTo.defaultProps = {
offset: '0',
};
export default ScrollTo;

View File

@ -52,7 +52,7 @@ class WC_Admin_Notes_Historical_Data {
$note->add_action( $note->add_action(
'get-started', 'get-started',
__( 'Get Started', 'woocommerce-admin' ), __( 'Get Started', 'woocommerce-admin' ),
'?page=wc-admin&path=/analytics/settings', '?page=wc-admin&path=/analytics/settings&import=true',
'actioned', 'actioned',
true true
); );