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 { interface OwnProps extends TimeMachineQueryProps {
onSubmit: () => void onSubmit: () => void
onShowEditor: () => void onShowEditor: () => void
runEnabled: boolean isRunnable: boolean
} }
type Props = OwnProps & typeof mdtp & ReturnType<typeof mstp> type Props = OwnProps & typeof mdtp & ReturnType<typeof mstp>
@ -32,7 +32,7 @@ const FluxQueryBuilder = ({
source, source,
timeRange, timeRange,
tags, tags,
runEnabled, isRunnable,
onSubmit, onSubmit,
onShowEditor, onShowEditor,
onAddTagSelector, onAddTagSelector,
@ -77,12 +77,26 @@ const FluxQueryBuilder = ({
text="Query Editor" text="Query Editor"
titleText="Switch to Flux 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 <Button
size={ComponentSize.ExtraSmall} size={ComponentSize.ExtraSmall}
color={ComponentColor.Primary} color={ComponentColor.Primary}
onClick={onSubmit} onClick={onSubmit}
status={ status={
runEnabled ? ComponentStatus.Default : ComponentStatus.Disabled isRunnable ? ComponentStatus.Default : ComponentStatus.Disabled
} }
text="Run" text="Run"
/> />
@ -96,7 +110,7 @@ const mstp = (state: any) => {
const fluxQueryBuilder = state?.fluxQueryBuilder as QueryBuilderState const fluxQueryBuilder = state?.fluxQueryBuilder as QueryBuilderState
return { return {
tags: fluxQueryBuilder.tags, tags: fluxQueryBuilder.tags,
runEnabled: isRunnable:
fluxQueryBuilder.buckets.status === RemoteDataState.Done && fluxQueryBuilder.buckets.status === RemoteDataState.Done &&
!!fluxQueryBuilder.buckets.selectedBucket, !!fluxQueryBuilder.buckets.selectedBucket,
} }