diff --git a/ui/src/dashboards/actions/cellEditorOverlay.js b/ui/src/dashboards/actions/cellEditorOverlay.js
index 3ef36d5ec..c70e4f261 100644
--- a/ui/src/dashboards/actions/cellEditorOverlay.js
+++ b/ui/src/dashboards/actions/cellEditorOverlay.js
@@ -43,3 +43,10 @@ export const updateGaugeColors = gaugeColors => ({
gaugeColors,
},
})
+
+export const updateAxes = axes => ({
+ type: 'UPDATE_AXES',
+ payload: {
+ axes,
+ },
+})
diff --git a/ui/src/dashboards/components/AxesOptions.js b/ui/src/dashboards/components/AxesOptions.js
index 5bcaea167..d5cbf9d1f 100644
--- a/ui/src/dashboards/components/AxesOptions.js
+++ b/ui/src/dashboards/components/AxesOptions.js
@@ -1,4 +1,6 @@
-import React, {PropTypes} from 'react'
+import React, {Component, PropTypes} from 'react'
+import {connect} from 'react-redux'
+import {bindActionCreators} from 'redux'
import OptIn from 'shared/components/OptIn'
import Input from 'src/dashboards/components/DisplayOptionsInput'
@@ -11,105 +13,158 @@ import {GRAPH_TYPES} from 'src/dashboards/graphics/graph'
const {LINEAR, LOG, BASE_2, BASE_10} = DISPLAY_OPTIONS
const getInputMin = scale => (scale === LOG ? '0' : null)
-const AxesOptions = ({
- axes: {y: {bounds, label, prefix, suffix, base, scale, defaultYLabel}},
- onSetBase,
- onSetScale,
- onSetLabel,
- onSetPrefixSuffix,
- onSetYAxisBoundMin,
- onSetYAxisBoundMax,
- cellType,
-}) => {
- const [min, max] = bounds
+import {updateAxes} from 'src/dashboards/actions/cellEditorOverlay'
- const {menuOption} = GRAPH_TYPES.find(graph => graph.type === cellType)
+class AxesOptions extends Component {
+ handleSetPrefixSuffix = e => {
+ const {handleUpdateAxes, axes} = this.props
+ const {prefix, suffix} = e.target.form
- return (
-
-
-
- {menuOption} Controls
-
-
+
+
+ )
+ }
}
const {arrayOf, func, shape, string} = PropTypes
@@ -128,13 +183,7 @@ AxesOptions.defaultProps = {
}
AxesOptions.propTypes = {
- cellType: string.isRequired,
- onSetPrefixSuffix: func.isRequired,
- onSetYAxisBoundMin: func.isRequired,
- onSetYAxisBoundMax: func.isRequired,
- onSetLabel: func.isRequired,
- onSetScale: func.isRequired,
- onSetBase: func.isRequired,
+ type: string.isRequired,
axes: shape({
y: shape({
bounds: arrayOf(string),
@@ -142,6 +191,16 @@ AxesOptions.propTypes = {
defaultYLabel: string,
}),
}).isRequired,
+ handleUpdateAxes: func.isRequired,
}
-export default AxesOptions
+const mapStateToProps = ({cellEditorOverlay: {cell: {axes, type}}}) => ({
+ axes,
+ type,
+})
+
+const mapDispatchToProps = dispatch => ({
+ handleUpdateAxes: bindActionCreators(updateAxes, dispatch),
+})
+
+export default connect(mapStateToProps, mapDispatchToProps)(AxesOptions)
diff --git a/ui/src/dashboards/components/CellEditorOverlay.js b/ui/src/dashboards/components/CellEditorOverlay.js
index b37efddc8..534c28d88 100644
--- a/ui/src/dashboards/components/CellEditorOverlay.js
+++ b/ui/src/dashboards/components/CellEditorOverlay.js
@@ -28,7 +28,7 @@ class CellEditorOverlay extends Component {
constructor(props) {
super(props)
- const {cell: {queries, axes}, sources} = props
+ const {cell: {queries}, sources} = props
let source = _.get(queries, ['0', 'source'], null)
source = sources.find(s => s.links.self === source) || props.source
@@ -45,7 +45,6 @@ class CellEditorOverlay extends Component {
queriesWorkingDraft,
activeQueryIndex: 0,
isDisplayOptionsTabActive: false,
- axes,
}
}
@@ -67,7 +66,7 @@ class CellEditorOverlay extends Component {
}
handleSetSuffix = e => {
- const {axes} = this.state
+ const {axes} = this.props.cell
this.setState({
axes: {
@@ -96,46 +95,6 @@ class CellEditorOverlay extends Component {
this.setState({queriesWorkingDraft: nextQueries})
}
- handleSetYAxisBoundMin = min => {
- const {axes} = this.state
- const {y: {bounds: [, max]}} = axes
-
- this.setState({
- axes: {...axes, y: {...axes.y, bounds: [min, max]}},
- })
- }
-
- handleSetYAxisBoundMax = max => {
- const {axes} = this.state
- const {y: {bounds: [min]}} = axes
-
- this.setState({
- axes: {...axes, y: {...axes.y, bounds: [min, max]}},
- })
- }
-
- handleSetLabel = label => {
- const {axes} = this.state
-
- this.setState({axes: {...axes, y: {...axes.y, label}}})
- }
-
- handleSetPrefixSuffix = e => {
- const {axes} = this.state
- const {prefix, suffix} = e.target.form
-
- this.setState({
- axes: {
- ...axes,
- y: {
- ...axes.y,
- prefix: prefix.value,
- suffix: suffix.value,
- },
- },
- })
- }
-
handleAddQuery = () => {
const {queriesWorkingDraft} = this.state
const newIndex = queriesWorkingDraft.length
@@ -157,7 +116,7 @@ class CellEditorOverlay extends Component {
}
handleSaveCell = () => {
- const {queriesWorkingDraft, axes} = this.state
+ const {queriesWorkingDraft} = this.state
const {cell, singleStatColors, gaugeColors} = this.props
@@ -185,7 +144,6 @@ class CellEditorOverlay extends Component {
this.props.onSave({
...cell,
queries,
- axes,
colors,
})
}
@@ -198,34 +156,6 @@ class CellEditorOverlay extends Component {
this.setState({activeQueryIndex})
}
- handleSetBase = base => () => {
- const {axes} = this.state
-
- this.setState({
- axes: {
- ...axes,
- y: {
- ...axes.y,
- base,
- },
- },
- })
- }
-
- handleSetScale = scale => () => {
- const {axes} = this.state
-
- this.setState({
- axes: {
- ...axes,
- y: {
- ...axes.y,
- scale,
- },
- },
- })
- }
-
handleSetQuerySource = source => {
const queriesWorkingDraft = this.state.queriesWorkingDraft.map(q => ({
..._.cloneDeep(q),
@@ -325,7 +255,6 @@ class CellEditorOverlay extends Component {
} = this.props
const {
- axes,
activeQueryIndex,
isDisplayOptionsTabActive,
queriesWorkingDraft,
@@ -355,7 +284,6 @@ class CellEditorOverlay extends Component {
initialBottomHeight={INITIAL_HEIGHTS.queryMaker}
>
{isDisplayOptionsTabActive
?
: {
- const {
- cell,
- onSetBase,
- onSetScale,
- onSetLabel,
- onSetPrefixSuffix,
- onSetYAxisBoundMin,
- onSetYAxisBoundMax,
- onSetSuffix,
- } = this.props
- const {axes, axes: {y: {suffix}}} = this.state
+ const {cell, cell: {axes: {y: {suffix}}}, onSetSuffix} = this.props
switch (cell.type) {
case 'gauge':
@@ -53,18 +43,7 @@ class DisplayOptions extends Component {
case 'single-stat':
return
default:
- return (
-
- )
+ return
}
}
@@ -83,19 +62,20 @@ DisplayOptions.propTypes = {
cell: shape({
type: string.isRequired,
}).isRequired,
- onSetPrefixSuffix: func.isRequired,
+ axes: shape({
+ y: shape({
+ bounds: arrayOf(string),
+ label: string,
+ defaultYLabel: string,
+ }),
+ }).isRequired,
onSetSuffix: func.isRequired,
- onSetYAxisBoundMin: func.isRequired,
- onSetYAxisBoundMax: func.isRequired,
- onSetScale: func.isRequired,
- onSetLabel: func.isRequired,
- onSetBase: func.isRequired,
- axes: shape({}).isRequired,
queryConfigs: arrayOf(shape()).isRequired,
}
-const mapStateToProps = ({cellEditorOverlay: {cell}}) => ({
+const mapStateToProps = ({cellEditorOverlay: {cell, cell: {axes}}}) => ({
cell,
+ axes,
})
export default connect(mapStateToProps, null)(DisplayOptions)
diff --git a/ui/src/dashboards/components/Visualization.js b/ui/src/dashboards/components/Visualization.js
index 5025ef08b..f34d17333 100644
--- a/ui/src/dashboards/components/Visualization.js
+++ b/ui/src/dashboards/components/Visualization.js
@@ -90,11 +90,12 @@ DashVisualization.contextTypes = {
}
const mapStateToProps = ({
- cellEditorOverlay: {singleStatColors, gaugeColors, cell: {type}},
+ cellEditorOverlay: {singleStatColors, gaugeColors, cell: {type, axes}},
}) => ({
gaugeColors,
singleStatColors,
type,
+ axes,
})
export default connect(mapStateToProps, null)(DashVisualization)
diff --git a/ui/src/dashboards/reducers/cellEditorOverlay.js b/ui/src/dashboards/reducers/cellEditorOverlay.js
index c57ae87e0..64ca629a6 100644
--- a/ui/src/dashboards/reducers/cellEditorOverlay.js
+++ b/ui/src/dashboards/reducers/cellEditorOverlay.js
@@ -68,6 +68,13 @@ export default function cellEditorOverlay(state = initialState, action) {
return {...state, gaugeColors}
}
+
+ case 'UPDATE_AXES': {
+ const {axes} = action.payload
+ const cell = {...state.cell, axes}
+
+ return {...state, cell}
+ }
}
return state