create action and reducer for updating the redux store
Co-authored-by: Deniz Kusefoglu <deniz@influxdata.com>pull/10616/head
parent
076e47b9e5
commit
7cb3132a09
|
@ -50,3 +50,10 @@ export const updateAxes = axes => ({
|
|||
axes,
|
||||
},
|
||||
})
|
||||
|
||||
export const updateOptions = options => ({
|
||||
type: 'UPDATE_OPTIONS',
|
||||
payload: {
|
||||
options,
|
||||
},
|
||||
})
|
||||
|
|
|
@ -26,10 +26,12 @@ class GraphOptionsTimeFormat extends Component {
|
|||
}
|
||||
|
||||
handleChooseFormat = formatOption => {
|
||||
const {onTimeFormatChange} = this.props
|
||||
if (formatOption.text === 'Custom') {
|
||||
this.setState({customFormat: true})
|
||||
} else {
|
||||
this.setState({format: formatOption.text, customFormat: false})
|
||||
onTimeFormatChange(formatOption.text)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import {MAX_THRESHOLDS} from 'src/dashboards/constants/gaugeColors'
|
|||
import {
|
||||
updateSingleStatType,
|
||||
updateSingleStatColors,
|
||||
updateAxes,
|
||||
updateOptions,
|
||||
} from 'src/dashboards/actions/cellEditorOverlay'
|
||||
|
||||
const formatColor = color => {
|
||||
|
@ -40,7 +40,8 @@ class TableOptions extends Component {
|
|||
handleChooseSortBy = () => {}
|
||||
|
||||
handleTimeFormatChange = timeFormat => {
|
||||
this.setState({...this.state, timeFormat})
|
||||
const {options, handleUpdateOptions} = this.props
|
||||
handleUpdateOptions({...options, timeFormat})
|
||||
}
|
||||
|
||||
handleToggleTimeAxis = () => {}
|
||||
|
@ -151,16 +152,16 @@ TableOptions.propTypes = {
|
|||
),
|
||||
handleUpdateSingleStatType: func.isRequired,
|
||||
handleUpdateSingleStatColors: func.isRequired,
|
||||
handleUpdateAxes: func.isRequired,
|
||||
axes: shape({}).isRequired,
|
||||
handleUpdateOptions: func.isRequired,
|
||||
options: shape({}).isRequired,
|
||||
}
|
||||
|
||||
const mapStateToProps = ({
|
||||
cellEditorOverlay: {singleStatType, singleStatColors, cell: {axes}},
|
||||
cellEditorOverlay: {singleStatType, singleStatColors, cell: {options}},
|
||||
}) => ({
|
||||
singleStatType,
|
||||
singleStatColors,
|
||||
axes,
|
||||
options,
|
||||
})
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
@ -172,7 +173,7 @@ const mapDispatchToProps = dispatch => ({
|
|||
updateSingleStatColors,
|
||||
dispatch
|
||||
),
|
||||
handleUpdateAxes: bindActionCreators(updateAxes, dispatch),
|
||||
handleUpdateOptions: bindActionCreators(updateOptions, dispatch),
|
||||
})
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(TableOptions)
|
||||
|
|
|
@ -132,7 +132,7 @@ export const DEFAULT_TABLE_COLORS = [
|
|||
]
|
||||
|
||||
export const DEFAULT_TABLE_OPTIONS = {
|
||||
timeFormat: '',
|
||||
timeFormat: 'MM/DD/YYYY HH:mm:ss.ss',
|
||||
verticalTimeAxis: false,
|
||||
sortBy: 'time',
|
||||
wrapping: 'truncate',
|
||||
|
|
|
@ -84,6 +84,13 @@ export default function cellEditorOverlay(state = initialState, action) {
|
|||
|
||||
return {...state, cell}
|
||||
}
|
||||
|
||||
case 'UPDATE_OPTIONS': {
|
||||
const {options} = action.payload
|
||||
const cell = {...state.cell, options}
|
||||
|
||||
return {...state, cell}
|
||||
}
|
||||
}
|
||||
|
||||
return state
|
||||
|
|
Loading…
Reference in New Issue