| 1 |
/** |
| 2 |
* External dependencies |
| 3 |
*/ |
| 4 |
import ChartEditor from '../ChartEditor.js'; |
| 5 |
|
| 6 |
/** |
| 7 |
* WordPress dependencies |
| 8 |
*/ |
| 9 |
const { __ } = wp.i18n; |
| 10 |
|
| 11 |
const { |
| 12 |
Component, |
| 13 |
Fragment |
| 14 |
} = wp.element; |
| 15 |
|
| 16 |
const { |
| 17 |
Button, |
| 18 |
Modal, |
| 19 |
PanelBody |
| 20 |
} = wp.components; |
| 21 |
|
| 22 |
class ManualData extends Component { |
| 23 |
constructor() { |
| 24 |
super( ...arguments ); |
| 25 |
|
| 26 |
this.toggleModal = this.toggleModal.bind( this ); |
| 27 |
|
| 28 |
this.state = { |
| 29 |
isOpen: false |
| 30 |
}; |
| 31 |
} |
| 32 |
|
| 33 |
toggleModal() { |
| 34 |
this.setState({ isOpen: ! this.state.isOpen }); |
| 35 |
} |
| 36 |
|
| 37 |
render() { |
| 38 |
return ( |
| 39 |
( 'community' !== visualizerLocalize.isPro ) ? |
| 40 |
<Fragment> |
| 41 |
|
| 42 |
<PanelBody |
| 43 |
title={ __( 'Manual Data' ) } |
| 44 |
initialOpen={ false } |
| 45 |
> |
| 46 |
|
| 47 |
<p>{ __( 'You can manually edit the chart data using a spreadsheet like editor.' ) }</p> |
| 48 |
|
| 49 |
<Button |
| 50 |
isPrimary |
| 51 |
isLarge |
| 52 |
isBusy={ this.state.isOpen } |
| 53 |
onClick={ this.toggleModal } |
| 54 |
> |
| 55 |
{ __( 'View Editor' ) } |
| 56 |
</Button> |
| 57 |
|
| 58 |
</PanelBody> |
| 59 |
|
| 60 |
{ this.state.isOpen && ( |
| 61 |
<Modal |
| 62 |
title={ 'Chart Editor' } |
| 63 |
onRequestClose={ this.toggleModal } |
| 64 |
shouldCloseOnClickOutside={ false } |
| 65 |
> |
| 66 |
<ChartEditor |
| 67 |
chart={ this.props.chart } |
| 68 |
editChartData={ this.props.editChartData } |
| 69 |
toggleModal={ this.toggleModal } |
| 70 |
/> |
| 71 |
</Modal> |
| 72 |
) } |
| 73 |
|
| 74 |
</Fragment> : |
| 75 |
<PanelBody |
| 76 |
title={ __( 'Manual Data' ) } |
| 77 |
icon="lock" |
| 78 |
initialOpen={ false } |
| 79 |
> |
| 80 |
|
| 81 |
<p>{ __( 'Enable this feature in PRO version!' ) }</p> |
| 82 |
|
| 83 |
<Button |
| 84 |
isPrimary |
| 85 |
href={ visualizerLocalize.proTeaser } |
| 86 |
target="_blank" |
| 87 |
> |
| 88 |
{ __( 'Upgrade Now' ) } |
| 89 |
</Button> |
| 90 |
|
| 91 |
</PanelBody> |
| 92 |
); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
export default ManualData; |
| 97 |
|