2020-08-07 13:44:34 +00:00
|
|
|
import {
|
|
|
|
AlertGroup,
|
|
|
|
Alert,
|
|
|
|
AlertActionCloseButton,
|
|
|
|
AlertVariant,
|
2020-08-31 18:26:25 +00:00
|
|
|
} from "@patternfly/react-core";
|
2022-07-13 10:17:21 +00:00
|
|
|
import type { AlertType } from "./Alerts";
|
2020-08-07 13:44:34 +00:00
|
|
|
|
|
|
|
type AlertPanelProps = {
|
|
|
|
alerts: AlertType[];
|
2022-07-13 10:17:21 +00:00
|
|
|
onCloseAlert: (id: number) => void;
|
2020-08-07 13:44:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export function AlertPanel({ alerts, onCloseAlert }: AlertPanelProps) {
|
|
|
|
return (
|
|
|
|
<AlertGroup isToast>
|
2022-07-13 10:17:21 +00:00
|
|
|
{alerts.map(({ id, variant, message, description }) => (
|
2021-03-09 13:59:41 +00:00
|
|
|
<Alert
|
2022-07-13 10:17:21 +00:00
|
|
|
key={id}
|
2021-03-09 13:59:41 +00:00
|
|
|
isLiveRegion
|
|
|
|
variant={AlertVariant[variant]}
|
|
|
|
variantLabel=""
|
|
|
|
title={message}
|
|
|
|
actionClose={
|
|
|
|
<AlertActionCloseButton
|
|
|
|
title={message}
|
2022-07-13 10:17:21 +00:00
|
|
|
onClose={() => onCloseAlert(id)}
|
2021-03-09 13:59:41 +00:00
|
|
|
/>
|
|
|
|
}
|
2022-07-13 10:17:21 +00:00
|
|
|
timeout
|
|
|
|
onTimeout={() => onCloseAlert(id)}
|
2021-03-09 13:59:41 +00:00
|
|
|
>
|
|
|
|
{description && <p>{description}</p>}
|
|
|
|
</Alert>
|
2020-08-07 13:44:34 +00:00
|
|
|
))}
|
|
|
|
</AlertGroup>
|
|
|
|
);
|
|
|
|
}
|