Skip to content

Commit

Permalink
chore(router): replace react-router-dom v6 with react-router-dom-v5-c…
Browse files Browse the repository at this point in the history
…ompat (#1529)
  • Loading branch information
aptmac authored Jan 14, 2025
1 parent a607a42 commit 2a0601d
Show file tree
Hide file tree
Showing 39 changed files with 171 additions and 64 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
"react-i18next": "^15.1.0",
"react-joyride": "^2.9.2",
"react-redux": "^8.0.5",
"react-router-dom": "^6.26.2",
"react-router-dom": "5.3.x",
"react-router-dom-v5-compat": "^6.11.2",
"rxjs": "^7.8.1",
"semver": "^7.6.0",
"showdown": "^2.1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/app/AppLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import {
import _ from 'lodash';
import * as React from 'react';
import { Trans } from 'react-i18next';
import { Link, matchPath, NavLink, useLocation, useNavigate } from 'react-router-dom';
import { Link, matchPath, NavLink, useLocation, useNavigate } from 'react-router-dom-v5-compat';
import { map } from 'rxjs/operators';
import { LogoutIcon } from './LogoutIcon';
import { ThemeToggle } from './ThemeToggle';
Expand Down
2 changes: 1 addition & 1 deletion src/app/AppLayout/AuthModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ServiceContext } from '@app/Shared/Services/Services';
import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
import { Modal, ModalVariant, Text } from '@patternfly/react-core';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router-dom-v5-compat';
import { Observable, filter, first, map, mergeMap } from 'rxjs';
import { CredentialAuthForm } from './CredentialAuthForm';

Expand Down
2 changes: 1 addition & 1 deletion src/app/AppLayout/SslErrorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { portalRoot } from '@app/utils/utils';
import { Button, Modal, ModalVariant, Text } from '@patternfly/react-core';
import * as React from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';

export interface SslErrorModalProps {
visible: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/app/Archives/Archives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from '@patternfly/react-core';
import { SearchIcon } from '@patternfly/react-icons';
import * as React from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
import { of } from 'rxjs';
import { AllArchivedRecordingsTable } from './AllArchivedRecordingsTable';
import { AllTargetsArchivedRecordingsTable } from './AllTargetsArchivedRecordingsTable';
Expand Down
2 changes: 1 addition & 1 deletion src/app/BreadcrumbPage/BreadcrumbPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
StackItem,
} from '@patternfly/react-core';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router-dom-v5-compat';
import { BreadcrumbTrail } from './types';
import { isItemFilled } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion src/app/CreateRecording/CustomRecordingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
} from '@patternfly/react-core';
import { HelpIcon } from '@patternfly/react-icons';
import * as React from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
import { forkJoin } from 'rxjs';
import { first } from 'rxjs/operators';
import { EventTemplateIdentifier, CustomRecordingFormData } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/app/CreateRecording/SnapshotRecordingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ServiceContext } from '@app/Shared/Services/Services';
import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
import { ActionGroup, Button, Form, Text, TextContent, TextVariants } from '@patternfly/react-core';
import * as React from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { first } from 'rxjs';

