Merge pull request #1756 from influxdata/fix/remove_auto_group_by_kapa_alerts-1730

Prevent 'auto' GROUP BY option in Kapacitor rule builder
pull/1763/head
Jared Scheib 2017-07-21 16:07:37 -07:00 committed by GitHub
commit 30eb59ca7d
5 changed files with 15 additions and 6 deletions

View File

@ -5,6 +5,7 @@
1. [#1752](https://github.com/influxdata/chronograf/pull/1752): Clarify BoltPath server flag help text by making example the default path
1. [#1703](https://github.com/influxdata/chronograf/pull/1703): Fix cell name cancel not reverting to original name
1. [#1751](https://github.com/influxdata/chronograf/pull/1751): Fix typo that may have affected PagerDuty node creation in Kapacitor
1. [#1756](https://github.com/influxdata/chronograf/pull/1756): Prevent 'auto' GROUP BY as option in Kapacitor rule builder when applying a function to a field
### Features
1. [#1717](https://github.com/influxdata/chronograf/pull/1717): View server generated TICKscripts

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