diff --git a/ui/src/dashboards/actions/cellEditorOverlay.ts b/ui/src/dashboards/actions/cellEditorOverlay.ts index 018444bad6..245894d60c 100644 --- a/ui/src/dashboards/actions/cellEditorOverlay.ts +++ b/ui/src/dashboards/actions/cellEditorOverlay.ts @@ -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, diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index d074ffea14..55d8ed3435 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -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' diff --git a/ui/src/dashboards/reducers/cellEditorOverlay.ts b/ui/src/dashboards/reducers/cellEditorOverlay.ts index bf0e8e61c8..8b6488c721 100644 --- a/ui/src/dashboards/reducers/cellEditorOverlay.ts +++ b/ui/src/dashboards/reducers/cellEditorOverlay.ts @@ -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' diff --git a/ui/src/types/actions/cellEditorOverlay.ts b/ui/src/types/actions/cellEditorOverlay.ts new file mode 100644 index 0000000000..0648c6cd1a --- /dev/null +++ b/ui/src/types/actions/cellEditorOverlay.ts @@ -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[] + } +}