You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.3 KiB
86 lines
2.3 KiB
4 years ago
|
import React from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import classnames from 'classnames';
|
||
4 years ago
|
import InfoTooltip from '../../../components/ui/info-tooltip';
|
||
|
|
||
|
const CLASSNAME_WARNING = 'actionable-message--warning';
|
||
|
const CLASSNAME_DANGER = 'actionable-message--danger';
|
||
|
const CLASSNAME_WITH_RIGHT_BUTTON = 'actionable-message--with-right-button';
|
||
|
|
||
|
const typeHash = {
|
||
|
warning: CLASSNAME_WARNING,
|
||
|
danger: CLASSNAME_DANGER,
|
||
|
};
|
||
4 years ago
|
|
||
4 years ago
|
export default function ActionableMessage({
|
||
4 years ago
|
message = '',
|
||
4 years ago
|
primaryAction = null,
|
||
|
secondaryAction = null,
|
||
4 years ago
|
className = '',
|
||
4 years ago
|
infoTooltipText = '',
|
||
|
withRightButton = false,
|
||
|
type = false,
|
||
4 years ago
|
}) {
|
||
4 years ago
|
const actionableMessageClassName = classnames(
|
||
|
'actionable-message',
|
||
|
typeHash[type],
|
||
|
withRightButton ? CLASSNAME_WITH_RIGHT_BUTTON : null,
|
||
|
className,
|
||
|
);
|
||
|
|
||
4 years ago
|
return (
|
||
4 years ago
|
<div className={actionableMessageClassName}>
|
||
|
{infoTooltipText && (
|
||
|
<InfoTooltip
|
||
|
position="left"
|
||
|
contentText={infoTooltipText}
|
||
|
wrapperClassName="actionable-message__info-tooltip-wrapper"
|
||
|
/>
|
||
|
)}
|
||
4 years ago
|
<div className="actionable-message__message">{message}</div>
|
||
4 years ago
|
{(primaryAction || secondaryAction) && (
|
||
|
<div className="actionable-message__actions">
|
||
|
{primaryAction && (
|
||
4 years ago
|
<button
|
||
4 years ago
|
className={classnames(
|
||
|
'actionable-message__action',
|
||
|
'actionable-message__action--primary',
|
||
|
)}
|
||
4 years ago
|
onClick={primaryAction.onClick}
|
||
|
>
|
||
|
{primaryAction.label}
|
||
4 years ago
|
</button>
|
||
4 years ago
|
)}
|
||
|
{secondaryAction && (
|
||
4 years ago
|
<button
|
||
4 years ago
|
className={classnames(
|
||
|
'actionable-message__action',
|
||
|
'actionable-message__action--secondary',
|
||
|
)}
|
||
4 years ago
|
onClick={secondaryAction.onClick}
|
||
|
>
|
||
|
{secondaryAction.label}
|
||
4 years ago
|
</button>
|
||
4 years ago
|
)}
|
||
|
</div>
|
||
|
)}
|
||
4 years ago
|
</div>
|
||
4 years ago
|
);
|
||
4 years ago
|
}
|
||
|
|
||
|
ActionableMessage.propTypes = {
|
||
4 years ago
|
message: PropTypes.node.isRequired,
|
||
4 years ago
|
primaryAction: PropTypes.shape({
|
||
|
label: PropTypes.string,
|
||
|
onClick: PropTypes.func,
|
||
|
}),
|
||
|
secondaryAction: PropTypes.shape({
|
||
4 years ago
|
label: PropTypes.string,
|
||
|
onClick: PropTypes.func,
|
||
|
}),
|
||
|
className: PropTypes.string,
|
||
4 years ago
|
type: PropTypes.string,
|
||
4 years ago
|
withRightButton: PropTypes.bool,
|
||
4 years ago
|
infoTooltipText: PropTypes.string,
|
||
4 years ago
|
};
|