Add missing suggestion params inside bodynodes function
parent
eb4b9d238f
commit
a8b6bb48c8
|
@ -17,7 +17,7 @@ import {
|
|||
|
||||
import {bodyNodes} from 'src/ifql/helpers'
|
||||
import {getSuggestions, getAST, getTimeSeries} from 'src/ifql/apis'
|
||||
import {funcNames, builder, argTypes} from 'src/ifql/constants'
|
||||
import {builder, argTypes} from 'src/ifql/constants'
|
||||
|
||||
import {Source, Service, Notification} from 'src/types'
|
||||
import {
|
||||
|
@ -408,20 +408,7 @@ export class IFQLPage extends PureComponent<Props, State> {
|
|||
|
||||
try {
|
||||
const ast = await getAST({url: links.ast, body: script})
|
||||
const suggestions = this.state.suggestions.map(s => {
|
||||
if (s.name === funcNames.JOIN) {
|
||||
return {
|
||||
...s,
|
||||
params: {
|
||||
tables: 'object',
|
||||
on: 'array',
|
||||
fn: 'function',
|
||||
},
|
||||
}
|
||||
}
|
||||
return s
|
||||
})
|
||||
const body = bodyNodes(ast, suggestions)
|
||||
const body = bodyNodes(ast, this.state.suggestions)
|
||||
const status = {type: 'success', text: ''}
|
||||
this.setState({ast, body, status})
|
||||
this.props.updateScript(script)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import uuid from 'uuid'
|
||||
import _ from 'lodash'
|
||||
import Walker from 'src/ifql/ast/walker'
|
||||
import {funcNames} from 'src/ifql/constants'
|
||||
|
||||
import {FlatBody, Func} from 'src/types/ifql'
|
||||
|
||||
interface Body extends FlatBody {
|
||||
|
@ -12,6 +14,20 @@ export const bodyNodes = (ast, suggestions): Body[] => {
|
|||
return []
|
||||
}
|
||||
|
||||
const enrichedSuggestions = suggestions.map(s => {
|
||||
if (s.name === funcNames.JOIN) {
|
||||
return {
|
||||
...s,
|
||||
params: {
|
||||
tables: 'object',
|
||||
on: 'array',
|
||||
fn: 'function',
|
||||
},
|
||||
}
|
||||
}
|
||||
return s
|
||||
})
|
||||
|
||||
const walker = new Walker(ast)
|
||||
|
||||
const body = walker.body.map(b => {
|
||||
|
@ -26,7 +42,7 @@ export const bodyNodes = (ast, suggestions): Body[] => {
|
|||
return {
|
||||
...d,
|
||||
id: uuid.v4(),
|
||||
funcs: functions(d.funcs, suggestions),
|
||||
funcs: functions(d.funcs, enrichedSuggestions),
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -37,7 +53,7 @@ export const bodyNodes = (ast, suggestions): Body[] => {
|
|||
|
||||
return {
|
||||
id,
|
||||
funcs: functions(funcs, suggestions),
|
||||
funcs: functions(funcs, enrichedSuggestions),
|
||||
declarations: [],
|
||||
type,
|
||||
source,
|
||||
|
|
Loading…
Reference in New Issue