2019-04-30 00:35:37 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2021-05-25 15:14:14 +00:00
|
|
|
import { TextControl } from '@wordpress/components';
|
|
|
|
import { trash, Icon } from '@wordpress/icons';
|
2021-06-24 14:18:29 +00:00
|
|
|
import ChevronUpIcon from 'gridicons/dist/chevron-up';
|
|
|
|
import ChevronDownIcon from 'gridicons/dist/chevron-down';
|
2019-05-22 20:43:45 +00:00
|
|
|
import { Component, Fragment } from '@wordpress/element';
|
2019-04-30 00:35:37 +00:00
|
|
|
import { MenuItem } from '@woocommerce/components';
|
|
|
|
|
|
|
|
class SectionControls extends Component {
|
|
|
|
constructor( props ) {
|
|
|
|
super( props );
|
|
|
|
this.onMoveUp = this.onMoveUp.bind( this );
|
|
|
|
this.onMoveDown = this.onMoveDown.bind( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
onMoveUp() {
|
|
|
|
const { onMove, onToggle } = this.props;
|
|
|
|
onMove( -1 );
|
|
|
|
// Close the dropdown
|
|
|
|
onToggle();
|
|
|
|
}
|
|
|
|
|
|
|
|
onMoveDown() {
|
|
|
|
const { onMove, onToggle } = this.props;
|
|
|
|
onMove( 1 );
|
|
|
|
// Close the dropdown
|
|
|
|
onToggle();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-02-14 02:23:21 +00:00
|
|
|
const {
|
|
|
|
onRemove,
|
|
|
|
isFirst,
|
|
|
|
isLast,
|
|
|
|
onTitleBlur,
|
|
|
|
onTitleChange,
|
|
|
|
titleInput,
|
|
|
|
} = this.props;
|
2019-04-30 00:35:37 +00:00
|
|
|
|
|
|
|
return (
|
2019-05-22 20:43:45 +00:00
|
|
|
<Fragment>
|
|
|
|
<div className="woocommerce-ellipsis-menu__item">
|
|
|
|
<TextControl
|
|
|
|
label={ __( 'Section Title', 'woocommerce-admin' ) }
|
|
|
|
onBlur={ onTitleBlur }
|
|
|
|
onChange={ onTitleChange }
|
|
|
|
required
|
|
|
|
value={ titleInput }
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-dashboard-section-controls">
|
|
|
|
{ ! isFirst && (
|
|
|
|
<MenuItem isClickable onInvoke={ this.onMoveUp }>
|
2020-02-14 02:23:21 +00:00
|
|
|
<Icon
|
2021-06-24 14:18:29 +00:00
|
|
|
icon={ <ChevronUpIcon /> }
|
2020-02-14 02:23:21 +00:00
|
|
|
label={ __( 'Move up' ) }
|
2021-05-25 15:14:14 +00:00
|
|
|
size={ 20 }
|
|
|
|
className="icon-control"
|
2020-02-14 02:23:21 +00:00
|
|
|
/>
|
2019-05-22 20:43:45 +00:00
|
|
|
{ __( 'Move up', 'woocommerce-admin' ) }
|
|
|
|
</MenuItem>
|
|
|
|
) }
|
|
|
|
{ ! isLast && (
|
|
|
|
<MenuItem isClickable onInvoke={ this.onMoveDown }>
|
2020-02-14 02:23:21 +00:00
|
|
|
<Icon
|
2021-06-24 14:18:29 +00:00
|
|
|
icon={ <ChevronDownIcon /> }
|
2021-05-25 15:14:14 +00:00
|
|
|
size={ 20 }
|
2021-06-24 20:08:16 +00:00
|
|
|
label={ __( 'Move down' ) }
|
2021-05-25 15:14:14 +00:00
|
|
|
className="icon-control"
|
2020-02-14 02:23:21 +00:00
|
|
|
/>
|
2021-06-24 20:08:16 +00:00
|
|
|
{ __( 'Move down', 'woocommerce-admin' ) }
|
2019-05-22 20:43:45 +00:00
|
|
|
</MenuItem>
|
|
|
|
) }
|
|
|
|
<MenuItem isClickable onInvoke={ onRemove }>
|
2021-05-25 15:14:14 +00:00
|
|
|
<Icon
|
|
|
|
icon={ trash }
|
|
|
|
size={ 20 }
|
|
|
|
label={ __( 'Remove block' ) }
|
|
|
|
className="icon-control"
|
|
|
|
/>
|
2019-05-22 20:43:45 +00:00
|
|
|
{ __( 'Remove section', 'woocommerce-admin' ) }
|
2019-04-30 00:35:37 +00:00
|
|
|
</MenuItem>
|
2019-05-22 20:43:45 +00:00
|
|
|
</div>
|
|
|
|
</Fragment>
|
2019-04-30 00:35:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SectionControls;
|