import React from 'react'; import {IAlertComponentProps} from 'superdesk-api'; import {assertNever} from 'core/helpers/typescript-helpers'; import {Button} from 'superdesk-ui-framework/react'; function getTypeClassName(alertType: IAlertComponentProps['type']) { switch (alertType) { case 'info': return 'sd-alert--primary'; case 'error': return 'sd-alert--alert'; case 'warning': return 'sd-alert--warning'; default: assertNever(alertType); } } function getSizeClassName(alertType: IAlertComponentProps['size']) { switch (alertType) { case 'small': return 'sd-alert--small'; default: assertNever(alertType); } } export class Alert extends React.PureComponent { render() { const classNames = [ 'sd-alert', this.props.hollow ? 'sd-alert--hollow' : '', getTypeClassName(this.props.type), 'alert-extended', 'sd-margin-b--0', 'sd-padding-x--1-5', ]; if (this.props.size != null) { classNames.push(getSizeClassName(this.props.size)); } return (
{ this.props.title != null && ( {this.props.title} ) }

{this.props.message}

{ this.props.actions != null && (
{ this.props.actions.map((action) => (
) }
); } }