2021-05-06 04:56:03 +05:30
|
|
|
import { Icon, Link, Stack, Text } from "@fluentui/react";
|
2021-04-30 10:23:34 -07:00
|
|
|
import React from "react";
|
2021-05-27 16:07:07 -05:00
|
|
|
import { useNotificationConsole } from "../../hooks/useNotificationConsole";
|
2021-03-18 18:06:13 -07:00
|
|
|
|
|
|
|
export interface PanelInfoErrorProps {
|
|
|
|
message: string;
|
|
|
|
messageType: string;
|
|
|
|
showErrorDetails: boolean;
|
|
|
|
link?: string;
|
|
|
|
linkText?: string;
|
2021-05-19 08:27:31 +05:30
|
|
|
formError?: boolean;
|
2021-03-18 18:06:13 -07:00
|
|
|
}
|
|
|
|
|
2021-05-10 05:52:44 +05:30
|
|
|
export const PanelInfoErrorComponent: React.FunctionComponent<PanelInfoErrorProps> = ({
|
|
|
|
message,
|
|
|
|
messageType,
|
|
|
|
showErrorDetails,
|
|
|
|
link,
|
|
|
|
linkText,
|
|
|
|
}: PanelInfoErrorProps): JSX.Element => {
|
2021-05-27 16:07:07 -05:00
|
|
|
const expandConsole = useNotificationConsole((state) => state.expandConsole);
|
|
|
|
|
2021-05-13 06:26:48 +05:30
|
|
|
let icon: JSX.Element = <Icon iconName="InfoSolid" className="panelLargeInfoIcon" aria-label="Infomation" />;
|
2021-05-10 05:52:44 +05:30
|
|
|
if (messageType === "error") {
|
2021-05-11 00:32:14 +05:30
|
|
|
icon = <Icon iconName="StatusErrorFull" className="panelErrorIcon" aria-label="error" />;
|
2021-05-10 05:52:44 +05:30
|
|
|
} else if (messageType === "warning") {
|
2021-05-11 00:32:14 +05:30
|
|
|
icon = <Icon iconName="WarningSolid" className="panelWarningIcon" aria-label="warning" />;
|
2021-05-10 05:52:44 +05:30
|
|
|
} else if (messageType === "info") {
|
2021-05-11 00:32:14 +05:30
|
|
|
icon = <Icon iconName="InfoSolid" className="panelLargeInfoIcon" aria-label="Infomation" />;
|
2021-03-18 18:06:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-05-12 17:12:03 -07:00
|
|
|
<Stack className="panelInfoErrorContainer" horizontal verticalAlign="center">
|
|
|
|
{icon}
|
2023-10-23 18:04:59 +05:30
|
|
|
<span className="panelWarningErrorDetailsLinkContainer" role="alert" aria-live="assertive">
|
|
|
|
<Text aria-label={message} className="panelWarningErrorMessage" variant="small">
|
2021-05-12 17:12:03 -07:00
|
|
|
{message}
|
|
|
|
{link && linkText && (
|
|
|
|
<Link target="_blank" href={link}>
|
2021-05-24 13:42:54 -07:00
|
|
|
{" " + linkText}
|
2021-05-12 17:12:03 -07:00
|
|
|
</Link>
|
2021-03-18 18:06:13 -07:00
|
|
|
)}
|
2021-05-12 17:12:03 -07:00
|
|
|
</Text>
|
|
|
|
{showErrorDetails && (
|
2023-04-25 21:04:12 +05:30
|
|
|
<a className="paneErrorLink" role="button" onClick={expandConsole} tabIndex={0} onKeyPress={expandConsole}>
|
2021-05-12 17:12:03 -07:00
|
|
|
More details
|
|
|
|
</a>
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
</Stack>
|
2021-03-18 18:06:13 -07:00
|
|
|
);
|
|
|
|
};
|