Use enums instead of string constants
parent
c36e01965d
commit
5ca710d6e8
|
@ -25,10 +25,7 @@ import replaceTemplate, {replaceInterval} from 'src/tempVars/utils/replace'
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
import {IS_STATIC_LEGEND} from 'src/shared/constants'
|
import {IS_STATIC_LEGEND} from 'src/shared/constants'
|
||||||
import {
|
import {TYPE_QUERY_CONFIG, CEOTabs} from 'src/dashboards/constants'
|
||||||
TYPE_QUERY_CONFIG,
|
|
||||||
DISPLAY_OPTIONS_QUERIES,
|
|
||||||
} from 'src/dashboards/constants'
|
|
||||||
import {OVERLAY_TECHNOLOGY} from 'src/shared/constants/classNames'
|
import {OVERLAY_TECHNOLOGY} from 'src/shared/constants/classNames'
|
||||||
import {MINIMUM_HEIGHTS, INITIAL_HEIGHTS} from 'src/data_explorer/constants'
|
import {MINIMUM_HEIGHTS, INITIAL_HEIGHTS} from 'src/data_explorer/constants'
|
||||||
import {
|
import {
|
||||||
|
@ -94,7 +91,7 @@ interface Props {
|
||||||
interface State {
|
interface State {
|
||||||
queriesWorkingDraft: QueriesModels.QueryConfig[]
|
queriesWorkingDraft: QueriesModels.QueryConfig[]
|
||||||
activeQueryIndex: number
|
activeQueryIndex: number
|
||||||
displayOptionsTab: string
|
activeEditorTab: CEOTabs
|
||||||
isStaticLegend: boolean
|
isStaticLegend: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +143,7 @@ class CellEditorOverlay extends Component<Props, State> {
|
||||||
this.state = {
|
this.state = {
|
||||||
queriesWorkingDraft,
|
queriesWorkingDraft,
|
||||||
activeQueryIndex: 0,
|
activeQueryIndex: 0,
|
||||||
displayOptionsTab: DISPLAY_OPTIONS_QUERIES,
|
activeEditorTab: CEOTabs.Queries,
|
||||||
isStaticLegend: IS_STATIC_LEGEND(legend),
|
isStaticLegend: IS_STATIC_LEGEND(legend),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +180,7 @@ class CellEditorOverlay extends Component<Props, State> {
|
||||||
editQueryStatus,
|
editQueryStatus,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const {displayOptionsTab, queriesWorkingDraft, isStaticLegend} = this.state
|
const {activeEditorTab, queriesWorkingDraft, isStaticLegend} = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -218,8 +215,8 @@ class CellEditorOverlay extends Component<Props, State> {
|
||||||
selected={this.findSelectedSource()}
|
selected={this.findSelectedSource()}
|
||||||
onSetQuerySource={this.handleSetQuerySource}
|
onSetQuerySource={this.handleSetQuerySource}
|
||||||
isSavable={this.isSaveable}
|
isSavable={this.isSaveable}
|
||||||
displayOptionsTab={displayOptionsTab}
|
activeEditorTab={activeEditorTab}
|
||||||
onClickDisplayOptions={this.handleClickDisplayOptionsTab}
|
onSetActiveEditorTab={this.handleSetActiveEditorTab}
|
||||||
/>
|
/>
|
||||||
{this.cellEditorBottom}
|
{this.cellEditorBottom}
|
||||||
</CEOBottom>
|
</CEOBottom>
|
||||||
|
@ -233,12 +230,12 @@ class CellEditorOverlay extends Component<Props, State> {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
activeQueryIndex,
|
activeQueryIndex,
|
||||||
displayOptionsTab,
|
activeEditorTab,
|
||||||
queriesWorkingDraft,
|
queriesWorkingDraft,
|
||||||
isStaticLegend,
|
isStaticLegend,
|
||||||
} = this.state
|
} = this.state
|
||||||
|
|
||||||
if (displayOptionsTab === DISPLAY_OPTIONS_QUERIES) {
|
if (activeEditorTab === CEOTabs.Queries) {
|
||||||
return (
|
return (
|
||||||
<QueryMaker
|
<QueryMaker
|
||||||
source={this.source}
|
source={this.source}
|
||||||
|
@ -351,15 +348,15 @@ class CellEditorOverlay extends Component<Props, State> {
|
||||||
this.props.onSave(newCell)
|
this.props.onSave(newCell)
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleClickDisplayOptionsTab = (tabName: string) => {
|
private handleSetActiveEditorTab = (tabName: CEOTabs): void => {
|
||||||
this.setState({displayOptionsTab: tabName})
|
this.setState({activeEditorTab: tabName})
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleSetActiveQueryIndex = activeQueryIndex => {
|
private handleSetActiveQueryIndex = (activeQueryIndex): void => {
|
||||||
this.setState({activeQueryIndex})
|
this.setState({activeQueryIndex})
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleToggleStaticLegend = isStaticLegend => () => {
|
private handleToggleStaticLegend = isStaticLegend => (): void => {
|
||||||
this.setState({isStaticLegend})
|
this.setState({isStaticLegend})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,7 @@ import SourceSelector from 'src/dashboards/components/SourceSelector'
|
||||||
import RadioButtons from 'src/reusable_ui/components/radio_buttons/RadioButtons'
|
import RadioButtons from 'src/reusable_ui/components/radio_buttons/RadioButtons'
|
||||||
import {ButtonShape} from 'src/reusable_ui/types'
|
import {ButtonShape} from 'src/reusable_ui/types'
|
||||||
|
|
||||||
import {
|
import {CEOTabs} from 'src/dashboards/constants'
|
||||||
DISPLAY_OPTIONS_QUERIES,
|
|
||||||
DISPLAY_OPTIONS_VIS,
|
|
||||||
} from 'src/dashboards/constants'
|
|
||||||
|
|
||||||
import * as QueriesModels from 'src/types/queries'
|
import * as QueriesModels from 'src/types/queries'
|
||||||
import * as SourcesModels from 'src/types/sources'
|
import * as SourcesModels from 'src/types/sources'
|
||||||
|
@ -16,8 +13,8 @@ import * as SourcesModels from 'src/types/sources'
|
||||||
interface Props {
|
interface Props {
|
||||||
onCancel: () => void
|
onCancel: () => void
|
||||||
onSave: () => void
|
onSave: () => void
|
||||||
displayOptionsTab: string
|
activeEditorTab: CEOTabs
|
||||||
onClickDisplayOptions: (tabName: string) => void
|
onSetActiveEditorTab: (tabName: CEOTabs) => void
|
||||||
isSavable: boolean
|
isSavable: boolean
|
||||||
sources: SourcesModels.SourceOption[]
|
sources: SourcesModels.SourceOption[]
|
||||||
onSetQuerySource: (source: SourcesModels.Source) => void
|
onSetQuerySource: (source: SourcesModels.Source) => void
|
||||||
|
@ -33,8 +30,8 @@ const OverlayControls: SFC<Props> = ({
|
||||||
onCancel,
|
onCancel,
|
||||||
isSavable,
|
isSavable,
|
||||||
onSetQuerySource,
|
onSetQuerySource,
|
||||||
displayOptionsTab,
|
activeEditorTab,
|
||||||
onClickDisplayOptions,
|
onSetActiveEditorTab,
|
||||||
}) => (
|
}) => (
|
||||||
<div className="overlay-controls">
|
<div className="overlay-controls">
|
||||||
<SourceSelector
|
<SourceSelector
|
||||||
|
@ -45,9 +42,9 @@ const OverlayControls: SFC<Props> = ({
|
||||||
/>
|
/>
|
||||||
<div className="overlay-controls--tabs">
|
<div className="overlay-controls--tabs">
|
||||||
<RadioButtons
|
<RadioButtons
|
||||||
activeButton={displayOptionsTab}
|
activeButton={activeEditorTab}
|
||||||
buttons={[DISPLAY_OPTIONS_QUERIES, DISPLAY_OPTIONS_VIS]}
|
buttons={[CEOTabs.Queries, CEOTabs.Vis]}
|
||||||
onChange={onClickDisplayOptions}
|
onChange={onSetActiveEditorTab}
|
||||||
shape={ButtonShape.StretchToFit}
|
shape={ButtonShape.StretchToFit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -109,5 +109,7 @@ export const TYPE_SHIFTED: string = 'shifted queryConfig'
|
||||||
export const TYPE_FLUX: string = 'flux'
|
export const TYPE_FLUX: string = 'flux'
|
||||||
export const DASHBOARD_NAME_MAX_LENGTH: number = 50
|
export const DASHBOARD_NAME_MAX_LENGTH: number = 50
|
||||||
|
|
||||||
export const DISPLAY_OPTIONS_QUERIES = 'Queries'
|
export enum CEOTabs {
|
||||||
export const DISPLAY_OPTIONS_VIS = 'Visualization'
|
Queries = 'Queries',
|
||||||
|
Vis = 'Visualization',
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue