PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.9.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.9.1
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / classes / Visualizer / Gutenberg / src / Components / Import / ChartImport.js

ChartImport.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.9.1, at classes/Visualizer/Gutenberg/src/Components/Import/ChartImport.js

110 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 const { __ } = wp.i18n;
5
6 const { apiFetch } = wp;
7
8 const {
9 Component,
10 Fragment
11 } = wp.element;
12
13 const {
14 Button,
15 PanelBody,
16 Placeholder,
17 SelectControl,
18 Spinner
19 } = wp.components;
20
21 class ChartImport extends Component {
22 constructor() {
23 super( ...arguments );
24
25 this.state = {
26 id: '',
27 charts: []
28 };
29 }
30
31 async componentDidMount() {
32 let charts = await apiFetch({ path: 'wp/v2/visualizer/?per_page=100' });
33 let id;
34
35 charts = charts.map( ( i, index ) => {
36 let label = i['chart_data']['visualizer-settings'].title ? i['chart_data']['visualizer-settings'].title : `#${i.id}`;
37
38 if ( 0 === index ) {
39 id = i.id;
40 }
41
42 return {
43 value: i.id,
44 label
45 };
46 });
47
48 this.setState({
49 id,
50 charts
51 });
52 }
53
54 render() {
55 return (
56 ( 'community' !== visualizerLocalize.isPro ) ?
57 <PanelBody
58 title={ __( 'Import from other chart' ) }
59 initialOpen={ false }
60 >
61
62 { 1 <= ( this.state.charts ).length ?
63 <Fragment>
64
65 <SelectControl
66 label={ __( 'You can import here data from your previously created charts.' ) }
67 value={ this.state.id }
68 options={ this.state.charts }
69 onChange={ id => this.setState({ id }) }
70 />
71
72 <Button
73 isPrimary
74 isLarge
75 isBusy={ 'getChartData' === this.props.isLoading }
76 onClick={ () => this.props.getChartData( this.state.id ) }
77 >
78 { __( 'Import Chart' ) }
79 </Button>
80
81 </Fragment> :
82 <Placeholder>
83 <Spinner />
84 </Placeholder>
85 }
86
87 </PanelBody> :
88 <PanelBody
89 title={ __( 'Import from other chart' ) }
90 icon="lock"
91 initialOpen={ false }
92 >
93
94 <p>{ __( 'Enable this feature in PRO version!' ) }</p>
95
96 <Button
97 isPrimary
98 href={ visualizerLocalize.proTeaser }
99 target="_blank"
100 >
101 { __( 'Buy Now' ) }
102 </Button>
103
104 </PanelBody>
105 );
106 }
107 }
108
109 export default ChartImport;
110