Skip to content

Commit

Permalink
change: ui severity class
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-mng committed Jan 6, 2025
1 parent 235ffe2 commit 8c0e8a1
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 78 deletions.
129 changes: 61 additions & 68 deletions src/web/components/label/severityclass.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,89 +3,82 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import _ from 'gmp/locale';
import React from 'react';
import {useTranslation} from 'react-i18next';
import styled from 'styled-components';

import Theme from 'web/utils/theme';

const Label = styled.div`
text-align: center;
box-sizing: border-box;
position: relative;
font-weight: normal;
font-style: normal;
color: white;
padding: 1px;
display: inline-block;
display: inline-flex;
align-items: center;
justify-content: center;
width: 70px;
height: 1.5em;
font-size: 0.8em;
text-align: center;
color: ${props => props.$textColor};
background-color: ${props => props.$backgroundColor};
border-radius: 5px;
overflow: hidden;
border-color: ${props => props.$borderColor};
`;

const HighLabel = props => {
return (
<Label
{...props}
$backgroundColor="#C83814"
$borderColor="#C83814"
data-testid="severity-class-High"
>
{_('High')}
</Label>
);
};

const MediumLabel = props => {
return (
<Label
{...props}
$backgroundColor="#F0A519"
$borderColor="#F0A519"
data-testid="severity-class-Medium"
>
{_('Medium')}
</Label>
);
};
const createLabel =
(backgroundColor, borderColor, textColor, testId, text) => props => {
const [_] = useTranslation();
return (
<Label
{...props}
$backgroundColor={backgroundColor}
$borderColor={borderColor}
$textColor={textColor}
data-testid={testId}
>
{_(text)}
</Label>
);
};

const LowLabel = props => {
return (
<Label
{...props}
$backgroundColor="#4F91C7"
$borderColor="#4F91C7"
data-testid="severity-class-Low"
>
{_('Low')}
</Label>
);
};

const LogLabel = props => {
return (
<Label
{...props}
$backgroundColor="#191919"
$borderColor="#191919"
data-testid="severity-class-Log"
>
{_('Log')}
</Label>
);
};

const FalsePositiveLabel = props => {
return (
<Label
{...props}
$backgroundColor="#191919"
$borderColor="#191919"
data-testid="severity-class-False-Positive"
>
{_('False Pos.')}
</Label>
);
};
const HighLabel = createLabel(
Theme.errorRed,
Theme.errorRed,
Theme.white,
'severity-class-High',
'High',
);
const MediumLabel = createLabel(
Theme.severityWarnYellow,
Theme.severityWarnYellow,
Theme.black,
'severity-class-Medium',
'Medium',
);
const LowLabel = createLabel(
Theme.severityLowBlue,
Theme.severityLowBlue,
Theme.white,
'severity-class-Low',
'Low',
);
const LogLabel = createLabel(
Theme.mediumGray,
Theme.mediumGray,
Theme.white,
'severity-class-Log',
'Log',
);
const FalsePositiveLabel = createLabel(
Theme.mediumGray,
Theme.mediumGray,
Theme.white,
'severity-class-False-Positive',
'False Pos.',
);

export const SeverityClassLabels = {
High: HighLabel,
Expand Down
11 changes: 1 addition & 10 deletions src/web/pages/scanconfigs/__tests__/editconfigfamilydialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@
import {describe, test, expect, testing} from '@gsa/testing';
import Nvt from 'gmp/models/nvt';
import {
clickElement,
getDialog,
getDialogSaveButton,
getTableBody,
getTableHeader,
} from 'web/components/testing';
import {
rendererWith,
fireEvent,
prettyDOM,
within,
wait,
userEvent,
screen,
} from 'web/utils/testing';
import {rendererWith, fireEvent, within, screen} from 'web/utils/testing';

import EditConfigFamilyDialog from '../editconfigfamilydialog';

Expand Down

0 comments on commit 8c0e8a1

Please sign in to comment.