Add parameter to the onclick on toolbar function to condition on the func name

pull/10616/head
Palak Bhojani 2019-01-03 10:14:44 -08:00
parent 78744e4b0e
commit 69fd6fddd6
3 changed files with 9 additions and 5 deletions

View File

@ -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}`)
}
}
}

View File

@ -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 => {

View File

@ -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)
}
}