Skip to content

Commit

Permalink
chore: update react router
Browse files Browse the repository at this point in the history
  • Loading branch information
kielllll committed Oct 30, 2024
1 parent b8bf603 commit 0127593
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 73 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react-redux": "^9.1.2",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-router-dom-v5-compat": "^6.27.0",
"redux": "^5.0.1",
"redux-saga": "^1.1.3",
"redux-watch": "^1.2.0",
Expand Down
29 changes: 16 additions & 13 deletions src/assets/js/react/router/coreFontRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { HashRouter as Router, Route, Switch } from 'react-router-dom'
import { CompatRouter } from 'react-router-dom-v5-compat'
/* Components */
import CoreFontContainer from '../components/CoreFonts/CoreFontContainer'

Expand All @@ -27,21 +28,23 @@ import CoreFontContainer from '../components/CoreFonts/CoreFontContainer'
*/
const Routes = ({ button }) => (
<Router>
<Switch>
<Route render={(props) => <CoreFont history={props.history} button={button} />} />
<CompatRouter>
<Switch>
<Route render={(props) => <CoreFont history={props.history} button={button} />} />

<Route
path='/downloadCoreFonts'
exact
render={(props) => <CoreFont history={props.history} button={button} />}
/>
<Route
path='/downloadCoreFonts'
exact
render={(props) => <CoreFont history={props.history} button={button} />}
/>

<Route
path='/retryDownloadCoreFonts'
exact
render={(props) => <CoreFont history={props.history} button={button} />}
/>
</Switch>
<Route
path='/retryDownloadCoreFonts'
exact
render={(props) => <CoreFont history={props.history} button={button} />}
/>
</Switch>
</CompatRouter>
</Router>
)

Expand Down
29 changes: 16 additions & 13 deletions src/assets/js/react/router/fontManagerRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import { createRoot } from 'react-dom/client'
import { HashRouter as Router, Route, Switch } from 'react-router-dom'
import { CompatRouter } from 'react-router-dom-v5-compat'
import { Provider } from 'react-redux'
/* Components */
import FontManager from '../components/FontManager/FontManager'
Expand Down Expand Up @@ -30,19 +31,21 @@ import Empty from '../components/Empty'
*/
export const Routes = () => (
<Router>
<Switch>
<Route
exact
path='/fontmanager/'
render={props => <FontManager id={props.match.params.id} history={props.history} />}
/>
<Route
exact
path='/fontmanager/:id'
render={props => <FontManager id={props.match.params.id} history={props.history} />}
/>
<Route component={Empty} />
</Switch>
<CompatRouter>
<Switch>
<Route
exact
path='/fontmanager/'
render={props => <FontManager id={props.match.params.id} history={props.history} />}
/>
<Route
exact
path='/fontmanager/:id'
render={props => <FontManager id={props.match.params.id} history={props.history} />}
/>
<Route component={Empty} />
</Switch>
</CompatRouter>
</Router>
)

