Type notification actions / reducers / tests
parent
fd3cd78f0b
commit
868fcc6746
|
@ -1,9 +0,0 @@
|
|||
export const notify = notification => ({
|
||||
type: 'PUBLISH_NOTIFICATION',
|
||||
payload: {notification},
|
||||
})
|
||||
|
||||
export const dismissNotification = id => ({
|
||||
type: 'DISMISS_NOTIFICATION',
|
||||
payload: {id},
|
||||
})
|
|
@ -0,0 +1,33 @@
|
|||
import {Notification} from 'src/types'
|
||||
|
||||
export type Action = ActionPublishNotification | ActionDismissNotification
|
||||
|
||||
// Publish notification
|
||||
export type PubishNotification = (n: Notification) => ActionPublishNotification
|
||||
export interface ActionPublishNotification {
|
||||
type: 'PUBLISH_NOTIFICATION'
|
||||
payload: {
|
||||
notification: Notification
|
||||
}
|
||||
}
|
||||
|
||||
export const notify = (
|
||||
notification: Notification
|
||||
): ActionPublishNotification => ({
|
||||
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 => ({
|
||||
type: 'DISMISS_NOTIFICATION',
|
||||
payload: {id},
|
||||
})
|
|
@ -155,7 +155,7 @@ export const removeAndLoadSources = (source: Source) => async (
|
|||
} = await getSourcesAJAX()
|
||||
dispatch(loadSources(newSources))
|
||||
} catch (err) {
|
||||
dispatch(notify(notifyServerError()))
|
||||
dispatch(notify(notifyServerError))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,14 +69,14 @@ export const notifySessionTimedOut = () => ({
|
|||
message: 'Your session has timed out. Log in again to continue.',
|
||||
})
|
||||
|
||||
export const notifyServerError = () => ({
|
||||
export const notifyServerError = {
|
||||
...defaultErrorNotification,
|
||||
mesasage: 'Internal Server Error. Check API Logs.',
|
||||
})
|
||||
message: 'Internal Server Error. Check API Logs.',
|
||||
}
|
||||
|
||||
export const notifyCouldNotRetrieveKapacitors = sourceID => ({
|
||||
...defaultErrorNotification,
|
||||
mesasage: `Internal Server Error. Could not retrieve Kapacitor Connections for source ${sourceID}.`,
|
||||
message: `Internal Server Error. Could not retrieve Kapacitor Connections for source ${sourceID}.`,
|
||||
})
|
||||
|
||||
export const notifyCouldNotRetrieveKapacitorServices = kapacitor => ({
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import uuid from 'uuid'
|
||||
export const initialState = []
|
||||
import {Action} from 'src/shared/actions/notifications'
|
||||
import {Notification} from 'src/types'
|
||||
|
||||
export const notifications = (state = initialState, action) => {
|
||||
export const initialState: Notification[] = []
|
||||
|
||||
export const notifications = (state = initialState, action: Action) => {
|
||||
switch (action.type) {
|
||||
case 'PUBLISH_NOTIFICATION': {
|
||||
const {notification} = action.payload
|
|
@ -1,8 +1,8 @@
|
|||
import {initialState, notifications} from 'shared/reducers/notifications'
|
||||
import {initialState, notifications} from 'src/shared/reducers/notifications'
|
||||
|
||||
import {notify, dismissNotification} from 'shared/actions/notifications'
|
||||
import {notify, dismissNotification} from 'src/shared/actions/notifications'
|
||||
|
||||
import {FIVE_SECONDS} from 'shared/constants/index'
|
||||
import {FIVE_SECONDS} from 'src/shared/constants/index'
|
||||
|
||||
const notificationID = '000'
|
||||
|
Loading…
Reference in New Issue