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