import React from 'react'; import PropTypes from 'prop-types'; import { Button, Panel, Grid, Row, Col } from 'react-bootstrap'; import Select from 'react-virtualized-select'; import visTypes from '../explore/stores/visTypes'; const propTypes = { datasources: PropTypes.arrayOf(PropTypes.shape({ label: PropTypes.string.isRequired, value: PropTypes.string.isRequired, })).isRequired, }; export default class AddSliceContainer extends React.PureComponent { constructor(props) { super(props); const visTypeKeys = Object.keys(visTypes); this.vizTypeOptions = visTypeKeys.map(vt => ({ label: visTypes[vt].label, value: vt })); this.state = { visType: 'table', }; } exploreUrl() { const baseUrl = `/superset/explore/${this.state.datasourceType}/${this.state.datasourceId}`; const formData = encodeURIComponent(JSON.stringify({ viz_type: this.state.visType })); return `${baseUrl}?form_data=${formData}`; } gotoSlice() { window.location.href = this.exploreUrl(); } changeDatasource(e) { this.setState({ datasourceValue: e.value, datasourceId: e.value.split('__')[0], datasourceType: e.value.split('__')[1], }); } changeVisType(e) { this.setState({ visType: e.value }); } isBtnDisabled() { return !(this.state.datasourceId && this.state.visType); } render() { return (
Create a new slice}>

Choose a datasource




); } } AddSliceContainer.propTypes = propTypes;