Add stronger types to handleSetQuerySource in CellEditorOverlay and make sure it conforms to types

pull/10616/head
Iris Scholten 2018-05-02 09:41:09 -07:00
parent 4f59492d73
commit b53d42d160
3 changed files with 18 additions and 12 deletions

View File

@ -326,11 +326,13 @@ class CellEditorOverlay extends Component<Props, State> {
this.setState({isStaticLegend})
}
private handleSetQuerySource = source => {
const queriesWorkingDraft = this.state.queriesWorkingDraft.map(q => ({
..._.cloneDeep(q),
source,
}))
private handleSetQuerySource = (source: Source): void => {
const queriesWorkingDraft: QueryConfig[] = this.state.queriesWorkingDraft.map(
q => ({
..._.cloneDeep(q),
source: source.links.self,
})
)
this.setState({queriesWorkingDraft})
}

View File

@ -3,7 +3,11 @@ import classnames from 'classnames'
import ConfirmOrCancel from 'src/shared/components/ConfirmOrCancel'
import SourceSelector from 'src/dashboards/components/SourceSelector'
import {QueryConfig} from 'src/types/query'
import {QueryConfig, Source} from 'src/types'
interface SourceOption extends Source {
text: string
}
interface Props {
onCancel: () => void
@ -12,8 +16,8 @@ interface Props {
onClickDisplayOptions: (
displayOptions: boolean
) => (event: MouseEvent<HTMLLIElement>) => void
isSavable?: boolean
sources: any[]
isSavable: boolean
sources: SourceOption[]
onSetQuerySource: (source: any) => void
selected: string
queries: QueryConfig[]

View File

@ -1,15 +1,15 @@
import React, {SFC} from 'react'
import Dropdown from 'src/shared/components/Dropdown'
import {QueryConfig} from 'src/types/query'
import {QueryConfig, Source} from 'src/types'
interface Options {
interface SourceOption extends Source {
text: string
}
interface Props {
sources: Options[]
sources: SourceOption[]
selected: string
onSetQuerySource: (source: any) => void
onSetQuerySource: (source: SourceOption) => void
queries: QueryConfig[]
}