Skip to content

Commit

Permalink
Merge pull request #1395 from acelaya-forks/feature/react-router-7
Browse files Browse the repository at this point in the history
Update to react-router 7
  • Loading branch information
acelaya authored Dec 9, 2024
2 parents d14c4fa + a65c717 commit f4c4f40
Show file tree
Hide file tree
Showing 34 changed files with 166 additions and 115 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]
### Added
* *Nothing*

### Changed
* Update to `react-router` 7.0
* Update to `@shlinkio/shlink-frontend-kit` 0.7.0
* Update to `@shlinkio/shlink-web-component` 0.12.0

### Deprecated
* *Nothing*

### Removed
* *Nothing*

### Fixed
* *Nothing*


## [4.3.0] - 2024-11-30
### Added
* [#1360](https://github.com/shlinkio/shlink-web-client/issues/1360) Added ability for server IDs to be generated based on the server name and URL, instead of generating a random UUID.
Expand Down
184 changes: 103 additions & 81 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"@json2csv/plainjs": "^7.0.6",
"@reduxjs/toolkit": "^2.4.0",
"@shlinkio/data-manipulation": "^1.0.3",
"@shlinkio/shlink-frontend-kit": "^0.6.0",
"@shlinkio/shlink-frontend-kit": "^0.7.0",
"@shlinkio/shlink-js-sdk": "^1.3.0",
"@shlinkio/shlink-web-component": "^0.11.0",
"@shlinkio/shlink-web-component": "^0.12.0",
"bootstrap": "5.2.3",
"bottlejs": "^2.0.1",
"clsx": "^2.1.1",
Expand All @@ -46,7 +46,7 @@
"react-dom": "^18.3.1",
"react-external-link": "^2.4.0",
"react-redux": "^9.1.2",
"react-router-dom": "^6.28.0",
"react-router": "^7.0.2",
"reactstrap": "^9.2.3",
"redux-localstorage-simple": "^2.5.1",
"workbox-core": "^7.3.0",
Expand Down
10 changes: 7 additions & 3 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Settings } from '@shlinkio/shlink-web-component/settings';
import { clsx } from 'clsx';
import type { FC } from 'react';
import { useEffect, useRef } from 'react';
import { Route, Routes, useLocation } from 'react-router-dom';
import { Route, Routes, useLocation } from 'react-router';
import { AppUpdateBanner } from '../common/AppUpdateBanner';
import { NotFound } from '../common/NotFound';
import type { FCWithDeps } from '../container/utils';
Expand Down Expand Up @@ -69,11 +69,15 @@ const App: FCWithDeps<AppProps, AppDeps> = (
<div className={clsx('shlink-wrapper', { 'd-flex align-items-center pt-3': isHome })}>
<Routes>
<Route index element={<Home />} />
<Route path="/settings/*" element={<Settings />} />
<Route path="/settings">
{['', '*'].map((path) => <Route key={path} path={path} element={<Settings />} />)}
</Route>
<Route path="/manage-servers" element={<ManageServers />} />
<Route path="/server/create" element={<CreateServer />} />
<Route path="/server/:serverId/edit" element={<EditServer />} />
<Route path="/server/:serverId/*" element={<ShlinkWebComponentContainer />} />
<Route path="/server/:serverId">
{['', '*'].map((path) => <Route key={path} path={path} element={<ShlinkWebComponentContainer />} />)}
</Route>
<Route path="*" element={<NotFound />} />
</Routes>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/common/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { clsx } from 'clsx';
import { useEffect } from 'react';
import { ExternalLink } from 'react-external-link';
import { Link, useNavigate } from 'react-router-dom';
import { Link, useNavigate } from 'react-router';
import { Card } from 'reactstrap';
import type { ServersMap } from '../servers/data';
import { ServersListGroup } from '../servers/ServersListGroup';
Expand Down
2 changes: 1 addition & 1 deletion src/common/MainHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useToggle } from '@shlinkio/shlink-frontend-kit';
import { clsx } from 'clsx';
import type { FC } from 'react';
import { useEffect } from 'react';
import { Link, useLocation } from 'react-router-dom';
import { Link, useLocation } from 'react-router';
import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
import type { FCWithDeps } from '../container/utils';
import { componentFactory, useDependencies } from '../container/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/common/NotFound.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SimpleCard } from '@shlinkio/shlink-frontend-kit';
import type { FC, PropsWithChildren } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';

