chore: refactor Alert-related components (#31858)

This commit is contained in:
Maxime Beauchemin
2025-01-24 08:39:09 -08:00
committed by GitHub
parent 5fe6ef268e
commit 6eb87e04c0
51 changed files with 590 additions and 753 deletions

View File

@@ -32,6 +32,7 @@ type Props = {
stackTrace?: string;
source?: ErrorSource;
description?: string;
descriptionDetails?: ReactNode;
errorMitigationFunction?: () => void;
fallback?: ReactNode;
};
@@ -45,6 +46,7 @@ export default function ErrorMessageWithStackTrace({
stackTrace,
source,
description,
descriptionDetails,
fallback,
}: Props) {
// Check if a custom error message component was registered for this message
@@ -66,28 +68,27 @@ export default function ErrorMessageWithStackTrace({
if (fallback) {
return <>{fallback}</>;
}
const computedDescriptionDetails =
descriptionDetails ||
(link || stackTrace ? (
<>
{link && (
<a href={link} target="_blank" rel="noopener noreferrer">
{t('Request Access')}
</a>
)}
<br />
{stackTrace && <pre>{stackTrace}</pre>}
</>
) : undefined);
return (
<ErrorAlert
level="warning"
title={title}
subtitle={subtitle}
copyText={copyText}
type="error"
errorType={title}
message={subtitle}
description={description}
source={source}
body={
link || stackTrace ? (
<>
{link && (
<a href={link} target="_blank" rel="noopener noreferrer">
(Request Access)
</a>
)}
<br />
{stackTrace && <pre>{stackTrace}</pre>}
</>
) : undefined
}
descriptionDetails={computedDescriptionDetails}
/>
);
}