Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonicalize all general reacts hooks in hooks directory #4076

Merged
merged 7 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion src/web/components/date/datetime.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {dateTimeWithTimeZone, ensureDate} from 'gmp/locale/date';
import {isDefined, hasValue} from 'gmp/utils/identity';

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

const DateTime = ({formatter = dateTimeWithTimeZone, timezone, date}) => {
date = ensureDate(date);
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
8 changes: 4 additions & 4 deletions src/web/components/menu/usermenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ 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 useUserName from 'web/utils/useUserName';
import useUserSessionTimeout from 'web/utils/useUserSessionTimeout';
import useUserTimezone from 'web/utils/useUserTimezone';
import useGmp from 'web/hooks/useGmp';
import useUserName from 'web/hooks/useUserName';
import useUserSessionTimeout from 'web/hooks/useUserSessionTimeout';
import useUserTimezone from 'web/hooks/useUserTimezone';

const UserMenu = styled.span`
display: inline-flex;
Expand Down
3 changes: 1 addition & 2 deletions src/web/components/notification/licensenotification.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';
Expand All @@ -17,7 +16,7 @@ import Link from 'web/components/link/link';
import InfoPanel from 'web/components/panel/infopanel';

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

const LICENSE_EXPIRATION_THRESHOLD = 30;

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


import React from 'react';

import Layout from 'web/components/layout/layout';

import withFilterDialog from 'web/components/powerfilter/withFilterDialog';
import useCapabilities from 'web/utils/useCapabilities';
import useCapabilities from 'web/hooks/useCapabilities';

import CreateNamedFilterGroup from './createnamedfiltergroup';
import FilterStringGroup from './filterstringgroup';
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
4 changes: 2 additions & 2 deletions src/web/entities/BulkTags.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ 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 useUserSessionTimeout from 'web/utils/useUserSessionTimeout';
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 @@ -7,7 +7,7 @@ import {describe, test, expect} from '@gsa/testing';

import Capabilities from 'gmp/capabilities/capabilities';

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

import useCapabilities from '../useCapabilities';

Expand All @@ -19,7 +19,7 @@ const TestUseCapabilities = () => {
return <span>Not allowed to create a task</span>;
};

describe('useCapabilties tests', () => {
describe('useCapabilities tests', () => {
test('should be allowed to create a task', () => {
const capabilities = new Capabilities(['create_task']);
const {render} = rendererWith({capabilities});
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {describe, test, expect} from '@gsa/testing';

import {setUsername} from 'web/store/usersettings/actions';

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

import useUserName from '../useUserName';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import date from 'gmp/models/date';

import {setSessionTimeout as setSessionTimeoutAction} from 'web/store/usersettings/actions';

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

import useUserSessionTimeout from '../useUserSessionTimeout';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {describe, test, expect} from '@gsa/testing';

import {setTimezone as setTimezoneAction} from 'web/store/usersettings/actions';

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

import useUserTimezone from '../useUserTimezone';

Expand Down
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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/cvssV4/CvssV4Calculator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
removeUnusedMetrics,
} from 'gmp/parser/cvssV4';

import useUserSessionTimeout from 'web/utils/useUserSessionTimeout';
import useUserSessionTimeout from 'web/hooks/useUserSessionTimeout';
import FormGroup from 'web/components/form/formgroup';
import Layout from 'web/components/layout/layout';
import Section from 'web/components/section/section';
Expand Down
2 changes: 1 addition & 1 deletion src/web/pages/extras/cvsscalculatorpage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Divider from 'web/components/layout/divider';

import Section from 'web/components/section/section';

import useUserSessionTimeout from 'web/utils/useUserSessionTimeout';
import useUserSessionTimeout from 'web/hooks/useUserSessionTimeout';
import CvssV4Calculator from './cvssV4/CvssV4Calculator';

const StyledTextField = styled(TextField)`
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
2 changes: 1 addition & 1 deletion src/web/pages/extras/trashcanpage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {renewSessionTimeout} from 'web/store/usersettings/actions';
import compose from 'web/utils/compose';
import PropTypes from 'web/utils/proptypes';
import withGmp from 'web/utils/withGmp';
import useCapabilities from 'web/utils/useCapabilities';
import useCapabilities from 'web/hooks/useCapabilities';

import AlertsTable from '../alerts/table';
import ScanConfigsTable from '../scanconfigs/table';
Expand Down
Loading
Loading