Only update table options when in CEO

pull/10616/head
Brandon Farmer 2018-04-20 17:19:25 -07:00
parent 8c5c2fa1ed
commit 745c27a4cd
4 changed files with 24 additions and 20 deletions

View File

@ -178,6 +178,7 @@ class CellEditorOverlay extends Component<Props, State> {
queryConfigs={queriesWorkingDraft} queryConfigs={queriesWorkingDraft}
editQueryStatus={editQueryStatus} editQueryStatus={editQueryStatus}
staticLegend={isStaticLegend} staticLegend={isStaticLegend}
isInCEO={true}
/> />
<CEOBottom> <CEOBottom>
<OverlayControls <OverlayControls

View File

@ -24,6 +24,7 @@ const DashVisualization = (
staticLegend, staticLegend,
thresholdsListColors, thresholdsListColors,
tableOptions, tableOptions,
isInCEO,
}, },
{source: {links: {proxy}}} {source: {links: {proxy}}}
) => { ) => {
@ -49,6 +50,7 @@ const DashVisualization = (
editQueryStatus={editQueryStatus} editQueryStatus={editQueryStatus}
resizerTopHeight={resizerTopHeight} resizerTopHeight={resizerTopHeight}
staticLegend={staticLegend} staticLegend={staticLegend}
isInCEO={isInCEO}
/> />
</div> </div>
</div> </div>
@ -78,6 +80,7 @@ DashVisualization.propTypes = {
gaugeColors: colorsNumberSchema, gaugeColors: colorsNumberSchema,
lineColors: colorsStringSchema, lineColors: colorsStringSchema,
staticLegend: bool, staticLegend: bool,
isInCEO: bool,
} }
DashVisualization.contextTypes = { DashVisualization.contextTypes = {

View File

@ -40,6 +40,7 @@ const RefreshingGraph = ({
editQueryStatus, editQueryStatus,
handleSetHoverTime, handleSetHoverTime,
grabDataForDownload, grabDataForDownload,
isInCEO,
}) => { }) => {
const prefix = (axes && axes.y.prefix) || '' const prefix = (axes && axes.y.prefix) || ''
const suffix = (axes && axes.y.suffix) || '' const suffix = (axes && axes.y.suffix) || ''
@ -106,6 +107,7 @@ const RefreshingGraph = ({
tableOptions={tableOptions} tableOptions={tableOptions}
resizerTopHeight={resizerTopHeight} resizerTopHeight={resizerTopHeight}
handleSetHoverTime={handleSetHoverTime} handleSetHoverTime={handleSetHoverTime}
isInCEO={isInCEO}
/> />
) )
} }
@ -165,6 +167,7 @@ RefreshingGraph.propTypes = {
tableOptions: shape({}), tableOptions: shape({}),
hoverTime: string.isRequired, hoverTime: string.isRequired,
handleSetHoverTime: func.isRequired, handleSetHoverTime: func.isRequired,
isInCEO: bool,
} }
RefreshingGraph.defaultProps = { RefreshingGraph.defaultProps = {

View File

@ -58,22 +58,25 @@ class TableGraph extends Component {
} }
} }
handleUpdateTableOptions = (fieldNames, tableOptions) => {
const {isInCEO} = this.props
if (!isInCEO) {
return
}
this.props.handleUpdateTableOptions({...tableOptions, fieldNames})
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const updatedProps = _.keys(nextProps).filter( const updatedProps = _.keys(nextProps).filter(
k => !_.isEqual(this.props[k], nextProps[k]) k => !_.isEqual(this.props[k], nextProps[k])
) )
const {sortField, sortDirection} = this.state const {sortField, sortDirection} = this.state
const {tableOptions, handleUpdateTableOptions} = nextProps const {tableOptions} = nextProps
const { const {sortBy: {internalName}, verticalTimeAxis, timeFormat} = tableOptions
sortBy: {internalName},
fieldNames,
verticalTimeAxis,
timeFormat,
} = tableOptions
let data let data
let sortedLabels let sortedLabels
let computedFieldNames let fieldNames
if ( if (
_.includes(updatedProps, 'data') || _.includes(updatedProps, 'data') ||
@ -85,15 +88,12 @@ class TableGraph extends Component {
) )
data = returned.data data = returned.data
sortedLabels = returned.sortedLabels sortedLabels = returned.sortedLabels
computedFieldNames = computeFieldNames(fieldNames, sortedLabels) fieldNames = computeFieldNames(tableOptions.fieldNames, sortedLabels)
handleUpdateTableOptions({ this.handleUpdateTableOptions(fieldNames, tableOptions)
...tableOptions,
fieldNames: computedFieldNames,
})
} else { } else {
data = this.state.data data = this.state.data
sortedLabels = this.state.sortedLabels sortedLabels = this.state.sortedLabels
computedFieldNames = computeFieldNames(fieldNames, sortedLabels) fieldNames = computeFieldNames(tableOptions.fieldNames, sortedLabels)
} }
if (_.isEmpty(data[0])) { if (_.isEmpty(data[0])) {
@ -125,7 +125,7 @@ class TableGraph extends Component {
sortFieldName, sortFieldName,
direction, direction,
verticalTimeAxis, verticalTimeAxis,
computedFieldNames, fieldNames,
timeFormat timeFormat
) )
@ -453,14 +453,11 @@ TableGraph.propTypes = {
handleSetHoverTime: func, handleSetHoverTime: func,
colors: colorsStringSchema, colors: colorsStringSchema,
queryASTs: arrayOf(shape()), queryASTs: arrayOf(shape()),
} isInCEO: bool,
const mapStateToProps = () => {
return {}
} }
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
handleUpdateTableOptions: bindActionCreators(updateTableOptions, dispatch), handleUpdateTableOptions: bindActionCreators(updateTableOptions, dispatch),
}) })
export default connect(mapStateToProps, mapDispatchToProps)(TableGraph) export default connect(null, mapDispatchToProps)(TableGraph)