Get actual databases for From component
parent
3bb4644aa9
commit
a86c2817a8
|
@ -6,9 +6,11 @@ import VariableName from 'src/ifql/components/VariableName'
|
||||||
import FuncSelector from 'src/ifql/components/FuncSelector'
|
import FuncSelector from 'src/ifql/components/FuncSelector'
|
||||||
import {funcNames} from 'src/ifql/constants'
|
import {funcNames} from 'src/ifql/constants'
|
||||||
|
|
||||||
|
import {Service} from 'src/types'
|
||||||
import {FlatBody, Suggestion} from 'src/types/ifql'
|
import {FlatBody, Suggestion} from 'src/types/ifql'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
service: Service
|
||||||
body: Body[]
|
body: Body[]
|
||||||
suggestions: Suggestion[]
|
suggestions: Suggestion[]
|
||||||
onAppendFrom: () => void
|
onAppendFrom: () => void
|
||||||
|
|
|
@ -19,7 +19,13 @@ class ExpressionNode extends PureComponent<Props> {
|
||||||
const {declarationID, bodyID, funcNames, funcs} = this.props
|
const {declarationID, bodyID, funcNames, funcs} = this.props
|
||||||
return (
|
return (
|
||||||
<IFQLContext.Consumer>
|
<IFQLContext.Consumer>
|
||||||
{({onDeleteFuncNode, onAddNode, onChangeArg, onGenerateScript}) => {
|
{({
|
||||||
|
onDeleteFuncNode,
|
||||||
|
onAddNode,
|
||||||
|
onChangeArg,
|
||||||
|
onGenerateScript,
|
||||||
|
service,
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{funcs.map((func, i) => (
|
{funcs.map((func, i) => (
|
||||||
|
@ -27,6 +33,7 @@ class ExpressionNode extends PureComponent<Props> {
|
||||||
key={i}
|
key={i}
|
||||||
func={func}
|
func={func}
|
||||||
bodyID={bodyID}
|
bodyID={bodyID}
|
||||||
|
service={service}
|
||||||
onChangeArg={onChangeArg}
|
onChangeArg={onChangeArg}
|
||||||
onDelete={onDeleteFuncNode}
|
onDelete={onDeleteFuncNode}
|
||||||
declarationID={declarationID}
|
declarationID={declarationID}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import React, {PureComponent} from 'react'
|
import React, {PureComponent} from 'react'
|
||||||
|
|
||||||
import {getDatabases} from 'src/ifql/apis'
|
import {showDatabases} from 'src/shared/apis/metaQuery'
|
||||||
|
import showDatabasesParser from 'src/shared/parsing/showDatabases'
|
||||||
|
|
||||||
import Dropdown from 'src/shared/components/Dropdown'
|
import Dropdown from 'src/shared/components/Dropdown'
|
||||||
import {OnChangeArg} from 'src/types/ifql'
|
import {OnChangeArg} from 'src/types/ifql'
|
||||||
|
import {Service} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
funcID: string
|
funcID: string
|
||||||
|
@ -12,6 +14,7 @@ interface Props {
|
||||||
bodyID: string
|
bodyID: string
|
||||||
declarationID: string
|
declarationID: string
|
||||||
onChangeArg: OnChangeArg
|
onChangeArg: OnChangeArg
|
||||||
|
service: Service
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
|
@ -31,11 +34,16 @@ class From extends PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async componentDidMount() {
|
public async componentDidMount() {
|
||||||
|
const {service} = this.props
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dbs = await getDatabases()
|
const {data} = await showDatabases(`${service.links.source}/proxy`)
|
||||||
this.setState({dbs})
|
const {databases} = showDatabasesParser(data)
|
||||||
} catch (error) {
|
const sorted = databases.sort()
|
||||||
// TODO: notity error
|
|
||||||
|
this.setState({dbs: sorted})
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,10 @@ import From from 'src/ifql/components/From'
|
||||||
|
|
||||||
import {funcNames, argTypes} from 'src/ifql/constants'
|
import {funcNames, argTypes} from 'src/ifql/constants'
|
||||||
import {OnChangeArg} from 'src/types/ifql'
|
import {OnChangeArg} from 'src/types/ifql'
|
||||||
|
import {Service} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
service: Service
|
||||||
funcName: string
|
funcName: string
|
||||||
funcID: string
|
funcID: string
|
||||||
argKey: string
|
argKey: string
|
||||||
|
@ -30,6 +32,7 @@ class FuncArg extends PureComponent<Props> {
|
||||||
type,
|
type,
|
||||||
bodyID,
|
bodyID,
|
||||||
funcID,
|
funcID,
|
||||||
|
service,
|
||||||
funcName,
|
funcName,
|
||||||
onChangeArg,
|
onChangeArg,
|
||||||
declarationID,
|
declarationID,
|
||||||
|
@ -39,6 +42,7 @@ class FuncArg extends PureComponent<Props> {
|
||||||
if (funcName === funcNames.FROM) {
|
if (funcName === funcNames.FROM) {
|
||||||
return (
|
return (
|
||||||
<From
|
<From
|
||||||
|
service={service}
|
||||||
argKey={argKey}
|
argKey={argKey}
|
||||||
funcID={funcID}
|
funcID={funcID}
|
||||||
value={this.value}
|
value={this.value}
|
||||||
|
|
|
@ -4,9 +4,11 @@ import {OnChangeArg} from 'src/types/ifql'
|
||||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||||
import {Func} from 'src/types/ifql'
|
import {Func} from 'src/types/ifql'
|
||||||
import {funcNames} from 'src/ifql/constants'
|
import {funcNames} from 'src/ifql/constants'
|
||||||
|
import {Service} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
func: Func
|
func: Func
|
||||||
|
service: Service
|
||||||
bodyID: string
|
bodyID: string
|
||||||
onChangeArg: OnChangeArg
|
onChangeArg: OnChangeArg
|
||||||
declarationID: string
|
declarationID: string
|
||||||
|
@ -20,6 +22,7 @@ export default class FuncArgs extends PureComponent<Props> {
|
||||||
const {
|
const {
|
||||||
func,
|
func,
|
||||||
bodyID,
|
bodyID,
|
||||||
|
service,
|
||||||
onChangeArg,
|
onChangeArg,
|
||||||
onDeleteFunc,
|
onDeleteFunc,
|
||||||
declarationID,
|
declarationID,
|
||||||
|
@ -37,6 +40,7 @@ export default class FuncArgs extends PureComponent<Props> {
|
||||||
value={value}
|
value={value}
|
||||||
bodyID={bodyID}
|
bodyID={bodyID}
|
||||||
funcID={func.id}
|
funcID={func.id}
|
||||||
|
service={service}
|
||||||
funcName={func.name}
|
funcName={func.name}
|
||||||
onChangeArg={onChangeArg}
|
onChangeArg={onChangeArg}
|
||||||
declarationID={declarationID}
|
declarationID={declarationID}
|
||||||
|
|
|
@ -4,9 +4,11 @@ import FuncArgs from 'src/ifql/components/FuncArgs'
|
||||||
import FuncArgsPreview from 'src/ifql/components/FuncArgsPreview'
|
import FuncArgsPreview from 'src/ifql/components/FuncArgsPreview'
|
||||||
import {OnDeleteFuncNode, OnChangeArg, Func} from 'src/types/ifql'
|
import {OnDeleteFuncNode, OnChangeArg, Func} from 'src/types/ifql'
|
||||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||||
|
import {Service} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
func: Func
|
func: Func
|
||||||
|
service: Service
|
||||||
bodyID: string
|
bodyID: string
|
||||||
declarationID?: string
|
declarationID?: string
|
||||||
onDelete: OnDeleteFuncNode
|
onDelete: OnDeleteFuncNode
|
||||||
|
@ -35,6 +37,7 @@ export default class FuncNode extends PureComponent<Props, State> {
|
||||||
const {
|
const {
|
||||||
func,
|
func,
|
||||||
bodyID,
|
bodyID,
|
||||||
|
service,
|
||||||
onChangeArg,
|
onChangeArg,
|
||||||
declarationID,
|
declarationID,
|
||||||
onGenerateScript,
|
onGenerateScript,
|
||||||
|
@ -53,6 +56,7 @@ export default class FuncNode extends PureComponent<Props, State> {
|
||||||
<FuncArgs
|
<FuncArgs
|
||||||
func={func}
|
func={func}
|
||||||
bodyID={bodyID}
|
bodyID={bodyID}
|
||||||
|
service={service}
|
||||||
onChangeArg={onChangeArg}
|
onChangeArg={onChangeArg}
|
||||||
declarationID={declarationID}
|
declarationID={declarationID}
|
||||||
onGenerateScript={onGenerateScript}
|
onGenerateScript={onGenerateScript}
|
||||||
|
|
|
@ -120,6 +120,7 @@ class TimeMachine extends PureComponent<Props> {
|
||||||
render: () => (
|
render: () => (
|
||||||
<BodyBuilder
|
<BodyBuilder
|
||||||
body={body}
|
body={body}
|
||||||
|
service={service}
|
||||||
suggestions={suggestions}
|
suggestions={suggestions}
|
||||||
onAppendFrom={onAppendFrom}
|
onAppendFrom={onAppendFrom}
|
||||||
onAppendJoin={onAppendJoin}
|
onAppendJoin={onAppendJoin}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {
|
||||||
FlatBody,
|
FlatBody,
|
||||||
Links,
|
Links,
|
||||||
InputArg,
|
InputArg,
|
||||||
Handlers,
|
Context,
|
||||||
DeleteFuncNodeArgs,
|
DeleteFuncNodeArgs,
|
||||||
Func,
|
Func,
|
||||||
ScriptStatus,
|
ScriptStatus,
|
||||||
|
@ -90,7 +90,7 @@ export class IFQLPage extends PureComponent<Props, State> {
|
||||||
const {script} = this.props
|
const {script} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IFQLContext.Provider value={this.handlers}>
|
<IFQLContext.Provider value={this.getContext}>
|
||||||
<KeyboardShortcuts onControlEnter={this.getTimeSeries}>
|
<KeyboardShortcuts onControlEnter={this.getTimeSeries}>
|
||||||
<div className="page hosts-list-page">
|
<div className="page hosts-list-page">
|
||||||
{this.header}
|
{this.header}
|
||||||
|
@ -129,7 +129,7 @@ export class IFQLPage extends PureComponent<Props, State> {
|
||||||
return this.props.services[0]
|
return this.props.services[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
private get handlers(): Handlers {
|
private get getContext(): Context {
|
||||||
return {
|
return {
|
||||||
onAddNode: this.handleAddNode,
|
onAddNode: this.handleAddNode,
|
||||||
onChangeArg: this.handleChangeArg,
|
onChangeArg: this.handleChangeArg,
|
||||||
|
@ -137,6 +137,7 @@ export class IFQLPage extends PureComponent<Props, State> {
|
||||||
onChangeScript: this.handleChangeScript,
|
onChangeScript: this.handleChangeScript,
|
||||||
onDeleteFuncNode: this.handleDeleteFuncNode,
|
onDeleteFuncNode: this.handleDeleteFuncNode,
|
||||||
onGenerateScript: this.handleGenerateScript,
|
onGenerateScript: this.handleGenerateScript,
|
||||||
|
service: this.service,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import {Service} from 'src/types'
|
||||||
// function definitions
|
// function definitions
|
||||||
export type OnDeleteFuncNode = (ids: DeleteFuncNodeArgs) => void
|
export type OnDeleteFuncNode = (ids: DeleteFuncNodeArgs) => void
|
||||||
export type OnChangeArg = (inputArg: InputArg) => void
|
export type OnChangeArg = (inputArg: InputArg) => void
|
||||||
|
@ -15,13 +16,14 @@ export interface ScriptStatus {
|
||||||
text: string
|
text: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Handlers {
|
export interface Context {
|
||||||
onAddNode: OnAddNode
|
onAddNode: OnAddNode
|
||||||
onChangeArg: OnChangeArg
|
onChangeArg: OnChangeArg
|
||||||
onSubmitScript: OnSubmitScript
|
onSubmitScript: OnSubmitScript
|
||||||
onChangeScript: OnChangeScript
|
onChangeScript: OnChangeScript
|
||||||
onDeleteFuncNode: OnDeleteFuncNode
|
onDeleteFuncNode: OnDeleteFuncNode
|
||||||
onGenerateScript: OnGenerateScript
|
onGenerateScript: OnGenerateScript
|
||||||
|
service: Service
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeleteFuncNodeArgs {
|
export interface DeleteFuncNodeArgs {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {shallow} from 'enzyme'
|
import {shallow} from 'enzyme'
|
||||||
import From from 'src/ifql/components/From'
|
import From from 'src/ifql/components/From'
|
||||||
|
import {service} from 'test/resources'
|
||||||
|
|
||||||
jest.mock('src/ifql/apis', () => require('mocks/ifql/apis'))
|
jest.mock('src/ifql/apis', () => require('mocks/ifql/apis'))
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ const setup = () => {
|
||||||
value: 'db1',
|
value: 'db1',
|
||||||
bodyID: '2',
|
bodyID: '2',
|
||||||
declarationID: '1',
|
declarationID: '1',
|
||||||
|
service,
|
||||||
onChangeArg: () => {},
|
onChangeArg: () => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {shallow} from 'enzyme'
|
import {shallow} from 'enzyme'
|
||||||
import FuncArg from 'src/ifql/components/FuncArg'
|
import FuncArg from 'src/ifql/components/FuncArg'
|
||||||
|
import {service} from 'test/resources'
|
||||||
|
|
||||||
const setup = () => {
|
const setup = () => {
|
||||||
const props = {
|
const props = {
|
||||||
|
@ -11,6 +12,7 @@ const setup = () => {
|
||||||
argKey: '',
|
argKey: '',
|
||||||
value: '',
|
value: '',
|
||||||
type: '',
|
type: '',
|
||||||
|
service,
|
||||||
onChangeArg: () => {},
|
onChangeArg: () => {},
|
||||||
onGenerateScript: () => {},
|
onGenerateScript: () => {},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue