keycloak-scim/src/components/alert/AlertPanel.tsx

42 lines
862 B
TypeScript
Raw Normal View History

import React from "react";
2020-08-07 13:44:34 +00:00
import {
AlertGroup,
Alert,
AlertActionCloseButton,
AlertVariant,
} from "@patternfly/react-core";
2020-08-07 13:44:34 +00:00
export type AlertType = {
key: number;
message: string;
variant: AlertVariant;
};
type AlertPanelProps = {
alerts: AlertType[];
onCloseAlert: (key: number) => void;
};
export function AlertPanel({ alerts, onCloseAlert }: AlertPanelProps) {
return (
<AlertGroup isToast>
{alerts.map(({ key, variant, message }) => (
<Alert
key={key}
2020-08-07 13:44:34 +00:00
isLiveRegion
timeout={true}
2020-08-07 13:44:34 +00:00
variant={AlertVariant[variant]}
variantLabel=""
2020-08-07 13:44:34 +00:00
title={message}
actionClose={
<AlertActionCloseButton
title={message}
onClose={() => onCloseAlert(key)}
/>
}
/>
))}
</AlertGroup>
);
}