Skip to content

Commit

Permalink
client-admin upgrade to react router v6
Browse files Browse the repository at this point in the history
  • Loading branch information
thomassth committed Oct 22, 2024
1 parent 3ecc2a5 commit e7b1529
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 123 deletions.
99 changes: 28 additions & 71 deletions client-admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"react-dom": "^18.3.1",
"react-easy-emoji": "~1.8.1",
"react-redux": "^9.1.2",
"react-router-dom": "^5.3.4",
"react-router-dom": "^6.27.0",
"redux": "^5.0.0",
"redux-thunk": "~2.3.0",
"theme-ui": "^0.16.2",
Expand Down
60 changes: 21 additions & 39 deletions client-admin/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { populateUserStore } from './actions'

import _ from 'lodash'

import { Switch, Route, Link, Redirect } from 'react-router-dom'
import { Routes, Route, Link, Navigate } from 'react-router-dom'
import { Flex, Box, jsx } from 'theme-ui'

/* landers */
Expand Down Expand Up @@ -42,8 +42,8 @@ const PrivateRoute = ({ component: Component, isLoading, authed, ...rest }) => {
authed === true ? (
<Component {...props} />
) : (
<Redirect
to={{ pathname: '/signin', state: { from: props.location } }}
<Navigate
to={{ pathname: 'signin', state: { from: props.location } }}
/>
)
}
Expand Down Expand Up @@ -130,41 +130,23 @@ class App extends React.Component {
const { location } = this.props
return (
<>
<Switch>
<Redirect from="/:url*(/+)" to={location.pathname.slice(0, -1)} />
<Route exact path="/home" component={Home} />
<Routes>
<Navigate to={location.pathname.slice(0, -1)} />
<Route exact path="home" component={Home} />
<Route
exact
path="/signin"
path="signin"
render={() => <SignIn {...this.props} authed={this.isAuthed()} />}
/>
<Route
exact
path="/signin/*"
render={() => <SignIn {...this.props} authed={this.isAuthed()} />}
/>
<Route
exact
path="/signin/**/*"
render={() => <SignIn {...this.props} authed={this.isAuthed()} />}
/>
<Route exact path="/signout" component={SignOut} />
<Route exact path="/signout/*" component={SignOut} />
<Route exact path="/signout/**/*" component={SignOut} />
<Route exact path="/createuser" component={CreateUser} />
<Route exact path="/createuser/*" component={CreateUser} />
<Route exact path="/createuser/**/*" component={CreateUser} />

<Route exact path="/pwreset" component={PasswordReset} />
<Route path="/pwreset/*" component={PasswordReset} />
<Route exact path="/pwresetinit" component={PasswordResetInit} />
<Route
exact
path="/pwresetinit/done"
component={PasswordResetInitDone}
/>
<Route exact path="/tos" component={TOS} />
<Route exact path="/privacy" component={Privacy} />
<Route path="signout" component={SignOut} />
<Route path="createuser" component={CreateUser} />

<Route path="pwreset" component={PasswordReset} />
<Route path="pwresetinit" component={PasswordResetInit} >
<Route path="done" component={PasswordResetInitDone} />
</Route>
<Route path="tos" component={TOS} />
<Route path="privacy" component={Privacy} />

<InteriorHeader>
<Route
Expand Down Expand Up @@ -209,21 +191,21 @@ class App extends React.Component {
isLoading={this.isLoading()}
authed={this.isAuthed()}
exact
path="/conversations"
path="conversations"
component={Conversations}
/>
<PrivateRoute
isLoading={this.isLoading()}
authed={this.isAuthed()}
exact
path="/account"
path="account"
component={Account}
/>
<PrivateRoute
isLoading={this.isLoading()}
authed={this.isAuthed()}
exact
path="/integrate"
path="integrate"
component={Integrate}
/>
</Box>
Expand All @@ -234,12 +216,12 @@ class App extends React.Component {

<PrivateRoute
isLoading={this.isLoading()}
path="/m/:conversation_id"
path="m/:conversation_id"
authed={this.isAuthed()}
component={ConversationAdminContainer}
/>
</InteriorHeader>
</Switch>
</Routes>
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ModerateCommentsTodo from './moderate-comments-todo'
import ModerateCommentsAccepted from './moderate-comments-accepted'
import ModerateCommentsRejected from './moderate-comments-rejected'

import { Switch, Route, Link } from 'react-router-dom'
import { Routes, Route, Link } from 'react-router-dom'

const mapStateToProps = (state, ownProps) => {
return {
Expand Down Expand Up @@ -103,7 +103,7 @@ class CommentModeration extends React.Component {
</Link>
</Flex>
<Box>
<Switch>
<Routes>
<Route
exact
path={`${match.url}`}
Expand All @@ -119,7 +119,7 @@ class CommentModeration extends React.Component {
path={`${match.url}/rejected`}
component={ModerateCommentsRejected}
/>
</Switch>
</Routes>
</Box>
</Box>
)
Expand Down
6 changes: 3 additions & 3 deletions client-admin/src/components/conversation-admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import { connect } from 'react-redux'
import { Flex, Box, jsx } from 'theme-ui'
import { populateZidMetadataStore, resetMetadataStore } from '../../actions'
import { Switch, Route, Link } from 'react-router-dom'
import { Route, Link, Routes } from 'react-router-dom'

import ConversationConfig from './conversation-config'
import ConversationStats from './stats'
Expand Down Expand Up @@ -99,7 +99,7 @@ class ConversationAdminContainer extends React.Component {
</Box>
</Box>
<Box sx={{ p: [4], flex: '0 0 auto', maxWidth: '35em', mx: [4] }}>
<Switch>
<Routes>
<Route
exact
path={`${match.path}/`}
Expand All @@ -121,7 +121,7 @@ class ConversationAdminContainer extends React.Component {
component={ConversationStats}
/>
{/* <Route exact path={`${match.path}/export`} component={DataExport} /> */}
</Switch>
</Routes>
</Box>
</Flex>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
import React from 'react'

import ReportsList from './reports-list'
import { Switch, Route } from 'react-router-dom'

class Reports extends React.Component {
render() {
return (
<div>
<Switch>
<Route exact component={ReportsList} />
</Switch>
<ReportsList />
</div>
)
}
Expand Down
4 changes: 2 additions & 2 deletions client-admin/src/components/landers/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import React from 'react'
import { connect } from 'react-redux'
import { doSignin, doFacebookSignin } from '../../actions'
import { Link, Redirect } from 'react-router-dom'
import { Link, Navigate } from 'react-router-dom'
import { Heading, Box, Text, Button, jsx } from 'theme-ui'
import StaticLayout from './lander-layout'

Expand Down Expand Up @@ -171,7 +171,7 @@ class SignIn extends React.Component {
const { signInSuccessful, authed } = this.props

if (signInSuccessful || authed) {
return <Redirect to={'/'} />
return <Navigate to={'/'} />
}

return (
Expand Down

0 comments on commit e7b1529

Please sign in to comment.