feat(fluxWizard): add copy button

pull/5852/head
Pavel Zavora 2022-02-02 12:12:24 +01:00
parent 9980958699
commit 4848895e73
1 changed files with 18 additions and 4 deletions

View File

@ -23,7 +23,7 @@ import {RemoteDataState} from 'src/types'
interface OwnProps extends TimeMachineQueryProps {
onSubmit: () => void
onShowEditor: () => void
runEnabled: boolean
isRunnable: boolean
}
type Props = OwnProps & typeof mdtp & ReturnType<typeof mstp>
@ -32,7 +32,7 @@ const FluxQueryBuilder = ({
source,
timeRange,
tags,
runEnabled,
isRunnable,
onSubmit,
onShowEditor,
onAddTagSelector,
@ -77,12 +77,26 @@ const FluxQueryBuilder = ({
text="Query Editor"
titleText="Switch to Flux Query Editor"
/>
<Button
shape={ButtonShape.Square}
size={ComponentSize.ExtraSmall}
titleText="Copy builder query to clipboard"
icon={IconFont.Duplicate}
status={
isRunnable ? ComponentStatus.Default : ComponentStatus.Disabled
}
onClick={e => {
// TODO perform copy, notify about success/failure
e.stopPropagation()
e.preventDefault()
}}
/>
<Button
size={ComponentSize.ExtraSmall}
color={ComponentColor.Primary}
onClick={onSubmit}
status={
runEnabled ? ComponentStatus.Default : ComponentStatus.Disabled
isRunnable ? ComponentStatus.Default : ComponentStatus.Disabled
}
text="Run"
/>
@ -96,7 +110,7 @@ const mstp = (state: any) => {
const fluxQueryBuilder = state?.fluxQueryBuilder as QueryBuilderState
return {
tags: fluxQueryBuilder.tags,
runEnabled:
isRunnable:
fluxQueryBuilder.buckets.status === RemoteDataState.Done &&
!!fluxQueryBuilder.buckets.selectedBucket,
}