Skip to content

Commit

Permalink
Use useTranslation hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam committed Jun 12, 2024
1 parent 28e9c0a commit c83f4ae
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/web/components/bar/compliancestatusbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import React from 'react';

import _ from 'gmp/locale';
import useTranslation from 'web/hooks/useTranslation';

import PropTypes from 'web/utils/proptypes';
import Theme from 'web/utils/theme';
Expand All @@ -15,6 +15,7 @@ import ProgressBar from 'web/components/bar/progressbar';
const ComplianceStatusBar = ({complianceStatus}) => {
let text;
let boxBackground;
const [_] = useTranslation();
if (complianceStatus < 0 || complianceStatus > 100) {
text = _('N/A');
boxBackground = Theme.darkGrey;
Expand Down
31 changes: 22 additions & 9 deletions src/web/components/label/compliancestate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import styled from 'styled-components';

import _ from 'gmp/locale';
import useTranslation from 'web/hooks/useTranslation';
import {styledExcludeProps} from 'web/utils/styledConfig';
import Theme from 'web/utils/theme';

Expand All @@ -26,45 +26,58 @@ const Label = styledExcludeProps(styled.div, [
border-color: ${props => props.borderColor};
`;

const YesLabel = props => (

const YesLabel = props => {
const [_] = useTranslation();
return (
<Label
{...props}
backgroundColor={Theme.complianceYes}
borderColor={Theme.complianceYes}
>
{_('Yes')}
</Label>
);
)
};

const NoLabel = props => (
const NoLabel = props => {
const [_] = useTranslation();
return (
<Label
{...props}
backgroundColor={Theme.complianceNo}
borderColor={Theme.complianceNo}
>
{_('No')}
</Label>
);
)
};

const IncompleteLabel = props => (
const IncompleteLabel = props => {
const [_] = useTranslation();
return (
<Label
{...props}
backgroundColor={Theme.complianceIncomplete}
borderColor={Theme.complianceIncomplete}
>
{_('Incomplete')}
</Label>
);
)
};

const UndefinedLabel = props => (
const UndefinedLabel = props => {
const [_] = useTranslation();
return (
<Label
{...props}
backgroundColor={Theme.complianceUndefined}
borderColor={Theme.complianceUndefined}
>
{_('Undefined')}
</Label>
);
)
};

export const ComplianceStateLabels = {
Yes: YesLabel,
Expand Down
4 changes: 3 additions & 1 deletion src/web/components/powerfilter/compliancelevelsgroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';

import _ from 'gmp/locale';
import useTranslation from 'web/hooks/useTranslation';

import {isDefined} from 'gmp/utils/identity';

Expand All @@ -25,6 +25,8 @@ const ComplianceLevelsFilterGroup = ({
onRemove,
isResult = false,
}) => {
const [_] = useTranslation();

const handleComplianceChange = (value, level) => {
const filter_name = isResult
? 'compliance_levels'
Expand Down
5 changes: 3 additions & 2 deletions src/web/pages/reports/auditdeltadetailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {useDispatch, useSelector, shallowEqual} from 'react-redux';

import {useRouteMatch} from 'react-router-dom';

import _ from 'gmp/locale';
import useTranslation from 'web/hooks/useTranslation';

import logger from 'gmp/log';

Expand Down Expand Up @@ -105,7 +105,8 @@ const DeltaAuditReportDetails = props => {
sortReverse: false,
},
});


const [_] = useTranslation();
const gmp = useGmp();
const dispatch = useDispatch();
const match = useRouteMatch();
Expand Down
3 changes: 2 additions & 1 deletion src/web/pages/reports/auditdetailscontent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react';

import styled from 'styled-components';

import _ from 'gmp/locale';
import useTranslation from 'web/hooks/useTranslation';

import {TASK_STATUS} from 'gmp/models/task';

Expand Down Expand Up @@ -106,6 +106,7 @@ const PageContent = ({
const userTags = hasReport ? report.userTags : undefined;
const userTagsCount = isDefined(userTags) ? userTags.length : 0;
const gmp = useGmp();
const [_] = useTranslation();

const {
errors = {},
Expand Down
5 changes: 2 additions & 3 deletions src/web/pages/reports/auditdetailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {useDispatch, useSelector, shallowEqual} from 'react-redux';

import {useRouteMatch} from 'react-router-dom';

import _ from 'gmp/locale';
import useTranslation from 'web/hooks/useTranslation';

import logger from 'gmp/log';

Expand Down Expand Up @@ -65,7 +65,6 @@ import {create_pem_certificate} from 'web/utils/cert';
import compose from 'web/utils/compose';
import {generateFilename} from 'web/utils/render';
import PropTypes from 'web/utils/proptypes';
import withGmp from 'web/utils/withGmp';

import TargetComponent from '../targets/component';
import PageTitle from 'web/components/layout/pagetitle';
Expand Down Expand Up @@ -138,6 +137,7 @@ const ReportDetails = props => {
// eslint-disable-next-line no-unused-vars
const [storeAsDefault, setStoreAsDefault] = useState();

const [_] = useTranslation();
const gmp = useGmp();
const dispatch = useDispatch();
const match = useRouteMatch();
Expand Down Expand Up @@ -687,7 +687,6 @@ const ReportDetailsWrapper = props => {
};

export default compose(
withGmp,
withDialogNotification,
withDownload,
)(ReportDetailsWrapper);
Expand Down
3 changes: 2 additions & 1 deletion src/web/pages/reports/auditreportrow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';

import _ from 'gmp/locale';
import useTranslation from 'web/hooks/useTranslation';

import {isDefined} from 'gmp/utils/identity';

Expand Down Expand Up @@ -39,6 +39,7 @@ const Actions = withEntitiesActions(

const scanActive = isActive(report.scan_run_status);

const [_] = useTranslation();
const title = scanActive ? _('Scan is active') : _('Delete Report');

return (
Expand Down
10 changes: 7 additions & 3 deletions src/web/pages/reports/auditreportslistpage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {useEffect, useState} from 'react';

import {useHistory} from 'react-router-dom';

import _ from 'gmp/locale';
import useTranslation from 'web/hooks/useTranslation';

import Filter, {AUDIT_REPORTS_FILTER_FILTER} from 'gmp/models/filter';

Expand Down Expand Up @@ -47,15 +47,18 @@ import AuditReportsDashboard, {
AUDIT_REPORTS_DASHBOARD_ID,
} from './auditdashboard';

const ToolBarIcons = () => (
const ToolBarIcons = () => {
const [_] = useTranslation();
return (
<IconDivider>
<ManualIcon
page="reports"
anchor="using-and-managing-audit-reports"
title={_('Help: Audit Reports')}
/>
</IconDivider>
);
)
};

const AuditReportsPage = ({
filter,
Expand All @@ -67,6 +70,7 @@ const AuditReportsPage = ({
const [selectedDeltaReport, setSelectedDeltaReport] = useState();
const [beforeSelectFilter, setBeforeSelectFilter] = useState();
const history = useHistory();
const [_] = useTranslation();

useEffect(() => {
if (
Expand Down
4 changes: 3 additions & 1 deletion src/web/pages/reports/details/auditthresholdpanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from 'react';

import styled from 'styled-components';

import _ from 'gmp/locale';
import useTranslation from 'web/hooks/useTranslation';

import Divider from 'web/components/layout/divider';

Expand Down Expand Up @@ -36,6 +36,8 @@ const AuditThresholdPanel = ({
onFilterChanged,
onFilterEditClick,
}) => {
const [_] = useTranslation();

const compliance = filter.get('compliance_levels', '');

const handleRemoveComplianceYes = () => {
Expand Down

0 comments on commit c83f4ae

Please sign in to comment.