Prevent 'auto' GROUP BY option in Kapacitor rule builder

pull/10616/head
Jared Scheib 2017-07-21 15:18:44 -07:00
parent d6db7ee084
commit 0bdc881f53
4 changed files with 14 additions and 6 deletions

View File

@ -25,7 +25,7 @@ const GroupByTimeDropdown = React.createClass({
} = this.props
let validOptions = groupByTimeOptions
if (isInDataExplorer) {
if (isInDataExplorer || isInRuleBuilder) {
validOptions = validOptions.filter(
({menuOption}) => menuOption !== DEFAULT_DASHBOARD_GROUP_BY_INTERVAL
)

View File

@ -32,6 +32,7 @@ export const DataSection = React.createClass({
onAddEvery: PropTypes.func.isRequired,
onRemoveEvery: PropTypes.func.isRequired,
timeRange: PropTypes.shape({}).isRequired,
isKapacitorRule: PropTypes.bool,
},
childContextTypes: {
@ -69,7 +70,13 @@ export const DataSection = React.createClass({
},
handleApplyFuncsToField(fieldFunc) {
this.props.actions.applyFuncsToField(this.props.query.id, fieldFunc)
this.props.actions.applyFuncsToField(
this.props.query.id,
fieldFunc,
// this 3rd arg (isKapacitorRule) makes sure 'auto' is not added as
// default group by in Kapacitor rule
this.props.isKapacitorRule
)
this.props.onAddEvery(defaultEveryFrequency)
},
@ -109,7 +116,7 @@ export const DataSection = React.createClass({
},
renderQueryBuilder() {
const {query} = this.props
const {query, isKapacitorRule} = this.props
return (
<div className="query-builder">
@ -129,7 +136,7 @@ export const DataSection = React.createClass({
onToggleField={this.handleToggleField}
onGroupByTime={this.handleGroupByTime}
applyFuncsToField={this.handleApplyFuncsToField}
isKapacitorRule={true}
isKapacitorRule={isKapacitorRule}
/>
</div>
)

View File

@ -71,6 +71,7 @@ export const KapacitorRule = React.createClass({
actions={queryActions}
onAddEvery={this.handleAddEvery}
onRemoveEvery={this.handleRemoveEvery}
isKapacitorRule={true}
/>
<ValuesSection
rule={rule}

View File

@ -86,7 +86,7 @@ export function toggleTagAcceptance(query) {
export function applyFuncsToField(
query,
{field, funcs},
isInDataExplorer = false
preventAutoGroupBy = false
) {
const shouldRemoveFuncs = funcs.length === 0
const nextFields = query.fields.map(f => {
@ -103,7 +103,7 @@ export function applyFuncsToField(
return f
})
const defaultGroupBy = isInDataExplorer
const defaultGroupBy = preventAutoGroupBy
? DEFAULT_DATA_EXPLORER_GROUP_BY_INTERVAL
: DEFAULT_DASHBOARD_GROUP_BY_INTERVAL
// If there are no functions, then there should be no GROUP BY time