/** * External dependencies */ import { Chart } from 'react-google-charts'; import DataTable from './DataTable.js'; import FileImport from './Import/FileImport.js'; import RemoteImport from './Import/RemoteImport.js'; import ChartImport from './Import/ChartImport.js'; import DataImport from './Import/DataImport.js'; import ManualData from './Import/ManualData.js'; import Sidebar from './Sidebar.js'; import ChartPermissions from './ChartPermissions.js'; import PanelButton from './PanelButton.js'; import merge from 'merge'; import { compact, formatDate, isValidJSON, formatData } from '../utils.js'; /** * WordPress dependencies */ const { startCase } = lodash; const { __ } = wp.i18n; const { Component, Fragment } = wp.element; const { InspectorControls } = wp.blockEditor || wp.editor; class ChartSelect extends Component { constructor() { super( ...arguments ); this.state = { /** * Sidebar Route Status * * home - Initial screen. * showAdvanced - Show Advanced Options. */ route: 'home' }; } render() { let chartVersion = 'undefined' !== typeof google.visualization ? google.visualization.Version : 'current'; let chart, footer; let data = formatDate( JSON.parse( JSON.stringify( this.props.chart ) ) ); if ( 0 <= [ 'gauge', 'tabular', 'timeline' ].indexOf( this.props.chart['visualizer-chart-type']) ) { if ( 'DataTable' === data['visualizer-chart-library']) { chart = data['visualizer-chart-type']; } else { chart = this.props.chart['visualizer-chart-type']; if ( 'tabular' === chart ) { chart = 'table'; } chart = startCase( chart ); } } else { chart = `${ startCase( this.props.chart['visualizer-chart-type']) }Chart`; } if ( data['visualizer-data-exploded']) { footer = __( 'Annotations in this chart may not display here but they will display in the front end.' ); } return ( { 'home' === this.state.route && this.setState({ route: 'showAdvanced' }) } /> this.setState({ route: 'showPermissions' }) } /> } { ( 'showAdvanced' === this.state.route || 'showPermissions' === this.state.route ) && this.setState({ route: 'home' }) } isBack={ true } /> { 'showAdvanced' === this.state.route && } { 'showPermissions' === this.state.route && } }
{ ( null !== this.props.chart ) && ( 'DataTable' === data['visualizer-chart-library']) ? ( ) : ( '' !== data['visualizer-data-exploded'] ? ( ) : ( ) ) }
{ footer }
); } } export default ChartSelect;