mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Eslint: allign with latest grafana-eslint-config * fix ts * Fix react/jsx-key * Fix react/no-children-prop * Fix react/jsx-no-target-blank
36 lines
964 B
TypeScript
36 lines
964 B
TypeScript
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>
|
|
);
|
|
}
|
|
}
|