2018-10-24 07:33:53 -05:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { AppNotification } from 'app/types';
|
2019-09-20 06:41:00 -05:00
|
|
|
import { Alert } from '@grafana/ui';
|
2018-10-24 07:33:53 -05:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
appNotification: AppNotification;
|
2019-05-12 07:15:23 -05:00
|
|
|
onClearNotification: (id: number) => void;
|
2018-10-24 07:33:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class AppNotificationItem extends Component<Props> {
|
2019-05-12 07:15:23 -05:00
|
|
|
shouldComponentUpdate(nextProps: Props) {
|
2018-10-24 07:33:53 -05:00
|
|
|
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 03:04:25 -06:00
|
|
|
|
2018-10-24 07:33:53 -05:00
|
|
|
return (
|
2019-09-20 06:41:00 -05:00
|
|
|
<Alert
|
2019-02-06 12:42:04 -06:00
|
|
|
severity={appNotification.severity}
|
|
|
|
title={appNotification.title}
|
2019-11-14 03:59:41 -06:00
|
|
|
children={appNotification.component || appNotification.text}
|
2019-09-20 06:41:00 -05:00
|
|
|
onRemove={() => onClearNotification(appNotification.id)}
|
2019-02-06 12:42:04 -06:00
|
|
|
/>
|
2018-10-24 07:33:53 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|