Refactor notifications types file structure & imports to new style

pull/10616/head
Jared Scheib 2018-06-22 18:14:46 -07:00
parent d74ad08c2c
commit 28b919908b
7 changed files with 38 additions and 37 deletions

View File

@ -72,7 +72,7 @@ import * as DashboardActions from 'src/types/actions/dashboards'
import * as DashboardAPIs from 'src/types/apis/dashboard'
import * as DashboardReducers from 'src/types/reducers/dashboards'
import * as AuthReducers from 'src/types/reducers/auth'
import * as NotificationActions from 'src/shared/actions/notifications'
import * as NotificationActions from 'src/types/actions/notifications'
import * as ErrorActions from 'src/types/actions/errors'
import {LocationAction} from 'react-router-redux'

View File

@ -66,7 +66,7 @@ import * as AppActions from 'src/shared/actions/app'
import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay'
import * as DashboardActions from 'src/types/actions/dashboards'
import * as ErrorActions from 'src/types/actions/errors'
import * as NotificationActions from 'src/shared/actions/notifications'
import * as NotificationActions from 'src/types/actions/notifications'
interface DashboardActions {
setDashTimeV1: DashboardActions.SetDashTimeV1ActionCreator

View File

@ -1,36 +1,15 @@
import {Notification} from 'src/types'
import * as NotificationActions from 'src/types/actions/notifications'
export type Action = PublishNotificationAction | ActionDismissNotification
// Publish notification
export type PublishNotificationActionCreator = (
n: Notification
) => PublishNotificationAction
export interface PublishNotificationAction {
type: 'PUBLISH_NOTIFICATION'
payload: {
notification: Notification
}
}
export const notify: PublishNotificationActionCreator = (
export const notify: NotificationActions.PublishNotificationActionCreator = (
notification: Notification
): PublishNotificationAction => ({
): NotificationActions.PublishNotificationAction => ({
type: 'PUBLISH_NOTIFICATION',
payload: {notification},
})
// Dismiss notification
export type DismissNotification = (id: string) => ActionDismissNotification
export interface ActionDismissNotification {
type: 'DISMISS_NOTIFICATION'
payload: {
id: string
}
}
export const dismissNotification = (id: string): ActionDismissNotification => ({
export const dismissNotification = (
id: string
): NotificationActions.DismissNotificationAction => ({
type: 'DISMISS_NOTIFICATION',
payload: {id},
})

View File

@ -1,5 +1,5 @@
import uuid from 'uuid'
import {Action} from 'src/shared/actions/notifications'
import {Action} from 'src/types/actions/notifications'
import {Notification} from 'src/types'
export const initialState: Notification[] = []

View File

@ -9,10 +9,7 @@ import {
AddSource,
UpdateSource,
} from 'src/shared/actions/sources'
import {
notify as notifyAction,
PublishNotificationActionCreator,
} from 'src/shared/actions/notifications'
import {notify as notifyAction} from 'src/shared/actions/notifications'
import {connect} from 'react-redux'
import Notifications from 'src/shared/components/Notifications'
@ -20,7 +17,6 @@ import SourceForm from 'src/sources/components/SourceForm'
import FancyScrollbar from 'src/shared/components/FancyScrollbar'
import PageHeader from 'src/shared/components/PageHeader'
import {DEFAULT_SOURCE} from 'src/shared/constants'
import {Source} from 'src/types'
const INITIAL_PATH = '/sources/new'
@ -33,8 +29,11 @@ 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'
interface Props extends WithRouterProps {
notify: PublishNotificationActionCreator
notify: NotificationActions.PublishNotificationActionCreator
addSource: AddSource
updateSource: UpdateSource
}

View File

@ -6,7 +6,7 @@ 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/shared/actions/notifications'
import * as NotificationActions from 'src/types/actions/notifications'
import * as DashboardReducers from 'src/types/reducers/dashboards'
import {Location} from 'history'

View File

@ -0,0 +1,23 @@
import {Notification} from 'src/types'
export type Action = PublishNotificationAction | DismissNotificationAction
export type PublishNotificationActionCreator = (
n: Notification
) => PublishNotificationAction
export interface PublishNotificationAction {
type: 'PUBLISH_NOTIFICATION'
payload: {
notification: Notification
}
}
export type DismissNotification = (id: string) => DismissNotificationAction
export interface DismissNotificationAction {
type: 'DISMISS_NOTIFICATION'
payload: {
id: string
}
}