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