Skip to content

Commit

Permalink
fix: error alert levels again (#17027)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Ritter committed Oct 11, 2021
1 parent 83a783d commit 153469d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ interface BasicErrorAlertProps {

export default function BasicErrorAlert({
body,
level,
level = 'error',
title,
}: BasicErrorAlertProps) {
const theme = useTheme();
const iconColor = theme.colors[level].base;

return (
<StyledContainer level={level} role="alert">
{!level || level === 'error' ? (
<Icons.ErrorSolid iconColor={theme.colors.error.base} />
{level === 'error' ? (
<Icons.ErrorSolid iconColor={iconColor} />
) : (
<Icons.WarningSolid iconColor={theme.colors[level].base} />
<Icons.WarningSolid iconColor={iconColor} />
)}
<StyledContent>
<StyledTitle>{title}</StyledTitle>
Expand Down
27 changes: 8 additions & 19 deletions superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ interface ErrorAlertProps {
export default function ErrorAlert({
body,
copyText,
level,
level = 'error',
source = 'dashboard',
subtitle,
title,
Expand All @@ -103,21 +103,16 @@ export default function ErrorAlert({
const [isBodyExpanded, setIsBodyExpanded] = useState(false);

const isExpandable = ['explore', 'sqllab'].includes(source);
const iconColor = theme.colors[level].base;

return (
<ErrorAlertDiv level={level} role="alert">
<div className="top-row">
<LeftSideContent>
{!level || level === 'error' ? (
<Icons.ErrorSolid
className="icon"
iconColor={theme.colors.error.base}
/>
{level === 'error' ? (
<Icons.ErrorSolid className="icon" iconColor={iconColor} />
) : (
<Icons.WarningSolid
className="icon"
iconColor={theme.colors[level].base}
/>
<Icons.WarningSolid className="icon" iconColor={iconColor} />
)}
<strong>{title}</strong>
</LeftSideContent>
Expand Down Expand Up @@ -171,16 +166,10 @@ export default function ErrorAlert({
onHide={() => setIsModalOpen(false)}
title={
<div className="header">
{!level || level === 'error' ? (
<Icons.ErrorSolid
className="icon"
iconColor={theme.colors.error.base}
/>
{level === 'error' ? (
<Icons.ErrorSolid className="icon" iconColor={iconColor} />
) : (
<Icons.WarningSolid
className="icon"
iconColor={theme.colors[level].base}
/>
<Icons.WarningSolid className="icon" iconColor={iconColor} />
)}
<div className="title">{title}</div>
</div>
Expand Down

0 comments on commit 153469d

Please sign in to comment.