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}
editQueryStatus={editQueryStatus}
staticLegend={isStaticLegend}
isInCEO={true}
/>
<CEOBottom>
<OverlayControls

View File

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

View File

@ -40,6 +40,7 @@ const RefreshingGraph = ({
editQueryStatus,
handleSetHoverTime,
grabDataForDownload,
isInCEO,
}) => {
const prefix = (axes && axes.y.prefix) || ''
const suffix = (axes && axes.y.suffix) || ''
@ -106,6 +107,7 @@ const RefreshingGraph = ({
tableOptions={tableOptions}
resizerTopHeight={resizerTopHeight}
handleSetHoverTime={handleSetHoverTime}
isInCEO={isInCEO}
/>
)
}
@ -165,6 +167,7 @@ RefreshingGraph.propTypes = {
tableOptions: shape({}),
hoverTime: string.isRequired,
handleSetHoverTime: func.isRequired,
isInCEO: bool,
}
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) {
const updatedProps = _.keys(nextProps).filter(
k => !_.isEqual(this.props[k], nextProps[k])
)
const {sortField, sortDirection} = this.state
const {tableOptions, handleUpdateTableOptions} = nextProps
const {
sortBy: {internalName},
fieldNames,
verticalTimeAxis,
timeFormat,
} = tableOptions
const {tableOptions} = nextProps
const {sortBy: {internalName}, verticalTimeAxis, timeFormat} = tableOptions
let data
let sortedLabels
let computedFieldNames
let fieldNames
if (
_.includes(updatedProps, 'data') ||
@ -85,15 +88,12 @@ class TableGraph extends Component {
)
data = returned.data
sortedLabels = returned.sortedLabels
computedFieldNames = computeFieldNames(fieldNames, sortedLabels)
handleUpdateTableOptions({
...tableOptions,
fieldNames: computedFieldNames,
})
fieldNames = computeFieldNames(tableOptions.fieldNames, sortedLabels)
this.handleUpdateTableOptions(fieldNames, tableOptions)
} else {
data = this.state.data
sortedLabels = this.state.sortedLabels
computedFieldNames = computeFieldNames(fieldNames, sortedLabels)
fieldNames = computeFieldNames(tableOptions.fieldNames, sortedLabels)
}
if (_.isEmpty(data[0])) {
@ -125,7 +125,7 @@ class TableGraph extends Component {
sortFieldName,
direction,
verticalTimeAxis,
computedFieldNames,
fieldNames,
timeFormat
)
@ -453,14 +453,11 @@ TableGraph.propTypes = {
handleSetHoverTime: func,
colors: colorsStringSchema,
queryASTs: arrayOf(shape()),
}
const mapStateToProps = () => {
return {}
isInCEO: bool,
}
const mapDispatchToProps = dispatch => ({
handleUpdateTableOptions: bindActionCreators(updateTableOptions, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(TableGraph)
export default connect(null, mapDispatchToProps)(TableGraph)