Skip to content

Commit

Permalink
add: new UI error
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-mng authored and bjoernricks committed Jun 18, 2024
1 parent eebf2a3 commit d08e8f5
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 217 deletions.

This file was deleted.

155 changes: 0 additions & 155 deletions src/web/components/error/__tests__/__snapshots__/errormessage.jsx.snap

This file was deleted.

2 changes: 1 addition & 1 deletion src/web/components/error/__tests__/errorcontainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ describe('ErrorContainer tests', () => {
</ErrorContainer>,
);

expect(element).toMatchSnapshot();
expect(element).toBeVisible();
});
});
2 changes: 1 addition & 1 deletion src/web/components/error/__tests__/errormessage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('ErrorMessage tests', () => {
<ErrorMessage message="An error occurred." details="Because of foo." />,
);

expect(element).toMatchSnapshot();
expect(element).toBeVisible();
});

test('should render with message, details and children', () => {
Expand Down
3 changes: 0 additions & 3 deletions src/web/components/error/errorcontainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ const ErrorContainer = styled(Layout)`
padding: 15px;
margin: 15px 15px 15px 15px;
border: 1px solid ${Theme.mediumLightRed};
color: ${Theme.darkRed};
background-color: ${Theme.lightRed};
`;

export default ErrorContainer;

// vim: set ts=2 sw=2 tw=80:
17 changes: 10 additions & 7 deletions src/web/components/error/errormessage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {isDefined} from 'gmp/utils/identity';
import Divider from 'web/components/layout/divider';
import Layout from 'web/components/layout/layout';

import StNonAvailableIcon from 'web/components/icon/stnonavailableicon';
import {AlertCircle} from 'lucide-react';
import Theme from 'web/utils/theme';

import PropTypes from 'web/utils/proptypes';

Expand All @@ -36,13 +37,15 @@ const ErrorMessage = ({
...props
}) => (
<ErrorContainer data-testid={dataTestId}>
<Divider margin="15px" align={['start', 'start']}>
<StNonAvailableIcon size="medium" />
<Layout {...props}>
<Divider>
<b data-testid="error-message">{message}</b>
<Divider margin="20px" flex="column" align={['center', 'center']} grow>
<AlertCircle size="24" color={Theme.darkRed} />
<Layout flex="column" align={['center', 'center']} {...props}>
<b data-testid="error-message">{message}</b>
<Divider margin="20px" flex="row" align={['center', 'start']} grow>
{isDefined(details) && (
<span data-testid="error-details">{details}</span>
<div>
<span data-testid="error-details">{details}</span>
</div>
)}
</Divider>
{children}
Expand Down
16 changes: 6 additions & 10 deletions src/web/components/error/errorpanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ import PropTypes from 'web/utils/proptypes';
import Theme from 'web/utils/theme';

import ErrorMessage from './errormessage';

const ErrorDetailsToggle = styled.span`
margin-top: 10px;
cursor: pointer;
:hover {
text-decoration: underline;
}
`;
import {Button as OpenSightButton} from '@greenbone/opensight-ui-components';

const ErrorDetails = styled.div`
margin-top: 10px;
Expand All @@ -61,12 +54,15 @@ const ErrorPanel = ({error, message, info}) => {
flex="column"
>
{isDefined(error) && (
<ErrorDetailsToggle
<OpenSightButton
variant="outline"
color="red"
size="sm"
data-testid="errorpanel-toggle"
onClick={handleToggleDetails}
>
{showDetails ? _('Hide Error Details') : _('Show Error Details')}
</ErrorDetailsToggle>
</OpenSightButton>
)}
{showDetails && (
<ErrorDetails>
Expand Down
4 changes: 1 addition & 3 deletions src/web/utils/theme.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Theme = {
loginButtonGray: '#4c4c4d', // used by: login button
loginButtonHover: '#212121', // used by: login button at hover

lightRed: '#fbddde', // used by: dialog errors background
lightRed: '#fdf2f2', // used by: dialog errors background
mediumLightRed: '#f4b1b2', // used by: dialog errors border
warningRed: '#e5393d', // used for warning font color at login dialog
darkRed: '#c12c30', // used by: dialog errors font
Expand Down Expand Up @@ -73,5 +73,3 @@ const Theme = {
};

export default Theme;

// vim: set ts=2 sw=2 tw=80:

0 comments on commit d08e8f5

Please sign in to comment.