mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* Updates eslint packages * Expected parentheses around arrow function argument having a body with curly braces * Prop type `object` is forbidden * Visible, non-interactive elements should not have mouse or keyboard event listeners * Prop type is defined but not used * Unexpected use of file extension "jsx" * Expected 'this' to be used by class method * HTML entities must be escaped * Prevent default behavior on more options button click
63 lines
1.4 KiB
JavaScript
63 lines
1.4 KiB
JavaScript
import React, { PropTypes } from 'react';
|
|
import radium from 'radium';
|
|
|
|
import componentStyles from './styles';
|
|
import { hideFlash } from '../../redux/nodes/notifications/actions';
|
|
import notificationInterface from '../../interfaces/notification';
|
|
|
|
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}>
|
|
<button
|
|
className="btn--unstyled"
|
|
onClick={submitUndoAction}
|
|
style={undoStyles}
|
|
>
|
|
{undoAction && 'undo'}
|
|
</button>
|
|
<button
|
|
className="btn--unstyled"
|
|
onClick={removeFlashMessage}
|
|
style={removeFlashMessageStyles(alertType)}
|
|
>
|
|
x
|
|
</button>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
FlashMessage.propTypes = {
|
|
dispatch: PropTypes.func,
|
|
notification: notificationInterface,
|
|
};
|
|
|
|
export default radium(FlashMessage);
|