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-10-27 12:00:02 +00:00
|
|
|
import type { AlertEntry } from "./Alerts";
|
2020-08-07 13:44:34 +00:00
|
|
|
|
|
|
|
type AlertPanelProps = {
|
2022-10-27 12:00:02 +00:00
|
|
|
alerts: AlertEntry[];
|
2023-03-03 12:57:58 +00:00
|
|
|
onCloseAlert: (id: number) => void;
|
2020-08-07 13:44:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export function AlertPanel({ alerts, onCloseAlert }: AlertPanelProps) {
|
|
|
|
return (
|
2023-01-18 11:11:34 +00:00
|
|
|
<AlertGroup
|
|
|
|
data-testid="global-alerts"
|
|
|
|
isToast
|
|
|
|
style={{ whiteSpace: "pre-wrap" }}
|
|
|
|
>
|
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
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{description && <p>{description}</p>}
|
|
|
|
</Alert>
|
2020-08-07 13:44:34 +00:00
|
|
|
))}
|
|
|
|
</AlertGroup>
|
|
|
|
);
|
|
|
|
}
|