The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
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.
 
 
 
 
 
 
grafana/public/app/core/components/AppNotifications/AppNotificationItem.tsx

35 lines
964 B

import React, { Component } from 'react';
import { AppNotification } from 'app/types';
import { Alert } from '@grafana/ui';
interface Props {
appNotification: AppNotification;
onClearNotification: (id: string) => void;
}
export default class AppNotificationItem extends Component<Props> {
shouldComponentUpdate(nextProps: Props) {
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;
return (
<Alert
severity={appNotification.severity}
title={appNotification.title}
onRemove={() => onClearNotification(appNotification.id)}
>
{appNotification.component || appNotification.text}
</Alert>
);
}
}