Skip to content

Commit

Permalink
refactor: icon to icons for basicerror componenet (apache#15336)
Browse files Browse the repository at this point in the history
* initial commit

* initial commit

* fix test

* lint fix

* Update superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx

Co-authored-by: David Aaron Suddjian <1858430+suddjian@users.noreply.github.com>

* lint

Co-authored-by: David Aaron Suddjian <1858430+suddjian@users.noreply.github.com>
  • Loading branch information
2 people authored and cccs-RyanS committed Dec 17, 2021
1 parent 4a7a31e commit c8bf279
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
Expand Up @@ -43,11 +43,9 @@ test('should render', () => {

test('should render warning icon', () => {
render(<BasicErrorAlert {...mockedProps} />);
expect(screen.getByTestId('icon')).toBeInTheDocument();
expect(screen.getByTestId('icon')).toHaveAttribute(
'data-name',
'warning-solid',
);
expect(
screen.getByRole('img', { name: 'warning-solid' }),
).toBeInTheDocument();
});

test('should render error icon', () => {
Expand All @@ -56,11 +54,7 @@ test('should render error icon', () => {
level: 'error' as ErrorLevel,
};
render(<BasicErrorAlert {...errorProps} />);
expect(screen.getByTestId('icon')).toBeInTheDocument();
expect(screen.getByTestId('icon')).toHaveAttribute(
'data-name',
'error-solid',
);
expect(screen.getByRole('img', { name: 'error-solid' })).toBeInTheDocument();
});

test('should render the error title', () => {
Expand Down
Expand Up @@ -18,7 +18,7 @@
*/
import React from 'react';
import { styled, supersetTheme } from '@superset-ui/core';
import Icon from '../Icon';
import Icons from 'src/components/Icons';
import { ErrorLevel } from './types';

const StyledContainer = styled.div<{ level: ErrorLevel }>`
Expand Down Expand Up @@ -56,10 +56,11 @@ export default function BasicErrorAlert({
}: BasicErrorAlertProps) {
return (
<StyledContainer level={level} role="alert">
<Icon
name={level === 'error' ? 'error-solid' : 'warning-solid'}
color={supersetTheme.colors[level].base}
/>
{level === 'error' ? (
<Icons.ErrorSolid iconColor={supersetTheme.colors[level].base} />
) : (
<Icons.WarningSolid iconColor={supersetTheme.colors[level].base} />
)}
<StyledContent>
<StyledTitle>{title}</StyledTitle>
<p>{body}</p>
Expand Down

0 comments on commit c8bf279

Please sign in to comment.