Refactor cellEditorOverlay types file structure & imports to new style

pull/10616/head
Jared Scheib 2018-06-22 18:22:49 -07:00
parent 28b919908b
commit a57055772a
4 changed files with 140 additions and 125 deletions

View File

@ -1,211 +1,114 @@
import {Cell} from 'src/types'
import {CellType, ThresholdType} from 'src/types/dashboards'
import {ColorNumber, ColorString} from 'src/types/colors'
import {
Axes,
DecimalPlaces,
FieldOption,
TableOptions,
} from 'src/types/dashboards'
import * as DashboardData from 'src/types/dashboards'
import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay'
export type Action =
| ShowCellEditorOverlayAction
| HideCellEditorOverlayAction
| ChangeCellTypeAction
| RenameCellAction
| UpdateThresholdsListColorsAction
| UpdateThresholdsListTypeAction
| UpdateGaugeColorsAction
| UpdateAxesAction
| UpdateTableOptionsAction
| UpdateLineColorsAction
| ChangeTimeFormatAction
| ChangeDecimalPlacesAction
| UpdateFieldOptionsAction
export type ShowCellEditorOverlayActionCreator = (
export const showCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator = (
cell: Cell
) => ShowCellEditorOverlayAction
interface ShowCellEditorOverlayAction {
type: 'SHOW_CELL_EDITOR_OVERLAY'
payload: {
cell: Cell
}
}
export const showCellEditorOverlay: ShowCellEditorOverlayActionCreator = (
cell: Cell
): ShowCellEditorOverlayAction => ({
): CellEditorOverlayActions.ShowCellEditorOverlayAction => ({
type: 'SHOW_CELL_EDITOR_OVERLAY',
payload: {
cell,
},
})
export type HideCellEditorOverlayActionCreator = () => HideCellEditorOverlayAction
interface HideCellEditorOverlayAction {
type: 'HIDE_CELL_EDITOR_OVERLAY'
}
export const hideCellEditorOverlay = (): HideCellEditorOverlayAction => ({
export const hideCellEditorOverlay = (): CellEditorOverlayActions.HideCellEditorOverlayAction => ({
type: 'HIDE_CELL_EDITOR_OVERLAY',
})
interface ChangeCellTypeAction {
type: 'CHANGE_CELL_TYPE'
payload: {
cellType: CellType
}
}
export const changeCellType = (cellType: CellType): ChangeCellTypeAction => ({
export const changeCellType = (
cellType: DashboardData.CellType
): CellEditorOverlayActions.ChangeCellTypeAction => ({
type: 'CHANGE_CELL_TYPE',
payload: {
cellType,
},
})
interface RenameCellAction {
type: 'RENAME_CELL'
payload: {
cellName: string
}
}
export const renameCell = (cellName: string): RenameCellAction => ({
export const renameCell = (
cellName: string
): CellEditorOverlayActions.RenameCellAction => ({
type: 'RENAME_CELL',
payload: {
cellName,
},
})
interface UpdateThresholdsListColorsAction {
type: 'UPDATE_THRESHOLDS_LIST_COLORS'
payload: {
thresholdsListColors: ColorNumber[]
}
}
export const updateThresholdsListColors = (
thresholdsListColors: ColorNumber[]
): UpdateThresholdsListColorsAction => ({
): CellEditorOverlayActions.UpdateThresholdsListColorsAction => ({
type: 'UPDATE_THRESHOLDS_LIST_COLORS',
payload: {
thresholdsListColors,
},
})
interface UpdateThresholdsListTypeAction {
type: 'UPDATE_THRESHOLDS_LIST_TYPE'
payload: {
thresholdsListType: ThresholdType
}
}
export const updateThresholdsListType = (
thresholdsListType: ThresholdType
): UpdateThresholdsListTypeAction => ({
thresholdsListType: DashboardData.ThresholdType
): CellEditorOverlayActions.UpdateThresholdsListTypeAction => ({
type: 'UPDATE_THRESHOLDS_LIST_TYPE',
payload: {
thresholdsListType,
},
})
interface UpdateGaugeColorsAction {
type: 'UPDATE_GAUGE_COLORS'
payload: {
gaugeColors: ColorNumber[]
}
}
export const updateGaugeColors = (
gaugeColors: ColorNumber[]
): UpdateGaugeColorsAction => ({
): CellEditorOverlayActions.UpdateGaugeColorsAction => ({
type: 'UPDATE_GAUGE_COLORS',
payload: {
gaugeColors,
},
})
interface UpdateAxesAction {
type: 'UPDATE_AXES'
payload: {
axes: Axes
}
}
export const updateAxes = (axes: Axes): UpdateAxesAction => ({
export const updateAxes = (
axes: DashboardData.Axes
): CellEditorOverlayActions.UpdateAxesAction => ({
type: 'UPDATE_AXES',
payload: {
axes,
},
})
interface UpdateTableOptionsAction {
type: 'UPDATE_TABLE_OPTIONS'
payload: {
tableOptions: TableOptions
}
}
export const updateTableOptions = (
tableOptions: TableOptions
): UpdateTableOptionsAction => ({
tableOptions: DashboardData.TableOptions
): CellEditorOverlayActions.UpdateTableOptionsAction => ({
type: 'UPDATE_TABLE_OPTIONS',
payload: {
tableOptions,
},
})
interface UpdateLineColorsAction {
type: 'UPDATE_LINE_COLORS'
payload: {
lineColors: ColorString[]
}
}
export const updateLineColors = (
lineColors: ColorString[]
): UpdateLineColorsAction => ({
): CellEditorOverlayActions.UpdateLineColorsAction => ({
type: 'UPDATE_LINE_COLORS',
payload: {
lineColors,
},
})
interface ChangeTimeFormatAction {
type: 'CHANGE_TIME_FORMAT'
payload: {
timeFormat: string
}
}
export const changeTimeFormat = (
timeFormat: string
): ChangeTimeFormatAction => ({
): CellEditorOverlayActions.ChangeTimeFormatAction => ({
type: 'CHANGE_TIME_FORMAT',
payload: {
timeFormat,
},
})
interface ChangeDecimalPlacesAction {
type: 'CHANGE_DECIMAL_PLACES'
payload: {
decimalPlaces: DecimalPlaces
}
}
export const changeDecimalPlaces = (
decimalPlaces: DecimalPlaces
): ChangeDecimalPlacesAction => ({
decimalPlaces: DashboardData.DecimalPlaces
): CellEditorOverlayActions.ChangeDecimalPlacesAction => ({
type: 'CHANGE_DECIMAL_PLACES',
payload: {
decimalPlaces,
},
})
interface UpdateFieldOptionsAction {
type: 'UPDATE_FIELD_OPTIONS'
payload: {
fieldOptions: FieldOption[]
}
}
export const updateFieldOptions = (
fieldOptions: FieldOption[]
): UpdateFieldOptionsAction => ({
fieldOptions: DashboardData.FieldOption[]
): CellEditorOverlayActions.UpdateFieldOptionsAction => ({
type: 'UPDATE_FIELD_OPTIONS',
payload: {
fieldOptions,

View File

@ -63,7 +63,7 @@ import {DashboardName} from 'src/types/dashboards'
import {ColorNumber, ColorString} from 'src/types/colors'
import * as AnnotationActions from 'src/types/actions/annotations'
import * as AppActions from 'src/shared/actions/app'
import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay'
import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay'
import * as DashboardActions from 'src/types/actions/dashboards'
import * as ErrorActions from 'src/types/actions/errors'
import * as NotificationActions from 'src/types/actions/notifications'

View File

@ -14,7 +14,7 @@ import {
} from 'src/shared/constants/graphColorPalettes'
import {initializeOptions} from 'src/dashboards/constants/cellEditor'
import {Action} from 'src/dashboards/actions/cellEditorOverlay'
import {Action} from 'src/types/actions/cellEditorOverlay'
import {CellType, Cell} from 'src/types'
import {ThresholdType, TableOptions} from 'src/types/dashboards'
import {ThresholdColor, GaugeColor, LineColor} from 'src/types/colors'

View File

@ -0,0 +1,112 @@
import {Cell} from 'src/types'
import {ColorNumber, ColorString} from 'src/types/colors'
import * as DashboardData from 'src/types/dashboards'
export type Action =
| ShowCellEditorOverlayAction
| HideCellEditorOverlayAction
| ChangeCellTypeAction
| RenameCellAction
| UpdateThresholdsListColorsAction
| UpdateThresholdsListTypeAction
| UpdateGaugeColorsAction
| UpdateAxesAction
| UpdateTableOptionsAction
| UpdateLineColorsAction
| ChangeTimeFormatAction
| ChangeDecimalPlacesAction
| UpdateFieldOptionsAction
export type ShowCellEditorOverlayActionCreator = (
cell: Cell
) => ShowCellEditorOverlayAction
export interface ShowCellEditorOverlayAction {
type: 'SHOW_CELL_EDITOR_OVERLAY'
payload: {
cell: Cell
}
}
export type HideCellEditorOverlayActionCreator = () => HideCellEditorOverlayAction
export interface HideCellEditorOverlayAction {
type: 'HIDE_CELL_EDITOR_OVERLAY'
}
export interface ChangeCellTypeAction {
type: 'CHANGE_CELL_TYPE'
payload: {
cellType: DashboardData.CellType
}
}
export interface RenameCellAction {
type: 'RENAME_CELL'
payload: {
cellName: string
}
}
export interface UpdateThresholdsListColorsAction {
type: 'UPDATE_THRESHOLDS_LIST_COLORS'
payload: {
thresholdsListColors: ColorNumber[]
}
}
export interface UpdateThresholdsListTypeAction {
type: 'UPDATE_THRESHOLDS_LIST_TYPE'
payload: {
thresholdsListType: DashboardData.ThresholdType
}
}
export interface UpdateGaugeColorsAction {
type: 'UPDATE_GAUGE_COLORS'
payload: {
gaugeColors: ColorNumber[]
}
}
export interface UpdateAxesAction {
type: 'UPDATE_AXES'
payload: {
axes: DashboardData.Axes
}
}
export interface UpdateTableOptionsAction {
type: 'UPDATE_TABLE_OPTIONS'
payload: {
tableOptions: DashboardData.TableOptions
}
}
export interface UpdateLineColorsAction {
type: 'UPDATE_LINE_COLORS'
payload: {
lineColors: ColorString[]
}
}
export interface ChangeTimeFormatAction {
type: 'CHANGE_TIME_FORMAT'
payload: {
timeFormat: string
}
}
export interface ChangeDecimalPlacesAction {
type: 'CHANGE_DECIMAL_PLACES'
payload: {
decimalPlaces: DashboardData.DecimalPlaces
}
}
export interface UpdateFieldOptionsAction {
type: 'UPDATE_FIELD_OPTIONS'
payload: {
fieldOptions: DashboardData.FieldOption[]
}
}