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

Replace Reach Router with React Router v6 #99

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"@fortawesome/free-brands-svg-icons": "^5.11.2",
"@fortawesome/free-solid-svg-icons": "^5.11.2",
"@fortawesome/react-fontawesome": "^0.1.4",
"@reach/router": "^1.3.3",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
Expand All @@ -21,6 +20,8 @@
"react-dom": "^16.13.1",
"react-helmet": "^5.2.1",
"react-js-pagination": "^3.0.3",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"react-scripts": "3.4.1",
"swagger-ui-react": "3.25.0"
},
Expand Down
24 changes: 13 additions & 11 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Router } from "@reach/router";
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import Home from './templates/home';
import About from './templates/about';
import SearchTemplate from './templates/search';
Expand All @@ -19,16 +19,18 @@ library.add(fab, fas);

function App() {
return (
<Router>
<NotFound default />
<Home path="/" />
<About path="/about"/>
<Publishers path="/publishers" />
<SearchTemplate path="/search" />
<ApiDocsFull path="/api" />
<Dataset path="/dataset/:id" />
<ApiDocsSpecific path="/dataset/:id/api" />
</Router>
<BrowserRouter>
<Routes>
<Route path={'/'} element={<Home />} />
<Route path={'/about'} element={<About />} />
<Route path={'/publishers'} element={<Publishers />} />
<Route path={'/search'} element={<SearchTemplate />} />
<Route path={'/api'} element={<ApiDocsFull />} />
<Route path={'/dataset/:id'} element={<Dataset />} />
<Route path={'/dataset/:id/api'} element={<ApiDocsSpecific />} />
<Route path={'*'} element={<NotFound />} />
</Routes>
</BrowserRouter>
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { render } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
render(<App />);
const linkElement = screen.getByText(/Welcome to DKAN/i);
expect(linkElement).toBeInTheDocument();
});
2 changes: 1 addition & 1 deletion src/components/FeaturedDatasets/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import PropTypes from "prop-types";
import excerpts from 'excerpts';
import { Link } from '@reach/router';
import { Link } from 'react-router-dom';
import { Text } from "@civicactions/data-catalog-components";
import config from "../../assets/config";
import './featureddatasets.scss';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import Helmet from "react-helmet";
import { Link } from '@reach/router';
import { Link } from 'react-router-dom';
import { Header, NavBar, Footer } from "@civicactions/data-catalog-components";
import config from "../../assets/config.json";
import links from "../../assets/menu.json";
Expand Down
2 changes: 1 addition & 1 deletion src/templates/dataset/api.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Link } from "@reach/router";
import { Link } from 'react-router-dom';
import Loader from "react-loader-advanced";
import LoadingSpin from "react-loading-spin";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/dataset/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import axios from 'axios';
import { Link } from '@reach/router';
import { Link } from 'react-router-dom';
import Layout from '../../components/Layout';
import config from "../../assets/config";
import ResourceTemplate from "../../components/Resource";
Expand Down
6 changes: 3 additions & 3 deletions src/templates/search/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useLocation } from "@reach/router"
import { useLocation } from 'react-router-dom';
import { defaultFacets, normalizeItems, sortOptions } from '../../config/search';
import { Search, SearchSidebar, SearchContent } from "@civicactions/data-catalog-components";
import Layout from "../../components/Layout";
Expand All @@ -9,7 +9,7 @@ const SearchTemplate = ({path}) => {
const location = useLocation();
return (
<Layout title="Search">
<div className={`dc-page ${config.container}`}>
<div className={`dc-page ${config.container}`}>
<h1>Datasets</h1>
<Search
searchEndpoint={`${process.env.REACT_APP_ROOT_URL}/search`}
Expand All @@ -26,7 +26,7 @@ const SearchTemplate = ({path}) => {
</div>
</Search>
</div>
</Layout>
</Layout>
);
}

Expand Down
96 changes: 29 additions & 67 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,13 @@
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.7.6":
version "7.17.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.9.tgz#d19fbf802d01a8cb6cf053a64e472d42c434ba72"
integrity sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==
dependencies:
regenerator-runtime "^0.13.4"

"@babel/template@^7.10.4", "@babel/template@^7.4.0", "@babel/template@^7.8.6":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.10.4.tgz#3251996c4200ebc71d1a8fc405fba940f36ba278"
Expand Down Expand Up @@ -3417,16 +3424,6 @@ cli-cursor@^3.1.0:
dependencies:
restore-cursor "^3.1.0"

cli-table3@~0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.5.1.tgz#0252372d94dfc40dbd8df06005f48f31f656f202"
integrity sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==
dependencies:
object-assign "^4.1.0"
string-width "^2.1.1"
optionalDependencies:
colors "^1.1.2"

cli-table3@~0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.0.tgz#b7b1bc65ca8e7b5cef9124e13dc2b21e2ce4faee"
Expand Down Expand Up @@ -4201,49 +4198,6 @@ cypress@*:
url "^0.11.0"
yauzl "^2.10.0"

cypress@^4.12.1:
version "4.12.1"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-4.12.1.tgz#0ead1b9f4c0917d69d8b57f996b6e01fe693b6ec"
integrity sha512-9SGIPEmqU8vuRA6xst2CMTYd9sCFCxKSzrHt0wr+w2iAQMCIIsXsQ5Gplns1sT6LDbZcmLv6uehabAOl3fhc9Q==
dependencies:
"@cypress/listr-verbose-renderer" "^0.4.1"
"@cypress/request" "^2.88.5"
"@cypress/xvfb" "^1.2.4"
"@types/sinonjs__fake-timers" "^6.0.1"
"@types/sizzle" "^2.3.2"
arch "^2.1.2"
bluebird "^3.7.2"
cachedir "^2.3.0"
chalk "^2.4.2"
check-more-types "^2.24.0"
cli-table3 "~0.5.1"
commander "^4.1.1"
common-tags "^1.8.0"
debug "^4.1.1"
eventemitter2 "^6.4.2"
execa "^1.0.0"
executable "^4.1.1"
extract-zip "^1.7.0"
fs-extra "^8.1.0"
getos "^3.2.1"
is-ci "^2.0.0"
is-installed-globally "^0.3.2"
lazy-ass "^1.6.0"
listr "^0.14.3"
lodash "^4.17.19"
log-symbols "^3.0.0"
minimist "^1.2.5"
moment "^2.27.0"
ospath "^1.2.2"
pretty-bytes "^5.3.0"
ramda "~0.26.1"
request-progress "^3.0.0"
supports-color "^7.1.0"
tmp "~0.1.0"
untildify "^4.0.0"
url "^0.11.0"
yauzl "^2.10.0"

d@1, d@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a"
Expand Down Expand Up @@ -6109,6 +6063,13 @@ hex-color-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==

history@^5.2.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/history/-/history-5.3.0.tgz#1548abaa245ba47992f063a0783db91ef201c73b"
integrity sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==
dependencies:
"@babel/runtime" "^7.7.6"

hmac-drbg@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
Expand Down Expand Up @@ -7971,13 +7932,6 @@ log-symbols@^1.0.2:
dependencies:
chalk "^1.0.0"

log-symbols@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4"
integrity sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==
dependencies:
chalk "^2.4.2"

log-symbols@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920"
Expand Down Expand Up @@ -10482,6 +10436,21 @@ react-redux@^4.x.x:
loose-envify "^1.4.0"
prop-types "^15.7.2"

react-router-dom@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.3.0.tgz#a0216da813454e521905b5fa55e0e5176123f43d"
integrity sha512-uaJj7LKytRxZNQV8+RbzJWnJ8K2nPsOOEuX7aQstlMZKQT0164C+X2w6bnkqU3sjtLvpd5ojrezAyfZ1+0sStw==
dependencies:
history "^5.2.0"
react-router "6.3.0"

[email protected], react-router@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.3.0.tgz#3970cc64b4cb4eae0c1ea5203a80334fdd175557"
integrity sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==
dependencies:
history "^5.2.0"

[email protected]:
version "3.4.1"
resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-3.4.1.tgz#f551298b5c71985cc491b9acf3c8e8c0ae3ada0a"
Expand Down Expand Up @@ -12220,13 +12189,6 @@ tmp@^0.0.33:
dependencies:
os-tmpdir "~1.0.2"

tmp@~0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.1.0.tgz#ee434a4e22543082e294ba6201dcc6eafefa2877"
integrity sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==
dependencies:
rimraf "^2.6.3"

tmp@~0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14"
Expand Down