PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.3.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.3.3
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.3.3, at classes/Visualizer/Gutenberg/src/Components/Import/ChartImport.js

109 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 isBusy={ 'getChartData' === this.props.isLoading }
75 onClick={ () => this.props.getChartData( this.state.id ) }
76 >
77 { __( 'Import Chart' ) }
78 </Button>
79
80 </Fragment> :
81 <Placeholder>
82 <Spinner />
83 </Placeholder>
84 }
85
86 </PanelBody> :
87 <PanelBody
88 title={ __( 'Import from other chart' ) }
89 icon="lock"
90 initialOpen={ false }
91 >
92
93 <p>{ __( 'Enable this feature in PRO version!' ) }</p>
94
95 <Button
96 isPrimary
97 href={ visualizerLocalize.proTeaser }
98 target="_blank"
99 >
100 { __( 'Buy Now' ) }
101 </Button>
102
103 </PanelBody>
104 );
105 }
106 }
107
108 export default ChartImport;
109