Expand Down
95 changes: 49 additions & 46 deletions src/assets/js/react/router/templateRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { lazy, Suspense } from 'react'
import { createRoot } from 'react-dom/client'
import { Provider } from 'react-redux'
import { HashRouter as Router, Route, Switch } from 'react-router-dom'
import { CompatRouter } from 'react-router-dom-v5-compat'
/* Components */
import Empty from '../components/Empty'
const TemplateList = lazy(() => import('../components/Template/TemplateList'))
Expand Down Expand Up @@ -35,52 +36,54 @@ const TemplateSingle = lazy(() => import('../components/Template/TemplateSingle'
export const Routes = () => (
<Suspense fallback={<div>{GFPDF.spinnerAlt}</div>}>
<Router>
<Switch>
<Route
path='/template'
exact
render={(props) => (
<TemplateList
{...props}
ajaxUrl={GFPDF.ajaxUrl}
ajaxNonce={GFPDF.ajaxNonce}
templateDetailsText={GFPDF.templateDetails}
templateHeaderText={GFPDF.installedPdfs}
genericUploadErrorText={GFPDF.problemWithTheUpload}
activateText={GFPDF.select}
addTemplateText={GFPDF.addNewTemplate}
filenameErrorText={GFPDF.uploadInvalidNotZipFile}
filesizeErrorText={GFPDF.uploadInvalidExceedsFileSizeLimit}
installSuccessText={GFPDF.templateSuccessfullyInstalled}
installUpdatedText={GFPDF.templateSuccessfullyUpdated}
templateSuccessfullyInstalledUpdated={GFPDF.templateSuccessfullyInstalledUpdated}
templateInstallInstructions={GFPDF.templateInstallInstructions}
/>
)}
/>
<Route
path='/template/:id'
render={(props) => (
<TemplateSingle
{...props}
ajaxUrl={GFPDF.ajaxUrl}
ajaxNonce={GFPDF.ajaxNonce}
pdfWorkingDirPath={GFPDF.pdfWorkingDir}
activateText={GFPDF.select}
templateDeleteText={GFPDF.delete}
templateConfirmDeleteText={GFPDF.doYouWantToDeleteTemplate}
templateDeleteErrorText={GFPDF.couldNotDeleteTemplate}
currentTemplateText={GFPDF.currentTemplate}
versionText={GFPDF.version}
groupText={GFPDF.group}
tagsText={GFPDF.tags}
showPreviousTemplateText={GFPDF.showPreviousTemplate}
showNextTemplateText={GFPDF.showNextTemplate}
/>
)}
/>
<Route component={Empty} />
</Switch>
<CompatRouter>
<Switch>
<Route
path='/template'
exact
render={(props) => (
<TemplateList
{...props}
ajaxUrl={GFPDF.ajaxUrl}
ajaxNonce={GFPDF.ajaxNonce}
templateDetailsText={GFPDF.templateDetails}
templateHeaderText={GFPDF.installedPdfs}
genericUploadErrorText={GFPDF.problemWithTheUpload}
activateText={GFPDF.select}
addTemplateText={GFPDF.addNewTemplate}
filenameErrorText={GFPDF.uploadInvalidNotZipFile}
filesizeErrorText={GFPDF.uploadInvalidExceedsFileSizeLimit}
installSuccessText={GFPDF.templateSuccessfullyInstalled}
installUpdatedText={GFPDF.templateSuccessfullyUpdated}
templateSuccessfullyInstalledUpdated={GFPDF.templateSuccessfullyInstalledUpdated}
templateInstallInstructions={GFPDF.templateInstallInstructions}
/>
)}
/>
<Route
path='/template/:id'
render={(props) => (
<TemplateSingle
{...props}
ajaxUrl={GFPDF.ajaxUrl}
ajaxNonce={GFPDF.ajaxNonce}
pdfWorkingDirPath={GFPDF.pdfWorkingDir}
activateText={GFPDF.select}
templateDeleteText={GFPDF.delete}
templateConfirmDeleteText={GFPDF.doYouWantToDeleteTemplate}
templateDeleteErrorText={GFPDF.couldNotDeleteTemplate}
currentTemplateText={GFPDF.currentTemplate}
versionText={GFPDF.version}
groupText={GFPDF.group}
tagsText={GFPDF.tags}
showPreviousTemplateText={GFPDF.showPreviousTemplate}
showNextTemplateText={GFPDF.showNextTemplate}
/>
)}
/>
<Route component={Empty} />
</Switch>
</CompatRouter>
</Router>
</Suspense>)

Expand Down
30 changes: 29 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@
dependencies:
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.23.2", "@babel/runtime@^7.8.4":
"@babel/runtime@^7.23.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4":
version "7.26.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1"
integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==
Expand Down Expand Up @@ -2040,6 +2040,11 @@
resolved "https://registry.yarnpkg.com/@redux-saga/types/-/types-1.2.1.tgz#9403f51c17cae37edf870c6bc0c81c1ece5ccef8"
integrity sha512-1dgmkh+3so0+LlBWRhGA33ua4MYr7tUOj+a9Si28vUi0IUFNbff1T3sgpeDJI/LaC75bBYnQ0A3wXjn0OrRNBA==

"@remix-run/[email protected]":
version "1.20.0"
resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.20.0.tgz#03554155b45d8b529adf635b2f6ad1165d70d8b4"
integrity sha512-mUnk8rPJBI9loFDZ+YzPGdeniYK+FTmRD1TMCz7ev2SNIozyKKpnGgsxO34u6Z4z/t0ITuu7voi/AshfsGsgFg==

"@rtsao/scc@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8"
Expand Down Expand Up @@ -5729,6 +5734,13 @@ history@^4.9.0:
tiny-warning "^1.0.0"
value-equal "^1.0.1"

history@^5.3.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"

hogan.js@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/hogan.js/-/hogan.js-3.0.2.tgz#4cd9e1abd4294146e7679e41d7898732b02c7bfd"
Expand Down Expand Up @@ -8831,6 +8843,15 @@ react-redux@^9.1.2:
"@types/use-sync-external-store" "^0.0.3"
use-sync-external-store "^1.0.0"

react-router-dom-v5-compat@^6.27.0:
version "6.27.0"
resolved "https://registry.yarnpkg.com/react-router-dom-v5-compat/-/react-router-dom-v5-compat-6.27.0.tgz#19429aefa130ee151e6f4487d073d919ec22d458"
integrity sha512-hq5yCVoW73mljLhRjyzpYmooLNPR/xb17S3CTz9fe2/P7q821ivMEa9c8OtrAk2Bs83PcNAtst5okT/aUhJtgg==
dependencies:
"@remix-run/router" "1.20.0"
history "^5.3.0"
react-router "6.27.0"

react-router-dom@^5.2.0:
version "5.3.4"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-5.3.4.tgz#2ed62ffd88cae6db134445f4a0c0ae8b91d2e5e6"
Expand Down Expand Up @@ -8859,6 +8880,13 @@ [email protected], react-router@^5.2.0:
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"

[email protected]:
version "6.27.0"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.27.0.tgz#db292474926c814c996c0ff3ef0162d1f9f60ed4"
integrity sha512-YA+HGZXz4jaAkVoYBE98VQl+nVzI+cVI2Oj/06F5ZM+0u3TgedN9Y9kmMRo2mnkSK2nCpNQn0DVob4HCsY/WLw==
dependencies:
"@remix-run/router" "1.20.0"

react-shallow-renderer@^16.13.1:
version "16.15.0"
resolved "https://registry.yarnpkg.com/react-shallow-renderer/-/react-shallow-renderer-16.15.0.tgz#48fb2cf9b23d23cde96708fe5273a7d3446f4457"
Expand Down

0 comments on commit 0127593

Please sign in to comment.