feat(fluxWizard): change draft script on wizard submit

pull/5852/head
Pavel Zavora 2022-02-02 15:57:21 +01:00
parent 9fb249a5b9
commit 4cc56eee33
1 changed files with 15 additions and 5 deletions

View File

@ -118,7 +118,7 @@ class FluxQueryMaker extends PureComponent<Props, State> {
<Button <Button
key={1} key={1}
text={'Run Script'} text={'Run Script'}
onClick={() => this.handleSubmitScript()} onClick={this.handleSubmitScript}
size={ComponentSize.ExtraSmall} size={ComponentSize.ExtraSmall}
color={ComponentColor.Primary} color={ComponentColor.Primary}
/>, />,
@ -168,7 +168,7 @@ class FluxQueryMaker extends PureComponent<Props, State> {
<FluxQueryBuilder <FluxQueryBuilder
source={source} source={source}
timeRange={timeRange} timeRange={timeRange}
onSubmit={this.handleSubmitScript} onSubmit={this.handleSubmitBuilderScript}
onShowEditor={this.handleShowEditor} onShowEditor={this.handleShowEditor}
/> />
) )
@ -194,10 +194,14 @@ class FluxQueryMaker extends PureComponent<Props, State> {
this.handleCursorPosition(cursorPosition) this.handleCursorPosition(cursorPosition)
} }
private handleSubmitScript = (script?: string) => { private handleSubmitScript = () => {
const {onChangeScript, onUpdateStatus, onManualRefresh} = this.props const {
onChangeScript,
onUpdateStatus,
onManualRefresh,
draftScript,
} = this.props
const {draftScriptStatus} = this.state const {draftScriptStatus} = this.state
const draftScript = script ? script : this.props.draftScript
onChangeScript(draftScript) onChangeScript(draftScript)
onManualRefresh() onManualRefresh()
@ -207,6 +211,12 @@ class FluxQueryMaker extends PureComponent<Props, State> {
} }
} }
private handleSubmitBuilderScript = async (script: string) => {
await this.handleChangeDraftScript(script)
this.props.onChangeScript(script)
this.handleSubmitScript()
}
private handleShowWizard = (): void => { private handleShowWizard = (): void => {
this.setState({isWizardActive: true}) this.setState({isWizardActive: true})
} }