export interface SnapshotRecordingFormProps {}
Expand Down
2 changes: 1 addition & 1 deletion src/app/Dashboard/Charts/jfr/JFRMetricsChartCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
import { DataSourceIcon, ExternalLinkAltIcon, SyncAltIcon, TachometerAltIcon } from '@patternfly/react-icons';
import * as React from 'react';
import { Trans } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { interval } from 'rxjs';
import { DashboardCard } from '../../DashboardCard';
import { ChartContext } from '../context';
Expand Down
2 changes: 1 addition & 1 deletion src/app/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { useCryostatTranslation } from '@i18n/i18nextUtil';
import { Grid, GridItem } from '@patternfly/react-core';
import * as React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { AddCard } from './AddCard';
import { ChartContext } from './Charts/context';
import { JFRMetricsChartController } from './Charts/jfr/JFRMetricsChartController';
Expand Down
2 changes: 1 addition & 1 deletion src/app/Dashboard/DashboardSolo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { MonitoringIcon } from '@patternfly/react-icons';
import * as React from 'react';
import { useSelector } from 'react-redux';
import { useLocation, useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
import { CardConfig } from './types';
import { getCardDescriptorByName } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion src/app/Events/EventTemplates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import {
} from '@patternfly/react-table';
import _ from 'lodash';
import * as React from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { forkJoin, Observable, of } from 'rxjs';
import { catchError, concatMap, defaultIfEmpty, first, tap } from 'rxjs/operators';

Expand Down
2 changes: 1 addition & 1 deletion src/app/Events/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
import { getActiveTab, switchTab } from '@app/utils/utils';
import { Card, CardBody, Tab, Tabs, Tooltip } from '@patternfly/react-core';
import * as React from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
import { concatMap, filter } from 'rxjs';
import { EventTemplates } from './EventTemplates';
import { EventTypes } from './EventTypes';
Expand Down
2 changes: 1 addition & 1 deletion src/app/NotFound/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from '@patternfly/react-core';
import { MapMarkedAltIcon } from '@patternfly/react-icons';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router-dom-v5-compat';
import { NotFoundCard } from './NotFoundCard';

export interface NotFoundProps {}
Expand Down
2 changes: 1 addition & 1 deletion src/app/NotFound/NotFoundCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { Card, CardTitle, CardBody, CardFooter } from '@patternfly/react-core';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router-dom-v5-compat';

export interface NotFoundCardProps {
title: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion src/app/Recordings/ActiveRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import { EllipsisVIcon, RedoIcon } from '@patternfly/react-icons';
import { ExpandableRowContent, SortByDirection, Tbody, Td, Tr } from '@patternfly/react-table';
import * as React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { combineLatest, forkJoin, merge, Observable } from 'rxjs';
import { concatMap, filter, first } from 'rxjs/operators';
import { DeleteWarningModal } from '../Modal/DeleteWarningModal';
Expand Down
2 changes: 1 addition & 1 deletion src/app/Recordings/Recordings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
import { getActiveTab, switchTab } from '@app/utils/utils';
import { Card, CardBody, CardTitle, Tab, Tabs, TabTitleText } from '@patternfly/react-core';
import * as React from 'react';
import { useLocation, useNavigate } from 'react-router';
import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
import { ActiveRecordingsTable } from './ActiveRecordingsTable';
import { ArchivedRecordingsTable } from './ArchivedRecordingsTable';

Expand Down
2 changes: 1 addition & 1 deletion src/app/Rules/CreateRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import { HelpIcon } from '@patternfly/react-icons';
import _ from 'lodash';
import * as React from 'react';
import { Trans } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { combineLatest, forkJoin, iif, of, Subject } from 'rxjs';
import { catchError, debounceTime, map, switchMap, tap } from 'rxjs/operators';
import { RuleFormData } from './types';
Expand Down
4 changes: 2 additions & 2 deletions src/app/Rules/Rules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Rule, NotificationCategory } from '@app/Shared/Services/api.types';
import { ServiceContext } from '@app/Shared/Services/Services';
import { useSubscriptions } from '@app/utils/hooks/useSubscriptions';
import { TableColumn, formatBytes, formatDuration, sortResources, portalRoot } from '@app/utils/utils';
import { useCryostatTranslation } from '@i18n/i18nextUtil';
import {
Button,
Card,
Expand Down Expand Up @@ -59,12 +60,11 @@ import {
import _ from 'lodash';
import * as React from 'react';
import { Trans } from 'react-i18next';
import { Link, useNavigate } from 'react-router-dom';
import { Link, useNavigate } from 'react-router-dom-v5-compat';
import { first } from 'rxjs/operators';
import { RuleDeleteWarningModal } from './RuleDeleteWarningModal';
import { RuleUploadModal } from './RulesUploadModal';
import { RuleToDeleteOrDisable } from './types';
import { useCryostatTranslation } from '@i18n/i18nextUtil';

export interface RulesTableProps {}

Expand Down
2 changes: 1 addition & 1 deletion src/app/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
} from '@patternfly/react-core';
import * as React from 'react';
import { Trans } from 'react-i18next';
import { useLocation, useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
import { AutomatedAnalysis } from './Config/AutomatedAnalysis';
import { AutoRefresh } from './Config/AutoRefresh';
import { ChartCards } from './Config/ChartCards';
Expand Down
2 changes: 1 addition & 1 deletion src/app/TargetView/TargetContextSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
} from '@patternfly/react-core';
import _ from 'lodash';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router-dom-v5-compat';

export interface TargetContextSelectorProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Actions/CreateTarget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
import { CheckCircleIcon, ExclamationCircleIcon, PendingIcon, SyncAltIcon } from '@patternfly/react-icons';
import { css } from '@patternfly/react-styles';
import * as React from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';

export const isValidTargetConnectURL = (connectUrl?: string) => connectUrl && !connectUrl.match(/\s+/);

Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Actions/NodeActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
import { css } from '@patternfly/react-styles';
import { ContextMenuItem as PFContextMenuItem } from '@patternfly/react-topology';
import * as React from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom-v5-compat';
import { Observable, Subject, switchMap } from 'rxjs';
import { GraphElement, ListElement } from '../Shared/types';
import { ActionUtils, MenuItemComponent, MenuItemVariant, NodeActionFunction } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Actions/QuickSearchPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { css } from '@patternfly/react-styles';
import { useHover } from '@patternfly/react-topology';
import _ from 'lodash';
import * as React from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { Link, useNavigate } from 'react-router-dom-v5-compat';
import QuickSearchIcon from '../../Shared/Components/QuickSearchIcon';
import quickSearches, { QuickSearchId, quickSearchIds } from './quicksearches/all-quick-searches';
import { QuickSearchItem } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Actions/WarningResolver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { NotificationsContext } from '@app/Shared/Services/Notifications.service
import { ServiceContext } from '@app/Shared/Services/Services';
import { Button, ButtonProps } from '@patternfly/react-core';
import * as React from 'react';
import { Link, LinkProps, useNavigate } from 'react-router-dom';
import { Link, LinkProps, useNavigate } from 'react-router-dom-v5-compat';
import { ActionUtils } from './types';

export interface WarningResolverAsLinkProps extends LinkProps {}
Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Actions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Services } from '@app/Shared/Services/Services';
import { LabelProps, DropdownItemProps } from '@patternfly/react-core';
import { ContextMenuItem as PFContextMenuItem } from '@patternfly/react-topology';
import * as React from 'react';
import { NavigateFunction } from 'react-router-dom';
import { NavigateFunction } from 'react-router-dom-v5-compat';
import { Observable } from 'rxjs';
import type { GraphElement, ListElement } from '../Shared/types';

Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Entity/EntityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { css } from '@patternfly/react-styles';
import { ExpandableRowContent, Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table';
import { GraphElement, NodeStatus } from '@patternfly/react-topology';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router-dom-v5-compat';
import { catchError, concatMap, map, of } from 'rxjs';
import { EmptyText } from '../../Shared/Components/EmptyText';
import { NodeAction } from '../Actions/types';
Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Entity/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
Popover,
} from '@patternfly/react-core';
import * as React from 'react';
import { LinkProps } from 'react-router-dom';
import { LinkProps } from 'react-router-dom-v5-compat';
import {
catchError,
combineLatest,
Expand Down
2 changes: 1 addition & 1 deletion src/app/Topology/Shared/Components/TopologyEmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import { TopologyIcon } from '@patternfly/react-icons';
import * as React from 'react';
import { useDispatch } from 'react-redux';
import { Link } from 'react-router-dom';
import { Link } from 'react-router-dom-v5-compat';
import { DiscoveryTreeContext } from '../utils';

export interface TopologyEmptyStateProps {}
Expand Down
2 changes: 1 addition & 1 deletion src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { NotificationsContext, NotificationsInstance } from '@app/Shared/Service
import { ServiceContext, defaultServices } from '@app/Shared/Services/Services';
import * as React from 'react';
import { Provider } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';
import { BrowserRouter as Router } from 'react-router-dom-v5-compat';
import { JoyrideProvider } from './Joyride/JoyrideProvider';

export const App: React.FC = () => (
Expand Down
2 changes: 1 addition & 1 deletion src/app/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as React from 'react';
import { useLocation, Route, Routes } from 'react-router-dom';
import { useLocation, Route, Routes } from 'react-router-dom-v5-compat';
import About from './About/About';
import Archives from './Archives/Archives';
import CreateRecording from './CreateRecording/CreateRecording';
Expand Down
2 changes: 1 addition & 1 deletion src/app/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ISortBy, SortByDirection, ThProps } from '@patternfly/react-table';
import humanizeDuration from 'humanize-duration';
import { TFunction } from 'i18next';
import _ from 'lodash';
import { NavigateFunction } from 'react-router-dom';
import { NavigateFunction } from 'react-router-dom-v5-compat';
import { BehaviorSubject, Observable } from 'rxjs';
import semverGt from 'semver/functions/gt';
import semverValid from 'semver/functions/valid';
Expand Down
4 changes: 2 additions & 2 deletions src/test/CreateRecording/CustomRecordingForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jest.mock('@patternfly/react-core', () => ({

const mockNavigate = jest.fn();

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
jest.mock('react-router-dom-v5-compat', () => ({
...jest.requireActual('react-router-dom-v5-compat'),
useNavigate: () => mockNavigate,
}));

Expand Down
4 changes: 2 additions & 2 deletions src/test/CreateRecording/SnapshotRecordingForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ jest.spyOn(defaultServices.target, 'authRetry').mockReturnValue(of());

const mockNavigate = jest.fn();

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
jest.mock('react-router-dom-v5-compat', () => ({
...jest.requireActual('react-router-dom-v5-compat'),
useNavigate: () => mockNavigate,
}));

Expand Down
4 changes: 2 additions & 2 deletions src/test/Dashboard/Charts/jfr/JFRMetricsChartCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const mockChartContext = {

const mockNavigate = jest.fn();

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
jest.mock('react-router-dom-v5-compat', () => ({
...jest.requireActual('react-router-dom-v5-compat'),
useNavigate: () => mockNavigate,
}));

Expand Down
4 changes: 2 additions & 2 deletions src/test/Rules/CreateRule.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ const mockRule: Rule = {

const mockNavigate = jest.fn();

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
jest.mock('react-router-dom-v5-compat', () => ({
...jest.requireActual('react-router-dom-v5-compat'),
useNavigate: () => mockNavigate,
}));

Expand Down
4 changes: 2 additions & 2 deletions src/test/Settings/Settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ jest.mock('@app/Settings/Config/Theme', () => ({

const mockNavigate = jest.fn();

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
jest.mock('react-router-dom-v5-compat', () => ({
...jest.requireActual('react-router-dom-v5-compat'),
useNavigate: () => mockNavigate,
}));

Expand Down
2 changes: 1 addition & 1 deletion src/test/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import userEvent from '@testing-library/user-event';
import { t, TOptions } from 'i18next';
import * as React from 'react';
import { Provider } from 'react-redux';
import { createMemoryRouter, RouterProvider } from 'react-router-dom';
import { createMemoryRouter, RouterProvider } from 'react-router-dom-v5-compat';
import renderer from 'react-test-renderer';

export interface ProviderInstance<T> {
Expand Down
Loading

0 comments on commit 2a0601d

Please sign in to comment.