Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 59x 59x 59x 139x 127x 139x 417x | import { Alert as MuiAlert, AlertProps as MuiAlertProps, styled } from "@mui/material";
import { grpcErrorStrings, ObscureGrpcErrorMessages } from "appConstants";
import React, { ReactNode } from "react";
const StyledAlert = styled(MuiAlert)(({ theme }) => ({
marginBottom: theme.spacing(2),
}));
interface AlertProps extends MuiAlertProps {
severity: MuiAlertProps["severity"];
children: string | ReactNode;
}
export default function Alert({ className, children, ...otherProps }: AlertProps) {
const oldErrorKey = Object.keys(grpcErrorStrings).find(
(oldError): oldError is ObscureGrpcErrorMessages => typeof children === "string" && children.includes(oldError),
);
return (
<StyledAlert {...otherProps} className={className}>
{
// Search for the error in the ugly grpc error object keys
// Replace it with the nice error if found
oldErrorKey ? grpcErrorStrings[oldErrorKey] : children
}
</StyledAlert>
);
}
|