2017-01-26 03:52:17 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
2017-02-17 06:14:10 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2017-01-26 03:52:17 +08:00
|
|
|
import styles from './styles.scss';
|
|
|
|
import cx from 'classnames';
|
|
|
|
import Button from '/imports/ui/components/button/component';
|
|
|
|
|
|
|
|
const COLORS = [
|
|
|
|
'default', 'primary', 'danger', 'success',
|
|
|
|
];
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
color: PropTypes.oneOf(COLORS),
|
|
|
|
message: PropTypes.string,
|
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
color: 'default',
|
|
|
|
};
|
|
|
|
|
2017-02-17 06:14:10 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
closeLabel: {
|
|
|
|
id: 'app.audioNotification.closeLabel',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
class AudioNotification extends Component {
|
2017-01-26 03:52:17 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.handleClose = this.handleClose.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleClose() {
|
|
|
|
this.props.handleClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-02-17 06:14:10 +08:00
|
|
|
const {
|
|
|
|
color,
|
|
|
|
message,
|
|
|
|
intl,
|
|
|
|
} = this.props;
|
2017-01-26 03:52:17 +08:00
|
|
|
|
2017-02-17 06:14:10 +08:00
|
|
|
if (!color || !message ){
|
2017-01-26 03:52:17 +08:00
|
|
|
return null;
|
2017-02-17 06:14:10 +08:00
|
|
|
} else {
|
2017-01-26 03:52:17 +08:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
role="alert"
|
|
|
|
className={cx(styles.audioNotifications, styles[this.props.color])}>
|
|
|
|
{message}
|
|
|
|
<Button className={styles.closeBtn}
|
2017-02-17 06:14:10 +08:00
|
|
|
label={intl.formatMessage(intlMessages.closeLabel)}
|
2017-01-26 03:52:17 +08:00
|
|
|
icon={'close'}
|
|
|
|
size={'sm'}
|
|
|
|
circle={true}
|
|
|
|
hideLabel={true}
|
|
|
|
onClick={this.handleClose}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioNotification.propTypes = propTypes;
|
|
|
|
AudioNotification.defaultProps = defaultProps;
|
2017-02-17 06:14:10 +08:00
|
|
|
|
|
|
|
export default injectIntl(AudioNotification);
|