diff --git a/src/shell/components/global-notifications/GlobalNotifications.js b/src/shell/components/global-notifications/GlobalNotifications.js index f6fdd277e3..d5473849d6 100644 --- a/src/shell/components/global-notifications/GlobalNotifications.js +++ b/src/shell/components/global-notifications/GlobalNotifications.js @@ -213,55 +213,92 @@ export const CustomNotification = forwardRef(({ id, ...props }, ref) => { closeSnackbar(id); }, [id, closeSnackbar]); - return ( - - - - - - - } - sx={{ - width: 540, - height: props.heading ? "auto" : 44, - }} - > - - - {props.heading ? props.heading : props.message} + const parseStrToBold = (str, isHeading = false) => { + const styles = { + variant: "body2", + fontWeight: 700, + component: "span", + }; + if (str.indexOf(":") !== -1) { + return ( + <> + + {str.substring(0, str.indexOf(":") + 1)} + {str.substring(str.indexOf(":") + 1)} + + ); + } else if (str.indexOf(":") === -1 && isHeading) + return {str}; + else if (str.indexOf(":") === -1 && [undefined, ""].includes(props.heading)) + return {str}; + else return str; + }; - {props.heading && ( + const typograpySX = { + maxWidth: "540px", + overflow: "hidden", + textOverflow: "ellipsis", + // this will only show 1 or 2 lines to prevent exceeding on the expected height + // depending what type of notification will be displayed. + display: props.severity === "success" ? "block" : "-webkit-box", + "-webkit-line-clamp": props.heading && props.message ? "1" : "2", + "-webkit-box-orient": "vertical", + }; + + return ( + + {typeof props.message === "object" ? ( + "" + ) : ( + + + + + + } + sx={{ + width: 540, + padding: + !(props.heading && props.message) || props.severity === "success" + ? "4px 8px" + : "0px 8px", + }} + > + - {props.message} + {props.heading + ? props.heading && parseStrToBold(props.heading, true) + : props.message && parseStrToBold(props.message)} - )} - - + + {props.heading && ( + + {parseStrToBold(props.message)} + + )} + + + )} ); });