type NotFoundProps = PropsWithChildren<{ to?: string }>;

Expand Down
2 changes: 1 addition & 1 deletion src/common/ScrollToTop.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC, PropsWithChildren } from 'react';
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { useLocation } from 'react-router';

export const ScrollToTop: FC<PropsWithChildren> = ({ children }) => {
const location = useLocation();
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import { BrowserRouter } from 'react-router';
import pack from '../package.json';
import { container } from './container';
import { setUpStore } from './container/store';
Expand Down
2 changes: 1 addition & 1 deletion src/servers/CreateServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { TimeoutToggle } from '@shlinkio/shlink-frontend-kit';
import { Result, useToggle } from '@shlinkio/shlink-frontend-kit';
import type { FC } from 'react';
import { useCallback, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router';
import { Button } from 'reactstrap';
import { NoMenuLayout } from '../common/NoMenuLayout';
import type { FCWithDeps } from '../container/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/servers/DeleteServerModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC } from 'react';
import { useRef } from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router';
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import type { ServerWithId } from './data';

Expand Down
2 changes: 1 addition & 1 deletion src/servers/ManageServers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { TimeoutToggle } from '@shlinkio/shlink-frontend-kit';
import { Result, SearchField, SimpleCard } from '@shlinkio/shlink-frontend-kit';
import type { FC } from 'react';
import { useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import { Button } from 'reactstrap';
import { NoMenuLayout } from '../common/NoMenuLayout';
import type { FCWithDeps } from '../container/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/servers/ManageServersRow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { faCheck as checkIcon } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { FC } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import { UncontrolledTooltip } from 'reactstrap';
import type { FCWithDeps } from '../container/utils';
import { componentFactory, useDependencies } from '../container/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/servers/ManageServersRowDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { RowDropdownBtn, useToggle } from '@shlinkio/shlink-frontend-kit';
import type { FC } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import { DropdownItem } from 'reactstrap';
import type { FCWithDeps } from '../container/utils';
import { componentFactory, useDependencies } from '../container/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/servers/ServersDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { faPlus as plusIcon, faServer as serverIcon } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from 'reactstrap';
import type { SelectedServer, ServersMap } from './data';
import { getServerId } from './data';
Expand Down
2 changes: 1 addition & 1 deletion src/servers/ServersListGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { faChevronRight as chevronIcon } from '@fortawesome/free-solid-svg-icons
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { clsx } from 'clsx';
import type { FC, PropsWithChildren } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import { ListGroup, ListGroupItem } from 'reactstrap';
import type { ServerWithId } from './data';
import './ServersListGroup.scss';
Expand Down
2 changes: 1 addition & 1 deletion src/servers/helpers/ServerError.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Message } from '@shlinkio/shlink-frontend-kit';
import type { FC } from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'react-router';
import { NoMenuLayout } from '../../common/NoMenuLayout';
import type { FCWithDeps } from '../../container/utils';
import { componentFactory, useDependencies } from '../../container/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/servers/helpers/withSelectedServer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Message } from '@shlinkio/shlink-frontend-kit';
import type { FC } from 'react';
import { useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { useParams } from 'react-router';
import { NoMenuLayout } from '../../common/NoMenuLayout';
import type { FCWithDeps } from '../../container/utils';
import { useDependencies } from '../../container/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helpers/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router';

export const useGoBack = () => {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion test/__helpers__/MemoryRouterWithParams.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC, PropsWithChildren } from 'react';
import { useMemo } from 'react';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { MemoryRouter, Route, Routes } from 'react-router';

export type MemoryRouterWithParamsProps = PropsWithChildren<{
params: Record<string, string>;
Expand Down
2 changes: 1 addition & 1 deletion test/app/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { act, render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import { AppFactory } from '../../src/app/App';
import { checkAccessibility } from '../__helpers__/accessibility';

Expand Down
2 changes: 1 addition & 1 deletion test/common/MainHeader.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom';
import { Router } from 'react-router';
import { MainHeaderFactory } from '../../src/common/MainHeader';
import { checkAccessibility } from '../__helpers__/accessibility';
import { renderWithEvents } from '../__helpers__/setUpTest';
Expand Down
2 changes: 1 addition & 1 deletion test/servers/CreateServer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fireEvent, screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom';
import { Router } from 'react-router';
import { CreateServerFactory } from '../../src/servers/CreateServer';
import type { ServersMap } from '../../src/servers/data';
import { checkAccessibility } from '../__helpers__/accessibility';
Expand Down
2 changes: 1 addition & 1 deletion test/servers/DeleteServerModal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { act, screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom';
import { Router } from 'react-router';
import { DeleteServerModal } from '../../src/servers/DeleteServerModal';
import { checkAccessibility } from '../__helpers__/accessibility';
import { renderWithEvents } from '../__helpers__/setUpTest';
Expand Down
2 changes: 1 addition & 1 deletion test/servers/EditServer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fireEvent, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom';
import { Router } from 'react-router';
import type { ReachableServer, SelectedServer } from '../../src/servers/data';
import { EditServerFactory } from '../../src/servers/EditServer';
import { checkAccessibility } from '../__helpers__/accessibility';
Expand Down
2 changes: 1 addition & 1 deletion test/servers/ManageServers.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import type { ServersMap, ServerWithId } from '../../src/servers/data';
import { ManageServersFactory } from '../../src/servers/ManageServers';
import type { ServersExporter } from '../../src/servers/services/ServersExporter';
Expand Down
2 changes: 1 addition & 1 deletion test/servers/ManageServersRow.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import type { ServerWithId } from '../../src/servers/data';
import { ManageServersRowFactory } from '../../src/servers/ManageServersRow';
import { checkAccessibility } from '../__helpers__/accessibility';
Expand Down
2 changes: 1 addition & 1 deletion test/servers/ManageServersRowDropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { screen } from '@testing-library/react';
import type { UserEvent } from '@testing-library/user-event';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import type { ServerWithId } from '../../src/servers/data';
import { ManageServersRowDropdownFactory } from '../../src/servers/ManageServersRowDropdown';
import { checkAccessibility } from '../__helpers__/accessibility';
Expand Down
2 changes: 1 addition & 1 deletion test/servers/ServersDropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import type { ServersMap } from '../../src/servers/data';
import { ServersDropdown } from '../../src/servers/ServersDropdown';
import { checkAccessibility } from '../__helpers__/accessibility';
Expand Down
2 changes: 1 addition & 1 deletion test/servers/ServersListGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import type { ServerWithId } from '../../src/servers/data';
import { ServersListGroup } from '../../src/servers/ServersListGroup';
import { checkAccessibility } from '../__helpers__/accessibility';
Expand Down
2 changes: 2 additions & 0 deletions test/servers/__snapshots__/ManageServersRow.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ exports[`<ManageServersRow /> > renders auto-connect icon only if server is auto
data-th="Name"
>
<a
data-discover="true"
href="/server/abc"
>
My server
Expand Down Expand Up @@ -73,6 +74,7 @@ exports[`<ManageServersRow /> > renders auto-connect icon only if server is auto
data-th="Name"
>
<a
data-discover="true"
href="/server/abc"
>
My server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ exports[`<ManageServersRowDropdown /> > renders expected size and icon 1`] = `
>
<a
class="dropdown-item"
data-discover="true"
href="/server/abc123"
role="menuitem"
tabindex="0"
Expand All @@ -61,6 +62,7 @@ exports[`<ManageServersRowDropdown /> > renders expected size and icon 1`] = `
</a>
<a
class="dropdown-item"
data-discover="true"
href="/server/abc123/edit"
role="menuitem"
tabindex="0"
Expand Down Expand Up @@ -181,6 +183,7 @@ exports[`<ManageServersRowDropdown /> > renders expected size and icon 2`] = `
>
<a
class="dropdown-item"
data-discover="true"
href="/server/abc123"
role="menuitem"
tabindex="0"
Expand All @@ -204,6 +207,7 @@ exports[`<ManageServersRowDropdown /> > renders expected size and icon 2`] = `
</a>
<a
class="dropdown-item"
data-discover="true"
href="/server/abc123/edit"
role="menuitem"
tabindex="0"
Expand Down
2 changes: 1 addition & 1 deletion test/servers/helpers/ServerError.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import type { NonReachableServer, NotFoundServer, SelectedServer } from '../../../src/servers/data';
import { ServerErrorFactory } from '../../../src/servers/helpers/ServerError';
import { checkAccessibility } from '../../__helpers__/accessibility';
Expand Down
2 changes: 1 addition & 1 deletion test/settings/Settings.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';
import { Settings } from '../../src/settings/Settings';
import { checkAccessibility } from '../__helpers__/accessibility';

Expand Down

0 comments on commit f4c4f40

Please sign in to comment.