From c83f4ae961df267f2e02da52d4e9ee6700abb938 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelsalam Date: Wed, 12 Jun 2024 10:30:53 +0200 Subject: [PATCH] Use useTranslation hook. --- .../components/bar/compliancestatusbar.jsx | 3 +- src/web/components/label/compliancestate.jsx | 31 +++++++++++++------ .../powerfilter/compliancelevelsgroup.jsx | 4 ++- .../pages/reports/auditdeltadetailspage.jsx | 5 +-- src/web/pages/reports/auditdetailscontent.jsx | 3 +- src/web/pages/reports/auditdetailspage.jsx | 5 ++- src/web/pages/reports/auditreportrow.jsx | 3 +- .../pages/reports/auditreportslistpage.jsx | 10 ++++-- .../reports/details/auditthresholdpanel.jsx | 4 ++- 9 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/web/components/bar/compliancestatusbar.jsx b/src/web/components/bar/compliancestatusbar.jsx index a3fbe98afe..16917b57f2 100644 --- a/src/web/components/bar/compliancestatusbar.jsx +++ b/src/web/components/bar/compliancestatusbar.jsx @@ -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'; @@ -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; diff --git a/src/web/components/label/compliancestate.jsx b/src/web/components/label/compliancestate.jsx index 392211c375..a0133320d0 100644 --- a/src/web/components/label/compliancestate.jsx +++ b/src/web/components/label/compliancestate.jsx @@ -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'; @@ -26,7 +26,10 @@ const Label = styledExcludeProps(styled.div, [ border-color: ${props => props.borderColor}; `; -const YesLabel = props => ( + +const YesLabel = props => { + const [_] = useTranslation(); + return ( -); + ) +}; -const NoLabel = props => ( +const NoLabel = props => { + const [_] = useTranslation(); + return ( -); + ) +}; -const IncompleteLabel = props => ( +const IncompleteLabel = props => { + const [_] = useTranslation(); + return ( -); + ) +}; -const UndefinedLabel = props => ( +const UndefinedLabel = props => { + const [_] = useTranslation(); + return ( -); + ) +}; export const ComplianceStateLabels = { Yes: YesLabel, diff --git a/src/web/components/powerfilter/compliancelevelsgroup.jsx b/src/web/components/powerfilter/compliancelevelsgroup.jsx index 09e6612bae..b7c0044379 100644 --- a/src/web/components/powerfilter/compliancelevelsgroup.jsx +++ b/src/web/components/powerfilter/compliancelevelsgroup.jsx @@ -6,7 +6,7 @@ import React from 'react'; -import _ from 'gmp/locale'; +import useTranslation from 'web/hooks/useTranslation'; import {isDefined} from 'gmp/utils/identity'; @@ -25,6 +25,8 @@ const ComplianceLevelsFilterGroup = ({ onRemove, isResult = false, }) => { + const [_] = useTranslation(); + const handleComplianceChange = (value, level) => { const filter_name = isResult ? 'compliance_levels' diff --git a/src/web/pages/reports/auditdeltadetailspage.jsx b/src/web/pages/reports/auditdeltadetailspage.jsx index 430f2c66e7..67f90d4029 100644 --- a/src/web/pages/reports/auditdeltadetailspage.jsx +++ b/src/web/pages/reports/auditdeltadetailspage.jsx @@ -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'; @@ -105,7 +105,8 @@ const DeltaAuditReportDetails = props => { sortReverse: false, }, }); - + + const [_] = useTranslation(); const gmp = useGmp(); const dispatch = useDispatch(); const match = useRouteMatch(); diff --git a/src/web/pages/reports/auditdetailscontent.jsx b/src/web/pages/reports/auditdetailscontent.jsx index e3c913508d..7f69f07a9a 100644 --- a/src/web/pages/reports/auditdetailscontent.jsx +++ b/src/web/pages/reports/auditdetailscontent.jsx @@ -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'; @@ -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 = {}, diff --git a/src/web/pages/reports/auditdetailspage.jsx b/src/web/pages/reports/auditdetailspage.jsx index 9ce266202b..088828a4a4 100644 --- a/src/web/pages/reports/auditdetailspage.jsx +++ b/src/web/pages/reports/auditdetailspage.jsx @@ -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'; @@ -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'; @@ -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(); @@ -687,7 +687,6 @@ const ReportDetailsWrapper = props => { }; export default compose( - withGmp, withDialogNotification, withDownload, )(ReportDetailsWrapper); diff --git a/src/web/pages/reports/auditreportrow.jsx b/src/web/pages/reports/auditreportrow.jsx index af8345abd4..52d8e57c47 100644 --- a/src/web/pages/reports/auditreportrow.jsx +++ b/src/web/pages/reports/auditreportrow.jsx @@ -6,7 +6,7 @@ import React from 'react'; -import _ from 'gmp/locale'; +import useTranslation from 'web/hooks/useTranslation'; import {isDefined} from 'gmp/utils/identity'; @@ -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 ( diff --git a/src/web/pages/reports/auditreportslistpage.jsx b/src/web/pages/reports/auditreportslistpage.jsx index 00798ba342..e399e3546a 100644 --- a/src/web/pages/reports/auditreportslistpage.jsx +++ b/src/web/pages/reports/auditreportslistpage.jsx @@ -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'; @@ -47,7 +47,9 @@ import AuditReportsDashboard, { AUDIT_REPORTS_DASHBOARD_ID, } from './auditdashboard'; -const ToolBarIcons = () => ( +const ToolBarIcons = () => { + const [_] = useTranslation(); + return ( ( title={_('Help: Audit Reports')} /> -); + ) +}; const AuditReportsPage = ({ filter, @@ -67,6 +70,7 @@ const AuditReportsPage = ({ const [selectedDeltaReport, setSelectedDeltaReport] = useState(); const [beforeSelectFilter, setBeforeSelectFilter] = useState(); const history = useHistory(); + const [_] = useTranslation(); useEffect(() => { if ( diff --git a/src/web/pages/reports/details/auditthresholdpanel.jsx b/src/web/pages/reports/details/auditthresholdpanel.jsx index 7d2f7e63e3..d9b141a1b7 100644 --- a/src/web/pages/reports/details/auditthresholdpanel.jsx +++ b/src/web/pages/reports/details/auditthresholdpanel.jsx @@ -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'; @@ -36,6 +36,8 @@ const AuditThresholdPanel = ({ onFilterChanged, onFilterEditClick, }) => { + const [_] = useTranslation(); + const compliance = filter.get('compliance_levels', ''); const handleRemoveComplianceYes = () => {