mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
refactor: icon to icons for basicerror componenet (#15336)
* 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>
This commit is contained in:
parent
680b447bc4
commit
a477505291
@ -43,11 +43,9 @@ test('should render', () => {
|
|||||||
|
|
||||||
test('should render warning icon', () => {
|
test('should render warning icon', () => {
|
||||||
render(<BasicErrorAlert {...mockedProps} />);
|
render(<BasicErrorAlert {...mockedProps} />);
|
||||||
expect(screen.getByTestId('icon')).toBeInTheDocument();
|
expect(
|
||||||
expect(screen.getByTestId('icon')).toHaveAttribute(
|
screen.getByRole('img', { name: 'warning-solid' }),
|
||||||
'data-name',
|
).toBeInTheDocument();
|
||||||
'warning-solid',
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should render error icon', () => {
|
test('should render error icon', () => {
|
||||||
@ -56,11 +54,7 @@ test('should render error icon', () => {
|
|||||||
level: 'error' as ErrorLevel,
|
level: 'error' as ErrorLevel,
|
||||||
};
|
};
|
||||||
render(<BasicErrorAlert {...errorProps} />);
|
render(<BasicErrorAlert {...errorProps} />);
|
||||||
expect(screen.getByTestId('icon')).toBeInTheDocument();
|
expect(screen.getByRole('img', { name: 'error-solid' })).toBeInTheDocument();
|
||||||
expect(screen.getByTestId('icon')).toHaveAttribute(
|
|
||||||
'data-name',
|
|
||||||
'error-solid',
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should render the error title', () => {
|
test('should render the error title', () => {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { styled, supersetTheme } from '@superset-ui/core';
|
import { styled, supersetTheme } from '@superset-ui/core';
|
||||||
import Icon from '../Icon';
|
import Icons from 'src/components/Icons';
|
||||||
import { ErrorLevel } from './types';
|
import { ErrorLevel } from './types';
|
||||||
|
|
||||||
const StyledContainer = styled.div<{ level: ErrorLevel }>`
|
const StyledContainer = styled.div<{ level: ErrorLevel }>`
|
||||||
@ -56,10 +56,11 @@ export default function BasicErrorAlert({
|
|||||||
}: BasicErrorAlertProps) {
|
}: BasicErrorAlertProps) {
|
||||||
return (
|
return (
|
||||||
<StyledContainer level={level} role="alert">
|
<StyledContainer level={level} role="alert">
|
||||||
<Icon
|
{level === 'error' ? (
|
||||||
name={level === 'error' ? 'error-solid' : 'warning-solid'}
|
<Icons.ErrorSolid iconColor={supersetTheme.colors[level].base} />
|
||||||
color={supersetTheme.colors[level].base}
|
) : (
|
||||||
/>
|
<Icons.WarningSolid iconColor={supersetTheme.colors[level].base} />
|
||||||
|
)}
|
||||||
<StyledContent>
|
<StyledContent>
|
||||||
<StyledTitle>{title}</StyledTitle>
|
<StyledTitle>{title}</StyledTitle>
|
||||||
<p>{body}</p>
|
<p>{body}</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user