Skip to content

Commit

Permalink
Merge pull request #1756 from influxdata/fix/remove_auto_group_by_kap…
Browse files Browse the repository at this point in the history
…a_alerts-1730

Prevent 'auto' GROUP BY option in Kapacitor rule builder
  • Loading branch information
jaredscheib committed Jul 21, 2017
2 parents c7d5c84 + 8bc45fb commit 30eb59c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ui/src/data_explorer/components/GroupByTimeDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
13 changes: 10 additions & 3 deletions ui/src/kapacitor/components/DataSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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)
},

Expand Down Expand Up @@ -109,7 +116,7 @@ export const DataSection = React.createClass({
},

renderQueryBuilder() {
const {query} = this.props
const {query, isKapacitorRule} = this.props

return (
<div className="query-builder">
Expand All @@ -129,7 +136,7 @@ export const DataSection = React.createClass({
onToggleField={this.handleToggleField}
onGroupByTime={this.handleGroupByTime}
applyFuncsToField={this.handleApplyFuncsToField}
isKapacitorRule={true}
isKapacitorRule={isKapacitorRule}
/>
</div>
)
Expand Down
1 change: 1 addition & 0 deletions ui/src/kapacitor/components/KapacitorRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const KapacitorRule = React.createClass({
actions={queryActions}
onAddEvery={this.handleAddEvery}
onRemoveEvery={this.handleRemoveEvery}
isKapacitorRule={true}
/>
<ValuesSection
rule={rule}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/utils/queryTransitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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
Expand Down

0 comments on commit 30eb59c

Please sign in to comment.