Skip to content

Commit

Permalink
Revert "Merge pull request #1585 from influxdata/revert-auto-func"
Browse files Browse the repository at this point in the history
This reverts commit 5a37e8f, reversing
changes made to 8bb869a.
  • Loading branch information
lukevmorris authored and timraymond committed Jun 15, 2017
1 parent 4e7ec0b commit 6a91690
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
1. [#1567](https://github.com/influxdata/chronograf/pull/1567): Replace the user icon with a solid style
1. [#1561](https://github.com/influxdata/chronograf/pull/1561): Disable query save in cell editor mode if the query does not have a database, measurement, and field
1. [#1575](https://github.com/influxdata/chronograf/pull/1575): Improve UX of applying functions to fields in the query builder
1. [#1560](https://github.com/influxdata/chronograf/pull/1560): Apply mean to fields by default

## v1.3.1.0 [2017-05-22]

Expand Down
33 changes: 16 additions & 17 deletions ui/spec/data_explorer/reducers/queryConfigSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,22 @@ describe('Chronograf.Reducers.queryConfig', () => {
expect(newState[queryId].fields[1].field).to.equal('a different field')
})

// TODO: uncomment when automatically applied funtions are added back to the code
// it('applies a funcs to newly selected fields', () => {
// expect(state[queryId].fields.length).to.equal(1)

// const oneFieldOneFunc = reducer(
// state,
// applyFuncsToField(queryId, {field: 'a great field', funcs: ['func1']})
// )

// const newState = reducer(
// oneFieldOneFunc,
// toggleField(queryId, {field: 'a different field', funcs: []})
// )

// expect(newState[queryId].fields[1].funcs.length).to.equal(1)
// expect(newState[queryId].fields[1].funcs[0]).to.equal('func1')
// })
it('applies a funcs to newly selected fields', () => {
expect(state[queryId].fields.length).to.equal(1)

const oneFieldOneFunc = reducer(
state,
applyFuncsToField(queryId, {field: 'a great field', funcs: ['func1']})
)

const newState = reducer(
oneFieldOneFunc,
toggleField(queryId, {field: 'a different field', funcs: []})
)

expect(newState[queryId].fields[1].funcs.length).to.equal(1)
expect(newState[queryId].fields[1].funcs[0]).to.equal('func1')
})
})
})

Expand Down
10 changes: 9 additions & 1 deletion ui/src/utils/queryTransitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ export const toggleField = (query, {field, funcs}, isKapacitorRule = false) => {
}
}

let newFuncs = ['mean']
if (query.fields.length) {
newFuncs = query.fields.find(f => f.funcs).funcs
}

return {
...query,
fields: query.fields.concat({field, funcs}),
fields: query.fields.concat({
field,
funcs: newFuncs,
}),
}
}

Expand Down

0 comments on commit 6a91690

Please sign in to comment.