Refactor all type imports modified in #3739 to unified Types ns

pull/3739/head
Jared Scheib 2018-06-23 13:55:52 -07:00
parent e96f639635
commit e0d6cae425
17 changed files with 251 additions and 249 deletions

View File

@ -1,24 +1,21 @@
import {Cell} from 'src/types'
import {ColorNumber, ColorString} from 'src/types/colors'
import * as DashboardData from 'src/types/dashboards'
import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay'
import * as Types from 'src/types/modules'
export const showCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator = (
cell: Cell
): CellEditorOverlayActions.ShowCellEditorOverlayAction => ({
export const showCellEditorOverlay: Types.CellEditorOverlay.Actions.ShowCellEditorOverlayActionCreator = (
cell: Types.Dashboards.Data.Cell
): Types.CellEditorOverlay.Actions.ShowCellEditorOverlayAction => ({
type: 'SHOW_CELL_EDITOR_OVERLAY',
payload: {
cell,
},
})
export const hideCellEditorOverlay = (): CellEditorOverlayActions.HideCellEditorOverlayAction => ({
export const hideCellEditorOverlay = (): Types.CellEditorOverlay.Actions.HideCellEditorOverlayAction => ({
type: 'HIDE_CELL_EDITOR_OVERLAY',
})
export const changeCellType = (
cellType: DashboardData.CellType
): CellEditorOverlayActions.ChangeCellTypeAction => ({
cellType: Types.Dashboards.Data.CellType
): Types.CellEditorOverlay.Actions.ChangeCellTypeAction => ({
type: 'CHANGE_CELL_TYPE',
payload: {
cellType,
@ -27,7 +24,7 @@ export const changeCellType = (
export const renameCell = (
cellName: string
): CellEditorOverlayActions.RenameCellAction => ({
): Types.CellEditorOverlay.Actions.RenameCellAction => ({
type: 'RENAME_CELL',
payload: {
cellName,
@ -35,8 +32,8 @@ export const renameCell = (
})
export const updateThresholdsListColors = (
thresholdsListColors: ColorNumber[]
): CellEditorOverlayActions.UpdateThresholdsListColorsAction => ({
thresholdsListColors: Types.Colors.Data.ColorNumber[]
): Types.CellEditorOverlay.Actions.UpdateThresholdsListColorsAction => ({
type: 'UPDATE_THRESHOLDS_LIST_COLORS',
payload: {
thresholdsListColors,
@ -44,8 +41,8 @@ export const updateThresholdsListColors = (
})
export const updateThresholdsListType = (
thresholdsListType: DashboardData.ThresholdType
): CellEditorOverlayActions.UpdateThresholdsListTypeAction => ({
thresholdsListType: Types.Dashboards.Data.ThresholdType
): Types.CellEditorOverlay.Actions.UpdateThresholdsListTypeAction => ({
type: 'UPDATE_THRESHOLDS_LIST_TYPE',
payload: {
thresholdsListType,
@ -53,8 +50,8 @@ export const updateThresholdsListType = (
})
export const updateGaugeColors = (
gaugeColors: ColorNumber[]
): CellEditorOverlayActions.UpdateGaugeColorsAction => ({
gaugeColors: Types.Colors.Data.ColorNumber[]
): Types.CellEditorOverlay.Actions.UpdateGaugeColorsAction => ({
type: 'UPDATE_GAUGE_COLORS',
payload: {
gaugeColors,
@ -62,8 +59,8 @@ export const updateGaugeColors = (
})
export const updateAxes = (
axes: DashboardData.Axes
): CellEditorOverlayActions.UpdateAxesAction => ({
axes: Types.Dashboards.Data.Axes
): Types.CellEditorOverlay.Actions.UpdateAxesAction => ({
type: 'UPDATE_AXES',
payload: {
axes,
@ -71,8 +68,8 @@ export const updateAxes = (
})
export const updateTableOptions = (
tableOptions: DashboardData.TableOptions
): CellEditorOverlayActions.UpdateTableOptionsAction => ({
tableOptions: Types.Dashboards.Data.TableOptions
): Types.CellEditorOverlay.Actions.UpdateTableOptionsAction => ({
type: 'UPDATE_TABLE_OPTIONS',
payload: {
tableOptions,
@ -80,8 +77,8 @@ export const updateTableOptions = (
})
export const updateLineColors = (
lineColors: ColorString[]
): CellEditorOverlayActions.UpdateLineColorsAction => ({
lineColors: Types.Colors.Data.ColorString[]
): Types.CellEditorOverlay.Actions.UpdateLineColorsAction => ({
type: 'UPDATE_LINE_COLORS',
payload: {
lineColors,
@ -90,7 +87,7 @@ export const updateLineColors = (
export const changeTimeFormat = (
timeFormat: string
): CellEditorOverlayActions.ChangeTimeFormatAction => ({
): Types.CellEditorOverlay.Actions.ChangeTimeFormatAction => ({
type: 'CHANGE_TIME_FORMAT',
payload: {
timeFormat,
@ -98,8 +95,8 @@ export const changeTimeFormat = (
})
export const changeDecimalPlaces = (
decimalPlaces: DashboardData.DecimalPlaces
): CellEditorOverlayActions.ChangeDecimalPlacesAction => ({
decimalPlaces: Types.Dashboards.Data.DecimalPlaces
): Types.CellEditorOverlay.Actions.ChangeDecimalPlacesAction => ({
type: 'CHANGE_DECIMAL_PLACES',
payload: {
decimalPlaces,
@ -107,8 +104,8 @@ export const changeDecimalPlaces = (
})
export const updateFieldOptions = (
fieldOptions: DashboardData.FieldOption[]
): CellEditorOverlayActions.UpdateFieldOptionsAction => ({
fieldOptions: Types.Dashboards.Data.FieldOption[]
): Types.CellEditorOverlay.Actions.UpdateFieldOptionsAction => ({
type: 'UPDATE_FIELD_OPTIONS',
payload: {
fieldOptions,

View File

@ -1,9 +1,10 @@
// Libraries
import React, {Component} from 'react'
import _ from 'lodash'
import uuid from 'uuid'
import {getDeep} from 'src/utils/wrappers'
// Components
import {ErrorHandling} from 'src/shared/decorators/errors'
import ResizeContainer from 'src/shared/components/ResizeContainer'
import QueryMaker from 'src/dashboards/components/QueryMaker'
import Visualization from 'src/dashboards/components/Visualization'
@ -11,14 +12,18 @@ import OverlayControls from 'src/dashboards/components/OverlayControls'
import DisplayOptions from 'src/dashboards/components/DisplayOptions'
import CEOBottom from 'src/dashboards/components/CEOBottom'
import * as queryTransitions from 'src/utils/queryTransitions'
// APIs
import {getQueryConfigAndStatus} from 'src/shared/apis'
// Utils
import {getDeep} from 'src/utils/wrappers'
import * as queryTransitions from 'src/utils/queryTransitions'
import defaultQueryConfig from 'src/utils/defaultQueryConfig'
import {buildQuery} from 'src/utils/influxql'
import {getQueryConfigAndStatus} from 'src/shared/apis'
import {IS_STATIC_LEGEND} from 'src/shared/constants'
import {nextSource} from 'src/dashboards/utils/sources'
// Constants
import {IS_STATIC_LEGEND} from 'src/shared/constants'
import {TYPE_QUERY_CONFIG} from 'src/dashboards/constants'
import {removeUnselectedTemplateValues} from 'src/tempVars/constants'
import {OVERLAY_TECHNOLOGY} from 'src/shared/constants/classNames'
@ -30,20 +35,8 @@ import {
} from 'src/shared/constants'
import {getCellTypeColors} from 'src/dashboards/constants/cellEditor'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {
TimeRange,
Source,
QueryConfig,
Cell,
CellQuery,
Legend,
Status,
} from 'src/types'
import {ColorString, ColorNumber} from 'src/types/colors'
import * as DashboardActions from 'src/types/actions/dashboards'
import {SourceOption} from 'src/dashboards/components/OverlayControls'
// Types
import * as Types from 'src/types/modules'
type QueryTransitions = typeof queryTransitions
type EditRawTextAsyncFunc = (
@ -59,7 +52,7 @@ export type CellEditorOverlayActions = QueryActions & {
editRawTextAsync: EditRawTextAsyncFunc
}
const staticLegend: Legend = {
const staticLegend: Types.Dashboards.Data.Legend = {
type: 'static',
orientation: 'bottom',
}
@ -70,37 +63,40 @@ interface Template {
interface QueryStatus {
queryID: string
status: Status
status: Types.Queries.Data.Status
}
interface Props {
sources: Source[]
editQueryStatus: DashboardActions.EditCellQueryStatusActionCreator
sources: Types.Sources.Data.Source[]
editQueryStatus: Types.Dashboards.Actions.EditCellQueryStatusActionCreator
onCancel: () => void
onSave: (cell: Cell) => void
source: Source
onSave: (cell: Types.Dashboards.Data.Cell) => void
source: Types.Sources.Data.Source
dashboardID: number
queryStatus: QueryStatus
autoRefresh: number
templates: Template[]
timeRange: TimeRange
timeRange: Types.Queries.Data.TimeRange
thresholdsListType: string
thresholdsListColors: ColorNumber[]
gaugeColors: ColorNumber[]
lineColors: ColorString[]
cell: Cell
thresholdsListColors: Types.Colors.Data.ColorNumber[]
gaugeColors: Types.Colors.Data.ColorNumber[]
lineColors: Types.Colors.Data.ColorString[]
cell: Types.Dashboards.Data.Cell
}
interface State {
queriesWorkingDraft: QueryConfig[]
queriesWorkingDraft: Types.Queries.Data.QueryConfig[]
activeQueryIndex: number
isDisplayOptionsTabActive: boolean
isStaticLegend: boolean
}
const createWorkingDraft = (source: Source, query: CellQuery): QueryConfig => {
const createWorkingDraft = (
source: Types.Sources.Data.Source,
query: Types.Dashboards.Data.CellQuery
): Types.Queries.Data.QueryConfig => {
const {queryConfig} = query
const draft: QueryConfig = {
const draft: Types.Queries.Data.QueryConfig = {
...queryConfig,
id: uuid.v4(),
source,
@ -110,11 +106,13 @@ const createWorkingDraft = (source: Source, query: CellQuery): QueryConfig => {
}
const createWorkingDrafts = (
source: Source,
queries: CellQuery[]
): QueryConfig[] =>
source: Types.Sources.Data.Source,
queries: Types.Dashboards.Data.CellQuery[]
): Types.Queries.Data.QueryConfig[] =>
_.cloneDeep(
queries.map((query: CellQuery) => createWorkingDraft(source, query))
queries.map((query: Types.Dashboards.Data.CellQuery) =>
createWorkingDraft(source, query)
)
)
@ErrorHandling
@ -248,7 +246,7 @@ class CellEditorOverlay extends Component<Props, State> {
)
}
private get formattedSources(): SourceOption[] {
private get formattedSources(): Types.Sources.Data.SourceOption[] {
const {sources} = this.props
return sources.map(s => ({
...s,
@ -303,15 +301,20 @@ class CellEditorOverlay extends Component<Props, State> {
const {queriesWorkingDraft, isStaticLegend} = this.state
const {cell, thresholdsListColors, gaugeColors, lineColors} = this.props
const queries: CellQuery[] = queriesWorkingDraft.map(q => {
const timeRange = q.range || {upper: null, lower: TEMP_VAR_DASHBOARD_TIME}
const source = getDeep<string | null>(q.source, 'links.self', null)
return {
queryConfig: q,
query: q.rawText || buildQuery(TYPE_QUERY_CONFIG, timeRange, q),
source,
const queries: Types.Dashboards.Data.CellQuery[] = queriesWorkingDraft.map(
q => {
const timeRange = q.range || {
upper: null,
lower: TEMP_VAR_DASHBOARD_TIME,
}
const source = getDeep<string | null>(q.source, 'links.self', null)
return {
queryConfig: q,
query: q.rawText || buildQuery(TYPE_QUERY_CONFIG, timeRange, q),
source,
}
}
})
)
const colors = getCellTypeColors({
cellType: cell.type,
@ -320,7 +323,7 @@ class CellEditorOverlay extends Component<Props, State> {
lineColors,
})
const newCell: Cell = {
const newCell: Types.Dashboards.Data.Cell = {
...cell,
queries,
colors,
@ -342,8 +345,8 @@ class CellEditorOverlay extends Component<Props, State> {
this.setState({isStaticLegend})
}
private handleSetQuerySource = (source: Source): void => {
const queriesWorkingDraft: QueryConfig[] = this.state.queriesWorkingDraft.map(
private handleSetQuerySource = (source: Types.Sources.Data.Source): void => {
const queriesWorkingDraft: Types.Queries.Data.QueryConfig[] = this.state.queriesWorkingDraft.map(
q => ({
..._.cloneDeep(q),
source,
@ -419,8 +422,8 @@ class CellEditorOverlay extends Component<Props, State> {
)
const config = data.queries.find(q => q.id === id)
const nextQueries: QueryConfig[] = this.state.queriesWorkingDraft.map(
(q: QueryConfig) => {
const nextQueries: Types.Queries.Data.QueryConfig[] = this.state.queriesWorkingDraft.map(
(q: Types.Queries.Data.QueryConfig) => {
if (q.id === id) {
const isQuerySupportedByExplorer = !isUsingUserDefinedTempVars
@ -448,18 +451,20 @@ class CellEditorOverlay extends Component<Props, State> {
private findSelectedSource = (): string => {
const {source} = this.props
const sources = this.formattedSources
const currentSource = getDeep<Source | null>(
const currentSource = getDeep<Types.Sources.Data.Source | null>(
this.state.queriesWorkingDraft,
'0.source',
null
)
if (!currentSource) {
const defaultSource: Source = sources.find(s => s.id === source.id)
const defaultSource: Types.Sources.Data.Source = sources.find(
s => s.id === source.id
)
return (defaultSource && defaultSource.text) || 'No sources'
}
const selected: Source = sources.find(
const selected: Types.Sources.Data.Source = sources.find(
s => s.links.self === currentSource.links.self
)
return (selected && selected.text) || 'No sources'
@ -503,7 +508,7 @@ class CellEditorOverlay extends Component<Props, State> {
const {queriesWorkingDraft} = this.state
return queriesWorkingDraft.every(
(query: QueryConfig) =>
(query: Types.Queries.Data.QueryConfig) =>
(!!query.measurement && !!query.database && !!query.fields.length) ||
!!query.rawText
)
@ -523,7 +528,7 @@ class CellEditorOverlay extends Component<Props, State> {
return result
}
private get initialSource(): Source {
private get initialSource(): Types.Sources.Data.Source {
const {
cell: {queries},
source,
@ -542,7 +547,7 @@ class CellEditorOverlay extends Component<Props, State> {
return source
}
private get source(): Source {
private get source(): Types.Sources.Data.Source {
const {source, sources} = this.props
const query = _.get(this.state.queriesWorkingDraft, 0, {source: null})

View File

@ -11,28 +11,26 @@ import GraphTips from 'src/shared/components/GraphTips'
import DashboardHeaderEdit from 'src/dashboards/components/DashboardHeaderEdit'
import DashboardSwitcher from 'src/dashboards/components/DashboardSwitcher'
import {Dashboard, TimeRange} from 'src/types'
import {DashboardName} from 'src/types/dashboards'
import * as AppActions from 'src/types/actions/app'
import * as Types from 'src/types/modules'
interface Props {
activeDashboard: string
dashboard: Dashboard
dashboard: Types.Dashboards.Data.Dashboard
onEditDashboard: () => void
timeRange: TimeRange
timeRange: Types.Queries.Data.TimeRange
autoRefresh: number
isEditMode?: boolean
handleChooseTimeRange: (timeRange: TimeRange) => void
handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator
handleChooseTimeRange: (timeRange: Types.Queries.Data.TimeRange) => void
handleChooseAutoRefresh: Types.App.Actions.SetAutoRefreshActionCreator
onManualRefresh: () => void
handleClickPresentationButton: AppActions.DelayEnablePresentationModeDispatcher
handleClickPresentationButton: Types.App.Actions.DelayEnablePresentationModeDispatcher
onAddCell: () => void
onToggleTempVarControls: () => void
showTemplateControlBar: boolean
zoomedTimeRange: TimeRange
zoomedTimeRange: Types.Queries.Data.TimeRange
onCancel: () => void
onSave: (name: string) => Promise<void>
names: DashboardName[]
names: Types.Dashboards.Data.DashboardName[]
isHidden: boolean
}

View File

@ -3,11 +3,8 @@ import classnames from 'classnames'
import ConfirmOrCancel from 'src/shared/components/ConfirmOrCancel'
import SourceSelector from 'src/dashboards/components/SourceSelector'
import {QueryConfig, Source} from 'src/types'
export interface SourceOption extends Source {
text: string
}
import * as Types from 'src/types/modules'
interface Props {
onCancel: () => void
@ -17,10 +14,10 @@ interface Props {
displayOptions: boolean
) => (event: MouseEvent<HTMLLIElement>) => void
isSavable: boolean
sources: SourceOption[]
onSetQuerySource: (source: Source) => void
sources: Types.Sources.Data.SourceOption[]
onSetQuerySource: (source: Types.Sources.Data.Source) => void
selected: string
queries: QueryConfig[]
queries: Types.Queries.Data.QueryConfig[]
}
const OverlayControls: SFC<Props> = ({

View File

@ -1,13 +1,14 @@
import React, {SFC} from 'react'
import Dropdown from 'src/shared/components/Dropdown'
import {QueryConfig} from 'src/types'
import {SourceOption} from 'src/dashboards/components/OverlayControls'
import * as Types from 'src/types/modules'
interface Props {
sources: SourceOption[]
sources: Types.Sources.Data.SourceOption[]
selected: string
onSetQuerySource: (source: SourceOption) => void
queries: QueryConfig[]
onSetQuerySource: (source: Types.Sources.Data.SourceOption) => void
queries: Types.Queries.Data.QueryConfig[]
}
const SourceSelector: SFC<Props> = ({

View File

@ -49,7 +49,8 @@ import {notify} from 'src/shared/actions/notifications'
import 'src/style/chronograf.scss'
import {HEARTBEAT_INTERVAL} from 'src/shared/constants'
import * as ErrorData from 'src/types/errors'
import * as Types from 'src/types/modules'
const errorsQueue = []
@ -190,7 +191,7 @@ class Root extends PureComponent<{}, State> {
errorThrown(
{status: 0, auth: null},
error,
ErrorData.AlertType.Warning
Types.Errors.Data.AlertType.Warning
)
)
}

View File

@ -1,39 +1,38 @@
import * as api from 'src/shared/apis/annotation'
import {Dispatch} from 'redux'
import * as AnnotationData from 'src/types/annotations'
import * as AnnotationActions from 'src/types/actions/annotations'
import * as Types from 'src/types/modules'
export const editingAnnotation = (): AnnotationActions.EditingAnnotationAction => ({
export const editingAnnotation = (): Types.Annotations.Actions.EditingAnnotationAction => ({
type: 'EDITING_ANNOTATION',
})
export const dismissEditingAnnotation = (): AnnotationActions.DismissEditingAnnotationAction => ({
export const dismissEditingAnnotation = (): Types.Annotations.Actions.DismissEditingAnnotationAction => ({
type: 'DISMISS_EDITING_ANNOTATION',
})
export const addingAnnotation = (): AnnotationActions.AddingAnnotationAction => ({
export const addingAnnotation = (): Types.Annotations.Actions.AddingAnnotationAction => ({
type: 'ADDING_ANNOTATION',
})
export const addingAnnotationSuccess = (): AnnotationActions.AddingAnnotationSuccessAction => ({
export const addingAnnotationSuccess = (): Types.Annotations.Actions.AddingAnnotationSuccessAction => ({
type: 'ADDING_ANNOTATION_SUCCESS',
})
export const dismissAddingAnnotation = (): AnnotationActions.DismissAddingAnnotationAction => ({
export const dismissAddingAnnotation = (): Types.Annotations.Actions.DismissAddingAnnotationAction => ({
type: 'DISMISS_ADDING_ANNOTATION',
})
export const mouseEnterTempAnnotation = (): AnnotationActions.MouseEnterTempAnnotationAction => ({
export const mouseEnterTempAnnotation = (): Types.Annotations.Actions.MouseEnterTempAnnotationAction => ({
type: 'MOUSEENTER_TEMP_ANNOTATION',
})
export const mouseLeaveTempAnnotation = (): AnnotationActions.MouseLeaveTempAnnotationAction => ({
export const mouseLeaveTempAnnotation = (): Types.Annotations.Actions.MouseLeaveTempAnnotationAction => ({
type: 'MOUSELEAVE_TEMP_ANNOTATION',
})
export const loadAnnotations = (
annotations: AnnotationData.AnnotationInterface[]
): AnnotationActions.LoadAnnotationsAction => ({
annotations: Types.Annotations.Data.AnnotationInterface[]
): Types.Annotations.Actions.LoadAnnotationsAction => ({
type: 'LOAD_ANNOTATIONS',
payload: {
annotations,
@ -41,8 +40,8 @@ export const loadAnnotations = (
})
export const updateAnnotation = (
annotation: AnnotationData.AnnotationInterface
): AnnotationActions.UpdateAnnotationAction => ({
annotation: Types.Annotations.Data.AnnotationInterface
): Types.Annotations.Actions.UpdateAnnotationAction => ({
type: 'UPDATE_ANNOTATION',
payload: {
annotation,
@ -50,8 +49,8 @@ export const updateAnnotation = (
})
export const deleteAnnotation = (
annotation: AnnotationData.AnnotationInterface
): AnnotationActions.DeleteAnnotationAction => ({
annotation: Types.Annotations.Data.AnnotationInterface
): Types.Annotations.Actions.DeleteAnnotationAction => ({
type: 'DELETE_ANNOTATION',
payload: {
annotation,
@ -59,8 +58,8 @@ export const deleteAnnotation = (
})
export const addAnnotation = (
annotation: AnnotationData.AnnotationInterface
): AnnotationActions.AddAnnotationAction => ({
annotation: Types.Annotations.Data.AnnotationInterface
): Types.Annotations.Actions.AddAnnotationAction => ({
type: 'ADD_ANNOTATION',
payload: {
annotation,
@ -69,7 +68,7 @@ export const addAnnotation = (
export const addAnnotationAsync = (
createUrl: string,
annotation: AnnotationData.AnnotationInterface
annotation: Types.Annotations.Data.AnnotationInterface
) => async dispatch => {
dispatch(addAnnotation(annotation))
const savedAnnotation = await api.createAnnotation(createUrl, annotation)
@ -77,25 +76,25 @@ export const addAnnotationAsync = (
dispatch(deleteAnnotation(annotation))
}
export const getAnnotationsAsync: AnnotationActions.GetAnnotationsDispatcher = (
export const getAnnotationsAsync: Types.Annotations.Actions.GetAnnotationsDispatcher = (
indexUrl: string,
{since, until}: AnnotationData.AnnotationRange
): AnnotationActions.GetAnnotationsThunk => async (
dispatch: Dispatch<AnnotationActions.LoadAnnotationsAction>
{since, until}: Types.Annotations.Data.AnnotationRange
): Types.Annotations.Actions.GetAnnotationsThunk => async (
dispatch: Dispatch<Types.Annotations.Actions.LoadAnnotationsAction>
): Promise<void> => {
const annotations = await api.getAnnotations(indexUrl, since, until)
dispatch(loadAnnotations(annotations))
}
export const deleteAnnotationAsync = (
annotation: AnnotationData.AnnotationInterface
annotation: Types.Annotations.Data.AnnotationInterface
) => async dispatch => {
await api.deleteAnnotation(annotation)
dispatch(deleteAnnotation(annotation))
}
export const updateAnnotationAsync = (
annotation: AnnotationData.AnnotationInterface
annotation: Types.Annotations.Data.AnnotationInterface
) => async dispatch => {
await api.updateAnnotation(annotation)
dispatch(updateAnnotation(annotation))

View File

@ -4,20 +4,20 @@ import {notify} from 'src/shared/actions/notifications'
import {notifyPresentationMode} from 'src/shared/copy/notifications'
import {Dispatch} from 'redux'
import * as AppActions from 'src/types/actions/app'
import * as Types from 'src/types/modules'
// ephemeral state action creators
export const enablePresentationMode = (): AppActions.EnablePresentationModeAction => ({
export const enablePresentationMode = (): Types.App.Actions.EnablePresentationModeAction => ({
type: 'ENABLE_PRESENTATION_MODE',
})
export const disablePresentationMode = (): AppActions.DisablePresentationModeAction => ({
export const disablePresentationMode = (): Types.App.Actions.DisablePresentationModeAction => ({
type: 'DISABLE_PRESENTATION_MODE',
})
export const delayEnablePresentationMode: AppActions.DelayEnablePresentationModeDispatcher = () => async (
dispatch: Dispatch<AppActions.EnablePresentationModeAction>
export const delayEnablePresentationMode: Types.App.Actions.DelayEnablePresentationModeDispatcher = () => async (
dispatch: Dispatch<Types.App.Actions.EnablePresentationModeAction>
): Promise<NodeJS.Timer> =>
setTimeout(() => {
dispatch(enablePresentationMode())
@ -26,20 +26,20 @@ export const delayEnablePresentationMode: AppActions.DelayEnablePresentationMode
// persistent state action creators
export const setAutoRefresh: AppActions.SetAutoRefreshActionCreator = (
export const setAutoRefresh: Types.App.Actions.SetAutoRefreshActionCreator = (
milliseconds: number
): AppActions.SetAutoRefreshAction => ({
): Types.App.Actions.SetAutoRefreshAction => ({
type: 'SET_AUTOREFRESH',
payload: {
milliseconds,
},
})
export const templateControlBarVisibilityToggled = (): AppActions.TemplateControlBarVisibilityToggledAction => ({
export const templateControlBarVisibilityToggled = (): Types.App.Actions.TemplateControlBarVisibilityToggledAction => ({
type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED',
})
export const noop = (): AppActions.NoopAction => ({
export const noop = (): Types.App.Actions.NoopAction => ({
type: 'NOOP',
payload: {},
})

View File

@ -1,11 +1,10 @@
import * as ErrorData from 'src/types/errors'
import * as ErrorActions from 'src/types/actions/errors'
import * as Types from 'src/types/modules'
export const errorThrown = (
error: ErrorData.ErrorDescription,
error: Types.Errors.Data.ErrorDescription,
altText?: string,
alertType?: ErrorData.AlertType
): ErrorActions.ErrorThrownAction => ({
alertType?: Types.Errors.Data.AlertType
): Types.Errors.Actions.ErrorThrownAction => ({
type: 'ERROR_THROWN',
error,
altText,

View File

@ -1,15 +1,14 @@
import {Notification} from 'src/types'
import * as NotificationActions from 'src/types/actions/notifications'
import * as Types from 'src/types/modules'
export const notify: NotificationActions.PublishNotificationActionCreator = (
notification: Notification
): NotificationActions.PublishNotificationAction => ({
export const notify: Types.Notifications.Actions.PublishNotificationActionCreator = (
notification: Types.Notifications.Data.Notification
): Types.Notifications.Actions.PublishNotificationAction => ({
type: 'PUBLISH_NOTIFICATION',
payload: {notification},
})
export const dismissNotification = (
id: string
): NotificationActions.DismissNotificationAction => ({
): Types.Notifications.Actions.DismissNotificationAction => ({
type: 'DISMISS_NOTIFICATION',
payload: {id},
})

View File

@ -29,11 +29,10 @@ import {
} from 'src/shared/copy/notifications'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {Source} from 'src/types'
import * as NotificationActions from 'src/types/actions/notifications'
import * as Types from 'src/types/modules'
interface Props extends WithRouterProps {
notify: NotificationActions.PublishNotificationActionCreator
notify: Types.Notifications.Actions.PublishNotificationActionCreator
addSource: AddSource
updateSource: UpdateSource
}
@ -41,7 +40,7 @@ interface Props extends WithRouterProps {
interface State {
isCreated: boolean
isLoading: boolean
source: Partial<Source>
source: Partial<Types.Sources.Data.Source>
editMode: boolean
isInitialSource: boolean
}

View File

@ -1,6 +1,4 @@
import {Cell} from 'src/types'
import {ColorNumber, ColorString} from 'src/types/colors'
import * as DashboardData from 'src/types/dashboards'
import * as Types from 'src/types/modules'
export type Action =
| ShowCellEditorOverlayAction
@ -18,13 +16,13 @@ export type Action =
| UpdateFieldOptionsAction
export type ShowCellEditorOverlayActionCreator = (
cell: Cell
cell: Types.Dashboards.Data.Cell
) => ShowCellEditorOverlayAction
export interface ShowCellEditorOverlayAction {
type: 'SHOW_CELL_EDITOR_OVERLAY'
payload: {
cell: Cell
cell: Types.Dashboards.Data.Cell
}
}
@ -37,7 +35,7 @@ export interface HideCellEditorOverlayAction {
export interface ChangeCellTypeAction {
type: 'CHANGE_CELL_TYPE'
payload: {
cellType: DashboardData.CellType
cellType: Types.Dashboards.Data.CellType
}
}
@ -51,42 +49,42 @@ export interface RenameCellAction {
export interface UpdateThresholdsListColorsAction {
type: 'UPDATE_THRESHOLDS_LIST_COLORS'
payload: {
thresholdsListColors: ColorNumber[]
thresholdsListColors: Types.Colors.Data.ColorNumber[]
}
}
export interface UpdateThresholdsListTypeAction {
type: 'UPDATE_THRESHOLDS_LIST_TYPE'
payload: {
thresholdsListType: DashboardData.ThresholdType
thresholdsListType: Types.Dashboards.Data.ThresholdType
}
}
export interface UpdateGaugeColorsAction {
type: 'UPDATE_GAUGE_COLORS'
payload: {
gaugeColors: ColorNumber[]
gaugeColors: Types.Colors.Data.ColorNumber[]
}
}
export interface UpdateAxesAction {
type: 'UPDATE_AXES'
payload: {
axes: DashboardData.Axes
axes: Types.Dashboards.Data.Axes
}
}
export interface UpdateTableOptionsAction {
type: 'UPDATE_TABLE_OPTIONS'
payload: {
tableOptions: DashboardData.TableOptions
tableOptions: Types.Dashboards.Data.TableOptions
}
}
export interface UpdateLineColorsAction {
type: 'UPDATE_LINE_COLORS'
payload: {
lineColors: ColorString[]
lineColors: Types.Colors.Data.ColorString[]
}
}
@ -100,13 +98,13 @@ export interface ChangeTimeFormatAction {
export interface ChangeDecimalPlacesAction {
type: 'CHANGE_DECIMAL_PLACES'
payload: {
decimalPlaces: DashboardData.DecimalPlaces
decimalPlaces: Types.Dashboards.Data.DecimalPlaces
}
}
export interface UpdateFieldOptionsAction {
type: 'UPDATE_FIELD_OPTIONS'
payload: {
fieldOptions: DashboardData.FieldOption[]
fieldOptions: Types.Dashboards.Data.FieldOption[]
}
}

View File

@ -2,35 +2,30 @@ import {Dispatch} from 'redux'
import {InjectedRouter} from 'react-router'
import {LocationAction} from 'react-router-redux'
import {Source} from 'src/types'
import * as DashboardData from 'src/types/dashboards'
import * as QueryData from 'src/types/query'
import * as TempVarData from 'src/types/tempVars'
import * as ErrorActions from 'src/types/actions/errors'
import * as NotificationActions from 'src/types/actions/notifications'
import * as DashboardReducers from 'src/types/reducers/dashboards'
import {Location} from 'history'
import * as Types from 'src/types/modules'
export type LoadDashboardsActionCreator = (
dashboards: DashboardData.Dashboard[],
dashboards: Types.Dashboards.Data.Dashboard[],
dashboardID?: number
) => LoadDashboardsAction
export interface LoadDashboardsAction {
type: 'LOAD_DASHBOARDS'
payload: {
dashboards: DashboardData.Dashboard[]
dashboards: Types.Dashboards.Data.Dashboard[]
dashboardID: number
}
}
export type LoadDashboardActionCreator = (
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
) => LoadDashboardAction
export interface LoadDashboardAction {
type: 'LOAD_DASHBOARD'
payload: {
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
}
}
@ -38,13 +33,13 @@ export interface SetDashTimeV1Action {
type: 'SET_DASHBOARD_TIME_V1'
payload: {
dashboardID: number
timeRange: QueryData.TimeRange
timeRange: Types.Queries.Data.TimeRange
}
}
export type SetDashTimeV1ActionCreator = (
dashboardID: number,
timeRange: QueryData.TimeRange
timeRange: Types.Queries.Data.TimeRange
) => SetDashTimeV1Action
export interface RetainRangesDashTimeV1Action {
@ -59,18 +54,18 @@ export type RetainRangesDashTimeV1ActionCreator = (
) => RetainRangesDashTimeV1Action
export type SetTimeRangeActionCreator = (
timeRange: QueryData.TimeRange
timeRange: Types.Queries.Data.TimeRange
) => SetTimeRangeAction
export interface SetTimeRangeAction {
type: 'SET_DASHBOARD_TIME_RANGE'
payload: {
timeRange: QueryData.TimeRange
timeRange: Types.Queries.Data.TimeRange
}
}
export type SetZoomedTimeRangeDispatcher = (
zoomedTimeRange: QueryData.TimeRange,
zoomedTimeRange: Types.Queries.Data.TimeRange,
location: Location
) => SetZoomedTimeRangeThunk
@ -82,135 +77,135 @@ export type SetZoomedTimeRangeThunk = (
) => Promise<void>
export type SetZoomedTimeRangeActionCreator = (
zoomedTimeRange: QueryData.TimeRange
zoomedTimeRange: Types.Queries.Data.TimeRange
) => SetZoomedTimeRangeAction
export interface SetZoomedTimeRangeAction {
type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE'
payload: {
zoomedTimeRange: QueryData.TimeRange
zoomedTimeRange: Types.Queries.Data.TimeRange
}
}
export interface UpdateDashboardAction {
type: 'UPDATE_DASHBOARD'
payload: {
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
}
}
export type UpdateDashboardActionCreator = (
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
) => UpdateDashboardAction
export type CreateDashboardActionCreator = (
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
) => CreateDashboardAction
export interface CreateDashboardAction {
type: 'CREATE_DASHBOARD'
payload: {
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
}
}
export type DeleteDashboardActionCreator = (
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
) => DeleteDashboardAction
export interface DeleteDashboardAction {
type: 'DELETE_DASHBOARD'
payload: {
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
}
}
export type DeleteDashboardFailedActionCreator = (
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
) => DeleteDashboardFailedAction
export interface DeleteDashboardFailedAction {
type: 'DELETE_DASHBOARD_FAILED'
payload: {
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
}
}
export type SyncDashboardCellActionCreator = (
dashboard: DashboardData.Dashboard,
cell: DashboardData.Cell
dashboard: Types.Dashboards.Data.Dashboard,
cell: Types.Dashboards.Data.Cell
) => SyncDashboardCellAction
export interface SyncDashboardCellAction {
type: 'SYNC_DASHBOARD_CELL'
payload: {
dashboard: DashboardData.Dashboard
cell: DashboardData.Cell
dashboard: Types.Dashboards.Data.Dashboard
cell: Types.Dashboards.Data.Cell
}
}
export type AddDashboardCellDispatcher = (
dashboard: DashboardData.Dashboard,
cellType?: DashboardData.CellType
dashboard: Types.Dashboards.Data.Dashboard,
cellType?: Types.Dashboards.Data.CellType
) => AddDashboardCellThunk
export type AddDashboardCellThunk = (
dispatch: Dispatch<
| AddDashboardCellAction
| NotificationActions.PublishNotificationActionCreator
| ErrorActions.ErrorThrownActionCreator
| Types.Notifications.Actions.PublishNotificationActionCreator
| Types.Errors.Actions.ErrorThrownActionCreator
>
) => Promise<void>
export type AddDashboardCellActionCreator = (
dashboard: DashboardData.Dashboard,
cell: DashboardData.Cell
dashboard: Types.Dashboards.Data.Dashboard,
cell: Types.Dashboards.Data.Cell
) => AddDashboardCellAction
export interface AddDashboardCellAction {
type: 'ADD_DASHBOARD_CELL'
payload: {
dashboard: DashboardData.Dashboard
cell: DashboardData.Cell
dashboard: Types.Dashboards.Data.Dashboard
cell: Types.Dashboards.Data.Cell
}
}
export type CloneDashboardCellDispatcher = (
dashboard: DashboardData.Dashboard,
cell: DashboardData.Cell
dashboard: Types.Dashboards.Data.Dashboard,
cell: Types.Dashboards.Data.Cell
) => CloneDashboardCellThunk
export type CloneDashboardCellThunk = (
dispatch: Dispatch<
| AddDashboardCellAction
| NotificationActions.PublishNotificationActionCreator
| ErrorActions.ErrorThrownActionCreator
| Types.Notifications.Actions.PublishNotificationActionCreator
| Types.Errors.Actions.ErrorThrownActionCreator
>
) => Promise<void>
export type DeleteDashboardCellDispatcher = (
dashboard: DashboardData.Dashboard,
cell: DashboardData.Cell
dashboard: Types.Dashboards.Data.Dashboard,
cell: Types.Dashboards.Data.Cell
) => DeleteDashboardCellThunk
export type DeleteDashboardCellThunk = (
dispatch: Dispatch<
| DeleteDashboardCellActionCreator
| NotificationActions.PublishNotificationActionCreator
| ErrorActions.ErrorThrownActionCreator
| Types.Notifications.Actions.PublishNotificationActionCreator
| Types.Errors.Actions.ErrorThrownActionCreator
>
) => Promise<void>
export type DeleteDashboardCellActionCreator = (
dashboard: DashboardData.Dashboard,
cell: DashboardData.Cell
dashboard: Types.Dashboards.Data.Dashboard,
cell: Types.Dashboards.Data.Cell
) => DeleteDashboardCellAction
export interface DeleteDashboardCellAction {
type: 'DELETE_DASHBOARD_CELL'
payload: {
dashboard: DashboardData.Dashboard
cell: DashboardData.Cell
dashboard: Types.Dashboards.Data.Dashboard
cell: Types.Dashboards.Data.Cell
}
}
@ -244,14 +239,14 @@ export interface TemplateVariableSelectedAction {
export type TemplateVariablesSelectedByNameActionCreator = (
dashboardID: number,
queryParams: TempVarData.URLQueryParams
queryParams: Types.TempVars.Data.URLQueryParams
) => TemplateVariablesSelectedByNameAction
export interface TemplateVariablesSelectedByNameAction {
type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME'
payload: {
dashboardID: number
queryParams: TempVarData.URLQueryParams
queryParams: Types.TempVars.Data.URLQueryParams
}
}
@ -295,24 +290,24 @@ export interface SetActiveCellAction {
export type GetDashboardsDispatcher = () => GetDashboardsThunk
export type GetDashboardsThunk = (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>
) => Promise<DashboardData.Dashboard[] | void>
dispatch: Dispatch<Types.Errors.Actions.ErrorThrownActionCreator>
) => Promise<Types.Dashboards.Data.Dashboard[] | void>
export type GetDashboardsNamesDispatcher = (
sourceID: string
) => GetDashboardsNamesThunk
export type GetDashboardsNamesThunk = (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>
) => Promise<DashboardData.DashboardName[] | void>
dispatch: Dispatch<Types.Errors.Actions.ErrorThrownActionCreator>
) => Promise<Types.Dashboards.Data.DashboardName[] | void>
export type PutDashboardDispatcher = (
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
) => PutDashboardThunk
export type PutDashboardThunk = (
dispatch: Dispatch<
UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator
UpdateDashboardAction | Types.Errors.Actions.ErrorThrownActionCreator
>
) => Promise<void>
@ -321,45 +316,46 @@ export type PutDashboardByIDDispatcher = (
) => PutDashboardByIDThunk
export type PutDashboardByIDThunk = (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>,
getState: () => DashboardReducers.Dashboards
dispatch: Dispatch<Types.Errors.Actions.ErrorThrownActionCreator>,
getState: () => Types.Dashboards.Reducers.Dashboards
) => Promise<void>
export type DeleteDashboardDispatcher = (
dashboard: DashboardData.Dashboard
dashboard: Types.Dashboards.Data.Dashboard
) => DeleteDashboardThunk
export type DeleteDashboardThunk = (
dispatch: Dispatch<
| DeleteDashboardActionCreator
| NotificationActions.PublishNotificationActionCreator
| ErrorActions.ErrorThrownActionCreator
| Types.Notifications.Actions.PublishNotificationActionCreator
| Types.Errors.Actions.ErrorThrownActionCreator
| DeleteDashboardFailedActionCreator
>
) => Promise<void>
export type UpdateDashboardCellDispatcher = (
dashboard: DashboardData.Dashboard,
cell: DashboardData.Cell
dashboard: Types.Dashboards.Data.Dashboard,
cell: Types.Dashboards.Data.Cell
) => UpdateDashboardCellThunk
export type UpdateDashboardCellThunk = (
dispatch: Dispatch<
SyncDashboardCellActionCreator | ErrorActions.ErrorThrownActionCreator
| SyncDashboardCellActionCreator
| Types.Errors.Actions.ErrorThrownActionCreator
>
) => Promise<void>
export type SyncURLQueryFromQueryParamsObjectDispatcher = (
location: Location,
updatedURLQueryParams: TempVarData.URLQueryParams,
deletedURLQueryParams?: TempVarData.URLQueryParams
updatedURLQueryParams: Types.TempVars.Data.URLQueryParams,
deletedURLQueryParams?: Types.TempVars.Data.URLQueryParams
) => SyncURLQueryFromQueryParamsObjectActionCreator
export type SyncURLQueryFromTempVarsDispatcher = (
location: Location,
tempVars: TempVarData.Template[],
deletedTempVars: TempVarData.Template[],
urlQueryParamsTimeRanges?: TempVarData.URLQueryParams
tempVars: Types.TempVars.Data.Template[],
deletedTempVars: Types.TempVars.Data.Template[],
urlQueryParamsTimeRanges?: Types.TempVars.Data.URLQueryParams
) => SyncURLQueryFromQueryParamsObjectActionCreator
export type SyncURLQueryFromQueryParamsObjectActionCreator = (
@ -368,15 +364,19 @@ export type SyncURLQueryFromQueryParamsObjectActionCreator = (
export type SyncDashboardTempVarsFromURLQueryParamsDispatcher = (
dispatch: Dispatch<
| NotificationActions.PublishNotificationActionCreator
| Types.Notifications.Actions.PublishNotificationActionCreator
| TemplateVariableSelectedAction
>,
getState: () => DashboardReducers.Dashboards & DashboardReducers.Auth
getState: () => Types.Dashboards.Reducers.Dashboards &
Types.Dashboards.Reducers.Auth
) => void
export type SyncDashboardTimeRangeFromURLQueryParamsDispatcher = (
dispatch: Dispatch<NotificationActions.PublishNotificationActionCreator>,
getState: () => DashboardReducers.Dashboards & DashboardReducers.DashTimeV1
dispatch: Dispatch<
Types.Notifications.Actions.PublishNotificationActionCreator
>,
getState: () => Types.Dashboards.Reducers.Dashboards &
Types.Dashboards.Reducers.DashTimeV1
) => void
export type SyncDashboardFromURLQueryParamsDispatcher = (
@ -394,5 +394,7 @@ export type GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = (
) => GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk
export type GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk = (
dispatch: Dispatch<NotificationActions.PublishNotificationActionCreator>
dispatch: Dispatch<
Types.Notifications.Actions.PublishNotificationActionCreator
>
) => Promise<void>

View File

@ -1,3 +1,4 @@
import * as Actions from 'src/types/actions/annotations'
import * as Data from 'src/types/annotations'
export {Actions}
export {Actions, Data}

View File

@ -1,3 +1,4 @@
import * as Actions from 'src/types/actions/errors'
import * as Data from 'src/types/errors'
export {Actions}
export {Actions, Data}

View File

@ -1,3 +1,4 @@
import * as Actions from 'src/types/actions/notifications'
import * as Data from 'src/types/notifications'
export {Actions}
export {Actions, Data}

View File

@ -37,3 +37,7 @@ export interface SourceLinks {
health: string
services: string
}
export interface SourceOption extends Source {
text: string
}