mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
20 lines
727 B
TypeScript
20 lines
727 B
TypeScript
import { AppNotification, AppNotificationsState } from 'app/types/';
|
|
import { Action, ActionTypes } from '../actions/appNotification';
|
|
|
|
export const initialState: AppNotificationsState = {
|
|
appNotifications: [] as AppNotification[],
|
|
};
|
|
|
|
export const appNotificationsReducer = (state = initialState, action: Action): AppNotificationsState => {
|
|
switch (action.type) {
|
|
case ActionTypes.AddAppNotification:
|
|
return { ...state, appNotifications: state.appNotifications.concat([action.payload]) };
|
|
case ActionTypes.ClearAppNotification:
|
|
return {
|
|
...state,
|
|
appNotifications: state.appNotifications.filter(appNotification => appNotification.id !== action.payload),
|
|
};
|
|
}
|
|
return state;
|
|
};
|