Files
grafana/public/app/core/components/AppNotifications/AppNotificationItem.tsx

36 lines
961 B
TypeScript
Raw Normal View History

2018-10-24 14:33:53 +02:00
import React, { Component } from 'react';
import { AppNotification } from 'app/types';
import { AlertBox } from '../AlertBox/AlertBox';
2018-10-24 14:33:53 +02:00
interface Props {
appNotification: AppNotification;
onClearNotification: (id) => void;
}
export default class AppNotificationItem extends Component<Props> {
shouldComponentUpdate(nextProps) {
return this.props.appNotification.id !== nextProps.appNotification.id;
}
componentDidMount() {
const { appNotification, onClearNotification } = this.props;
setTimeout(() => {
onClearNotification(appNotification.id);
}, appNotification.timeout);
}
render() {
const { appNotification, onClearNotification } = this.props;
2018-12-15 10:04:25 +01:00
2018-10-24 14:33:53 +02:00
return (
<AlertBox
severity={appNotification.severity}
title={appNotification.title}
text={appNotification.text}
icon={appNotification.icon}
onClose={() => onClearNotification(appNotification.id)}
/>
2018-10-24 14:33:53 +02:00
);
}
}