keycloak-scim/apps/admin-ui/src/components/alert/AlertPanel.tsx

41 lines
925 B
TypeScript
Raw Normal View History

2020-08-07 13:44:34 +00:00
import {
AlertGroup,
Alert,
AlertActionCloseButton,
AlertVariant,
} from "@patternfly/react-core";
import type { AlertEntry } from "./Alerts";
2020-08-07 13:44:34 +00:00
type AlertPanelProps = {
alerts: AlertEntry[];
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
data-testid="global-alerts"
isToast
style={{ whiteSpace: "pre-wrap" }}
>
2022-07-13 10:17:21 +00:00
{alerts.map(({ id, variant, message, description }) => (
<Alert
2022-07-13 10:17:21 +00:00
key={id}
isLiveRegion
variant={AlertVariant[variant]}
variantLabel=""
title={message}
actionClose={
<AlertActionCloseButton
title={message}
2022-07-13 10:17:21 +00:00
onClose={() => onCloseAlert(id)}
/>
}
>
{description && <p>{description}</p>}
</Alert>
2020-08-07 13:44:34 +00:00
))}
</AlertGroup>
);
}