Skip to content

Commit

Permalink
Change: Move useGmp hook to hooks directory
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernricks committed Jun 20, 2024
1 parent 25af2e2 commit c4542fd
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 79 deletions.
5 changes: 2 additions & 3 deletions src/web/components/bar/titlebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import React from 'react';

import {connect} from 'react-redux';
Expand All @@ -25,7 +24,7 @@ import {isLoggedIn} from 'web/store/usersettings/selectors';

import PropTypes from 'web/utils/proptypes';
import Theme from 'web/utils/theme';
import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';

const TITLE_BAR_HEIGHT = '42px';

Expand Down Expand Up @@ -90,7 +89,7 @@ const Titlebar = ({loggedIn}) => {
</TitlebarLayout>
</React.Fragment>
);
}
};

Titlebar.propTypes = {
loggedIn: PropTypes.bool.isRequired,
Expand Down
3 changes: 1 addition & 2 deletions src/web/components/img/product.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import React from 'react';

import styled from 'styled-components';
Expand All @@ -12,7 +11,7 @@ import _ from 'gmp/locale';

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

import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';

import Img from './img';

Expand Down
3 changes: 1 addition & 2 deletions src/web/components/link/manuallink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import React from 'react';

import {getLocale} from 'gmp/locale/lang';

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

import PropTypes from 'web/utils/proptypes';
import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';

import BlankLink from './blanklink';

Expand Down
2 changes: 1 addition & 1 deletion src/web/components/link/protocoldoclink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from 'react';

import PropTypes from 'web/utils/proptypes';

import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';

import BlankLink from './blanklink';

Expand Down
2 changes: 1 addition & 1 deletion src/web/components/menu/usermenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Divider from 'web/components/layout/divider';
import Link from 'web/components/link/link';

import Theme from 'web/utils/theme';
import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';
import useUserName from 'web/hooks/useUserName';
import useUserSessionTimeout from 'web/hooks/useUserSessionTimeout';
import useUserTimezone from 'web/hooks/useUserTimezone';
Expand Down
3 changes: 1 addition & 2 deletions src/web/components/provider/licenseprovider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import React, {useEffect, useState} from 'react';

import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';

export const LicenseContext = React.createContext({});

Expand Down
2 changes: 1 addition & 1 deletion src/web/entities/BulkTags.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {apiType, getEntityType, typeName} from 'gmp/utils/entitytype';
import PropTypes from 'web/utils/proptypes';
import SelectionType from 'web/utils/selectiontype';

import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';
import useUserSessionTimeout from 'web/hooks/useUserSessionTimeout';

import TagDialog from 'web/pages/tags/dialog';
Expand Down
2 changes: 1 addition & 1 deletion src/web/entities/useEntitiesReloadInterval.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {useCallback} from 'react';

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

import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';

/**
* Hook to get the reload interval for entities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {describe, test, expect, testing} from '@gsa/testing';

import {rendererWith} from '../testing';
import {rendererWith} from 'web/utils/testing';

import useGmp from '../useGmp';

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/web/hooks/usePageFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {getUserSettingsDefaults} from 'web/store/usersettings/defaults/selectors
import {loadUserSettingsDefaultFilter} from 'web/store/usersettings/defaultfilters/actions';
import {getUserSettingsDefaultFilter} from 'web/store/usersettings/defaultfilters/selectors';

import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';

import useShallowEqualSelector from './useShallowEqualSelector';

Expand Down
5 changes: 2 additions & 3 deletions src/web/pages/cves/details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import React from 'react';

import {_, _l} from 'gmp/locale/lang';
Expand All @@ -25,7 +24,7 @@ import TableData from 'web/components/table/data';
import TableRow from 'web/components/table/row';

import PropTypes from 'web/utils/proptypes';
import useGmp from "web/utils/useGmp";
import useGmp from 'web/hooks/useGmp';

const CVSS_PROPS = {
cvssAccessVector: _l('Access Vector'),
Expand All @@ -45,7 +44,7 @@ const CVSS_PROPS = {
cvssAvailabilityVS: _l('Vulnerable System Availability Impact'),
cvssConfidentialitySS: _l('Subsequent System Confidentiality Impact'),
cvssIntegritySS: _l('Subsequent System Integrity Impact'),
cvssAvailabilitySS: _l('Subsequent System Availability Impact'),
cvssAvailabilitySS: _l('Subsequent System Availability Impact'),
};

const CveDetails = ({entity}) => {
Expand Down
20 changes: 9 additions & 11 deletions src/web/pages/cves/row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import React from 'react';

import {_} from 'gmp/locale/lang';
Expand All @@ -25,8 +24,8 @@ import EntitiesActions from 'web/entities/actions';
import {RowDetailsToggle} from 'web/entities/row';

import PropTypes from 'web/utils/proptypes';
import {isNumber} from "gmp/utils/identity";
import useGmp from "web/utils/useGmp";
import {isNumber} from 'gmp/utils/identity';
import useGmp from 'web/hooks/useGmp';

const Row = ({
actionsComponent: ActionsComponent = EntitiesActions,
Expand All @@ -36,8 +35,8 @@ const Row = ({
...props
}) => {
const gmp = useGmp();
const epssScore = entity?.epss?.score
const epssPercentile = entity?.epss?.percentile
const epssScore = entity?.epss?.score;
const epssPercentile = entity?.epss?.percentile;
return (
<TableRow>
<TableData>
Expand All @@ -60,20 +59,19 @@ const Row = ({
<TableData>
<SeverityBar severity={entity.severity} />
</TableData>
{
gmp.settings.enableEPSS &&
{gmp.settings.enableEPSS && (
<>
<TableData>
{isNumber(epssScore) ? epssScore.toFixed(5) : _("N/A")}
{isNumber(epssScore) ? epssScore.toFixed(5) : _('N/A')}
</TableData>
<TableData>
{isNumber(epssPercentile) ? epssPercentile.toFixed(5) : _("N/A")}
{isNumber(epssPercentile) ? epssPercentile.toFixed(5) : _('N/A')}
</TableData>
</>
}
)}
<ActionsComponent {...props} entity={entity} />
</TableRow>
)
);
};

Row.propTypes = {
Expand Down
17 changes: 7 additions & 10 deletions src/web/pages/cves/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import TableRow from 'web/components/table/row';

import CveDetails from './details';
import CveRow from './row';
import {isDefined} from "gmp/utils/identity.js";
import useGmp from "web/utils/useGmp";
import {isDefined} from 'gmp/utils/identity.js';
import useGmp from 'web/hooks/useGmp';

const Header = ({
actionsColumn,
Expand Down Expand Up @@ -80,11 +80,9 @@ const Header = ({
onSortChange={onSortChange}
title={_('Severity')}
/>
{gmp.settings.enableEPSS &&
<TableHead colSpan="2">
{_("EPSS")}
</TableHead>
}
{gmp.settings.enableEPSS && (
<TableHead colSpan="2">{_('EPSS')}</TableHead>
)}
{isDefined(actionsColumn) ? (
actionsColumn
) : (
Expand All @@ -93,8 +91,7 @@ const Header = ({
</TableHead>
)}
</TableRow>
{
gmp.settings.enableEPSS &&
{gmp.settings.enableEPSS && (
<TableRow>
<TableHead
width="5%"
Expand All @@ -113,7 +110,7 @@ const Header = ({
title={_('Percentile')}
/>
</TableRow>
}
)}
</TableHeader>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/web/pages/extras/feedstatuspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import Reload, {
USE_DEFAULT_RELOAD_INTERVAL_ACTIVE,
} from 'web/components/loading/reload';

import useGmp from 'web/utils/useGmp';
import useGmp from 'web/hooks/useGmp';
import PropTypes from 'web/utils/proptypes';

const ToolBarIcons = () => (
Expand Down
38 changes: 24 additions & 14 deletions src/web/pages/nvts/details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {isDefined, isNumber} from 'gmp/utils/identity';
import {TAG_NA} from 'gmp/models/nvt';

import PropTypes from 'web/utils/proptypes';
import useGmp from "web/utils/useGmp";
import useGmp from 'web/hooks/useGmp';

import {na, getTranslatableSeverityOrigin} from 'web/utils/render';

Expand All @@ -33,7 +33,7 @@ import TableRow from 'web/components/table/row';
import References from './references';
import Solution from './solution';
import Pre from './preformatted';
import CveLink from "web/components/link/cvelink";
import CveLink from 'web/components/link/cvelink';

const NvtDetails = ({entity, links = true}) => {
const {
Expand Down Expand Up @@ -99,7 +99,7 @@ const NvtDetails = ({entity, links = true}) => {
)}
</TableData>
</TableRow>
{ gmp.settings.enableEPSS && isDefined(epss?.max_severity) &&
{gmp.settings.enableEPSS && isDefined(epss?.max_severity) && (
<>
<TableData colSpan="2">
<b>{_('EPSS (CVE with highest severity)')}</b>
Expand All @@ -108,14 +108,16 @@ const NvtDetails = ({entity, links = true}) => {
<TableData>{_('EPSS Score')}</TableData>
<TableData>
{isNumber(epss?.max_severity?.score)
? epss?.max_severity?.score.toFixed(5) : _("N/A")}
? epss?.max_severity?.score.toFixed(5)
: _('N/A')}
</TableData>
</TableRow>
<TableRow>
<TableData>{_('EPSS Percentile')}</TableData>
<TableData>
{isNumber(epss?.max_severity?.percentile)
? epss?.max_severity?.percentile.toFixed(5) : _("N/A")}
? epss?.max_severity?.percentile.toFixed(5)
: _('N/A')}
</TableData>
</TableRow>
<TableRow>
Expand All @@ -129,13 +131,16 @@ const NvtDetails = ({entity, links = true}) => {
<TableRow>
<TableData>{_('CVE Severity')}</TableData>
<Severitybar
severity={isDefined(epss?.max_severity?.cve?.severity)
? epss?.max_severity?.cve?.severity : _("N/A")}
severity={
isDefined(epss?.max_severity?.cve?.severity)
? epss?.max_severity?.cve?.severity
: _('N/A')
}
/>
</TableRow>
</>
}
{ gmp.settings.enableEPSS && isDefined(epss?.max_epss) &&
)}
{gmp.settings.enableEPSS && isDefined(epss?.max_epss) && (
<>
<TableData colSpan="2">
<b>{_('EPSS (highest EPSS score)')}</b>
Expand All @@ -144,14 +149,16 @@ const NvtDetails = ({entity, links = true}) => {
<TableData>{_('EPSS Score')}</TableData>
<TableData>
{isNumber(epss?.max_epss?.score)
? epss?.max_epss?.score.toFixed(5) : _("N/A")}
? epss?.max_epss?.score.toFixed(5)
: _('N/A')}
</TableData>
</TableRow>
<TableRow>
<TableData>{_('EPSS Percentile')}</TableData>
<TableData>
{isNumber(epss?.max_epss?.percentile)
? epss?.max_epss?.percentile.toFixed(5) : _("N/A")}
? epss?.max_epss?.percentile.toFixed(5)
: _('N/A')}
</TableData>
</TableRow>
<TableRow>
Expand All @@ -166,13 +173,16 @@ const NvtDetails = ({entity, links = true}) => {
<TableData>{_('CVE Severity')}</TableData>
<TableData>
<Severitybar
severity={isDefined(epss?.max_epss?.cve?.severity)
? epss?.max_epss?.cve?.severity : _("N/A")}
severity={
isDefined(epss?.max_epss?.cve?.severity)
? epss?.max_epss?.cve?.severity
: _('N/A')
}
/>
</TableData>
</TableRow>
</>
}
)}
</TableBody>
</InfoTable>
</DetailsBlock>
Expand Down
Loading

0 comments on commit c4542fd

Please sign in to comment.