Refactor error types to follow new file structure
Co-authored-by: Jared Scheib <jared.scheib@gmail.com>pull/10616/head
parent
61130535e5
commit
058af91e46
|
@ -73,7 +73,7 @@ import * as DashboardAPIs from 'src/types/apis/dashboard'
|
||||||
import * as DashboardReducers from 'src/types/reducers/dashboard'
|
import * as DashboardReducers from 'src/types/reducers/dashboard'
|
||||||
import * as AuthReducers from 'src/types/reducers/auth'
|
import * as AuthReducers from 'src/types/reducers/auth'
|
||||||
import * as NotificationActions from 'src/shared/actions/notifications'
|
import * as NotificationActions from 'src/shared/actions/notifications'
|
||||||
import * as ErrorActions from 'src/shared/actions/errors'
|
import * as ErrorActions from 'src/types/actions/error'
|
||||||
import {LocationAction} from 'react-router-redux'
|
import {LocationAction} from 'react-router-redux'
|
||||||
|
|
||||||
export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = (
|
export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = (
|
||||||
|
|
|
@ -65,7 +65,7 @@ import * as AnnotationActions from 'src/shared/actions/annotations'
|
||||||
import * as AppActions from 'src/shared/actions/app'
|
import * as AppActions from 'src/shared/actions/app'
|
||||||
import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay'
|
import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay'
|
||||||
import * as DashboardActions from 'src/types/actions/dashboard'
|
import * as DashboardActions from 'src/types/actions/dashboard'
|
||||||
import * as ErrorActions from 'src/shared/actions/errors'
|
import * as ErrorActions from 'src/types/actions/error'
|
||||||
import * as NotificationActions from 'src/shared/actions/notifications'
|
import * as NotificationActions from 'src/shared/actions/notifications'
|
||||||
|
|
||||||
interface DashboardActions {
|
interface DashboardActions {
|
||||||
|
|
|
@ -49,6 +49,7 @@ import {notify} from 'src/shared/actions/notifications'
|
||||||
import 'src/style/chronograf.scss'
|
import 'src/style/chronograf.scss'
|
||||||
|
|
||||||
import {HEARTBEAT_INTERVAL} from 'src/shared/constants'
|
import {HEARTBEAT_INTERVAL} from 'src/shared/constants'
|
||||||
|
import * as ErrorData from 'src/types/error'
|
||||||
|
|
||||||
const errorsQueue = []
|
const errorsQueue = []
|
||||||
|
|
||||||
|
@ -185,7 +186,13 @@ class Root extends PureComponent<{}, State> {
|
||||||
if (typeof error === 'object') {
|
if (typeof error === 'object') {
|
||||||
dispatch(notify(error))
|
dispatch(notify(error))
|
||||||
} else {
|
} else {
|
||||||
dispatch(errorThrown({status: 0, auth: null}, error, 'warning'))
|
dispatch(
|
||||||
|
errorThrown(
|
||||||
|
{status: 0, auth: null},
|
||||||
|
error,
|
||||||
|
ErrorData.AlertType.Warning
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,13 @@
|
||||||
enum AlertType {
|
import * as ErrorData from 'src/types/error'
|
||||||
'info',
|
import * as ErrorActions from 'src/types/actions/error'
|
||||||
}
|
|
||||||
|
|
||||||
export type ErrorThrownActionCreator = (
|
|
||||||
error: Error,
|
|
||||||
altText?: string,
|
|
||||||
alertType?: AlertType
|
|
||||||
) => ErrorThrownAction
|
|
||||||
|
|
||||||
interface ErrorThrownAction {
|
|
||||||
type: 'ERROR_THROWN'
|
|
||||||
error: ErrorDescription
|
|
||||||
altText?: string
|
|
||||||
alertType?: AlertType
|
|
||||||
}
|
|
||||||
export const errorThrown = (
|
export const errorThrown = (
|
||||||
error: ErrorDescription,
|
error: ErrorData.ErrorDescription,
|
||||||
altText?: string,
|
altText?: string,
|
||||||
alertType?: AlertType
|
alertType?: ErrorData.AlertType
|
||||||
): ErrorThrownAction => ({
|
): ErrorActions.ErrorThrownAction => ({
|
||||||
type: 'ERROR_THROWN',
|
type: 'ERROR_THROWN',
|
||||||
error,
|
error,
|
||||||
altText,
|
altText,
|
||||||
alertType,
|
alertType,
|
||||||
})
|
})
|
||||||
|
|
||||||
interface ErrorDescription {
|
|
||||||
status: number
|
|
||||||
auth: {
|
|
||||||
links: {
|
|
||||||
me: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {Source} from 'src/types'
|
||||||
import * as DashboardData from 'src/types/dashboard'
|
import * as DashboardData from 'src/types/dashboard'
|
||||||
import * as QueryData from 'src/types/query'
|
import * as QueryData from 'src/types/query'
|
||||||
import * as TempVarData from 'src/types/tempVars'
|
import * as TempVarData from 'src/types/tempVars'
|
||||||
import * as ErrorActions from 'src/shared/actions/errors'
|
import * as ErrorActions from 'src/types/actions/error'
|
||||||
import * as NotificationActions from 'src/shared/actions/notifications'
|
import * as NotificationActions from 'src/shared/actions/notifications'
|
||||||
import * as DashboardReducers from 'src/types/reducers/dashboard'
|
import * as DashboardReducers from 'src/types/reducers/dashboard'
|
||||||
import {Location} from 'history'
|
import {Location} from 'history'
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import * as ErrorData from 'src/types/error'
|
||||||
|
|
||||||
|
export type ErrorThrownActionCreator = (
|
||||||
|
error: ErrorData.ErrorDescription,
|
||||||
|
altText?: string,
|
||||||
|
alertType?: ErrorData.AlertType
|
||||||
|
) => ErrorThrownAction
|
||||||
|
|
||||||
|
export interface ErrorThrownAction {
|
||||||
|
type: 'ERROR_THROWN'
|
||||||
|
error: ErrorData.ErrorDescription
|
||||||
|
altText?: string
|
||||||
|
alertType?: ErrorData.AlertType
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
export interface ErrorDescription {
|
||||||
|
status: number
|
||||||
|
auth: {
|
||||||
|
links: {
|
||||||
|
me: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum AlertType {
|
||||||
|
Info = 'info',
|
||||||
|
Warning = 'warning',
|
||||||
|
}
|
Loading…
Reference in New Issue