Add parameter to the onclick on toolbar function to condition on the func name
parent
78744e4b0e
commit
69fd6fddd6
|
@ -71,10 +71,14 @@ class FluxFunctionsToolbar extends PureComponent<Props, State> {
|
|||
this.setState({searchTerm})
|
||||
}
|
||||
|
||||
private handleUpdateScript = (funcExample: string) => {
|
||||
private handleUpdateScript = (funcName: string, funcExample: string) => {
|
||||
const {activeQueryText, onSetActiveQueryText} = this.props
|
||||
|
||||
onSetActiveQueryText(`${activeQueryText}\n |> ${funcExample}`)
|
||||
if (funcName === 'from') {
|
||||
onSetActiveQueryText(`${activeQueryText}\n${funcExample}`)
|
||||
} else {
|
||||
onSetActiveQueryText(`${activeQueryText}\n |> ${funcExample}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import {FluxToolbarFunction} from 'src/types/shared'
|
|||
interface Props {
|
||||
category: string
|
||||
funcs: FluxToolbarFunction[]
|
||||
onClickFunction: (s: string) => void
|
||||
onClickFunction: (name: string, example: string) => void
|
||||
}
|
||||
|
||||
const FunctionCategory: SFC<Props> = props => {
|
||||
|
|
|
@ -9,7 +9,7 @@ import {FluxToolbarFunction} from 'src/types/shared'
|
|||
|
||||
interface Props {
|
||||
func: FluxToolbarFunction
|
||||
onClickFunction: (s: string) => void
|
||||
onClickFunction: (name: string, example: string) => void
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
@ -77,7 +77,7 @@ class ToolbarFunction extends PureComponent<Props, State> {
|
|||
private handleClickFunction = () => {
|
||||
const {func, onClickFunction} = this.props
|
||||
|
||||
onClickFunction(func.example)
|
||||
onClickFunction(func.name, func.example)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue