virtuacoplenny da1c760abf feat(notifications): implement a react/redux notification system (#1786)
* feat(notifications): implement a react/redux notification system

* squash into impl explicit timeout, style

* ref(notifications): convert toastr notifications to use react

* ref(toastr): remove library

* squash into conversion: pass timeout

* squash into clean remove from debian patch
2017-07-28 12:56:49 -05:00

48 lines
1.1 KiB
JavaScript

import {
HIDE_NOTIFICATION,
SHOW_NOTIFICATION
} from './actionTypes';
/**
* Removes the notification with the passed in id.
*
* @param {string} uid - The unique identifier for the notification to be
* removed.
* @returns {{
* type: HIDE_NOTIFICATION,
* uid: string
* }}
*/
export function hideNotification(uid) {
return {
type: HIDE_NOTIFICATION,
uid
};
}
/**
* Queues a notification for display.
*
* @param {ReactComponent} component - The notification component to be
* displayed.
* @param {Object} props - The props needed to show the notification component.
* @param {number} timeout - How long the notification should display before
* automatically being hidden.
* @returns {{
* type: SHOW_NOTIFICATION,
* component: ReactComponent,
* props: Object,
* timeout: number,
* uid: number
* }}
*/
export function showNotification(component, props = {}, timeout) {
return {
type: SHOW_NOTIFICATION,
component,
props,
timeout,
uid: window.Date.now()
};
}