Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent 'auto' GROUP BY option in Kapacitor rule builder #1756

Merged
merged 2 commits into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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