Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: icon to icons for basicerror componenet #15336

Merged
merged 7 commits into from Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,13 @@ 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