Implement stronger system for rendering appropriate graph options

pull/10616/head
Alex P 2017-12-08 10:13:14 -08:00
parent 1ba52966f8
commit 8762a8a456
1 changed files with 44 additions and 34 deletions

View File

@ -33,14 +33,13 @@ class DisplayOptions extends Component {
: axes
}
render() {
renderOptions = () => {
const {
colors,
onSetBase,
onSetScale,
onSetLabel,
selectedGraphType,
onSelectGraphType,
onSetPrefixSuffix,
onSetYAxisBoundMin,
onSetYAxisBoundMax,
@ -52,44 +51,55 @@ class DisplayOptions extends Component {
} = this.props
const {axes} = this.state
switch (selectedGraphType) {
case 'gauge':
return (
<GaugeOptions
colors={colors}
onChooseColor={onChooseColor}
onValidateColorValue={onValidateColorValue}
onUpdateColorValue={onUpdateColorValue}
onAddThreshold={onAddThreshold}
onDeleteThreshold={onDeleteThreshold}
/>
)
case 'single-stat':
return (
<SingleStatOptions
colors={colors}
onChooseColor={onChooseColor}
onValidateColorValue={onValidateColorValue}
onUpdateColorValue={onUpdateColorValue}
onAddThreshold={onAddThreshold}
onDeleteThreshold={onDeleteThreshold}
/>
)
default:
return (
<AxesOptions
selectedGraphType={selectedGraphType}
axes={axes}
onSetBase={onSetBase}
onSetLabel={onSetLabel}
onSetScale={onSetScale}
onSetPrefixSuffix={onSetPrefixSuffix}
onSetYAxisBoundMin={onSetYAxisBoundMin}
onSetYAxisBoundMax={onSetYAxisBoundMax}
/>
)
}
}
render() {
const {selectedGraphType, onSelectGraphType} = this.props
return (
<div className="display-options">
<GraphTypeSelector
selectedGraphType={selectedGraphType}
onSelectGraphType={onSelectGraphType}
/>
{selectedGraphType === 'gauge'
? <GaugeOptions
colors={colors}
onChooseColor={onChooseColor}
onValidateColorValue={onValidateColorValue}
onUpdateColorValue={onUpdateColorValue}
onAddThreshold={onAddThreshold}
onDeleteThreshold={onDeleteThreshold}
/>
: null}
{selectedGraphType === 'single-stat'
? <SingleStatOptions
colors={colors}
onChooseColor={onChooseColor}
onValidateColorValue={onValidateColorValue}
onUpdateColorValue={onUpdateColorValue}
onAddThreshold={onAddThreshold}
onDeleteThreshold={onDeleteThreshold}
/>
: null}
{selectedGraphType === !('single-stat' || 'gauge')
? <AxesOptions
selectedGraphType={selectedGraphType}
axes={axes}
onSetBase={onSetBase}
onSetLabel={onSetLabel}
onSetScale={onSetScale}
onSetPrefixSuffix={onSetPrefixSuffix}
onSetYAxisBoundMin={onSetYAxisBoundMin}
onSetYAxisBoundMax={onSetYAxisBoundMax}
/>
: null}
{this.renderOptions()}
</div>
)
}