fleet/frontend/components/FlashMessage/FlashMessage.jsx
Mike Stone db57aaa1fc Filter unchanged attributes when updating user (#293)
* Only send changed user attributes to the server

* Improve flash message styles

* Do not allow admins to demote or disable their own account

* Disable admin actions against self
2016-10-07 13:07:02 -04:00

47 lines
1.2 KiB
JavaScript

import React, { PropTypes } from 'react';
import radium from 'radium';
import componentStyles from './styles';
import { hideFlash } from '../../redux/nodes/notifications/actions';
const FlashMessage = ({ notification, dispatch }) => {
const { alertType, isVisible, message, undoAction } = notification;
const {
containerStyles,
contentStyles,
flashActionStyles,
removeFlashMessageStyles,
undoStyles,
} = componentStyles;
const submitUndoAction = () => {
dispatch(undoAction);
dispatch(hideFlash);
return false;
};
const removeFlashMessage = () => {
dispatch(hideFlash);
return false;
};
if (!isVisible) return false;
return (
<div style={containerStyles(alertType)}>
<div style={contentStyles}>
{message}
</div>
<div style={flashActionStyles}>
<div onClick={submitUndoAction} style={undoStyles}>{undoAction && 'undo'}</div>
<div onClick={removeFlashMessage} style={removeFlashMessageStyles(alertType)}>x</div>
</div>
</div>
);
};
FlashMessage.propTypes = {
dispatch: PropTypes.func,
notification: PropTypes.object,
};
export default radium(FlashMessage);