mirror of
https://github.com/fleetdm/fleet
synced 2026-05-15 04:58:25 +00:00
* 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
47 lines
1.2 KiB
JavaScript
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);
|