add new slice form improvements (#2928)

* dont set first datasource as default

* not used

* add a disabled class if datasource is not selected

* sort datasources alphabettically

* make btn disabled is no datasource is selected

* fix linting
This commit is contained in:
Alanna Scott
2017-06-08 10:49:02 -07:00
committed by GitHub
parent 24a2f5b8f0
commit 24292dbc11
3 changed files with 30 additions and 9 deletions

View File

@@ -17,9 +17,6 @@ export default class AddSliceContainer extends React.PureComponent {
const visTypeKeys = Object.keys(visTypes);
this.vizTypeOptions = visTypeKeys.map(vt => ({ label: visTypes[vt].label, value: vt }));
this.state = {
datasourceValue: this.props.datasources[0].value,
datasourceId: this.props.datasources[0].value.split('__')[0],
datasourceType: this.props.datasources[0].value.split('__')[1],
visType: 'table',
};
}
@@ -42,14 +39,14 @@ export default class AddSliceContainer extends React.PureComponent {
});
}
changeSliceName(e) {
this.setState({ sliceName: e.target.value });
}
changeVisType(e) {
this.setState({ visType: e.value });
}
isBtnDisabled() {
return !(this.state.datasourceId && this.state.visType);
}
render() {
return (
<div className="container">
@@ -81,7 +78,11 @@ export default class AddSliceContainer extends React.PureComponent {
/>
</div>
<br />
<Button bsStyle="primary" onClick={this.gotoSlice.bind(this)}>
<Button
bsStyle="primary"
disabled={this.isBtnDisabled()}
onClick={this.gotoSlice.bind(this)}
>
Create new slice
</Button>
<br /><br />