Skip to content

Commit

Permalink
Replace /entry path with existing /locations
Browse files Browse the repository at this point in the history
- /entry/:id -> /locations/:id
- /entry/new -> /locations/new
- /entry/edit -> /locations/edit

See #246.
  • Loading branch information
ezwelty committed Dec 27, 2022
1 parent 0cc063a commit 52041c5
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/components/desktop/MainPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const MainPane = () => {
secondary
onClick={() =>
history.push({
pathname: '/entry/new',
pathname: '/locations/new',
state: { fromPage: '/map' },
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/desktop/NavBack.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const NavBack = ({ isEntry }) => {
const history = useAppHistory()
const { state } = useLocation()
const { t } = useTranslation()
const match = useRouteMatch('/entry/:id')
const match = useRouteMatch('/locations/:id')
const entryId = match?.params.id

const isEditingEntry = useRouteMatch('/entry/:id/edit')
const isEditingEntry = useRouteMatch('/locations/:id/edit')

const handleBackButtonClick = () => {
// Default to going back to the map. This occurs when the user opens /entry/{typeId} directly
// Default to going back to the map. This occurs when the user opens /locations/:id directly
if (isEditingEntry) {
history.push(match.url)
} else {
Expand All @@ -46,7 +46,7 @@ const NavBack = ({ isEntry }) => {
{t('Back')}
</BackButton>
{isEntry && match && !isEditingEntry && (
<BackButton onClick={() => history.push(`/entry/${entryId}/edit`)}>
<BackButton onClick={() => history.push(`/locations/${entryId}/edit`)}>
<Pencil />
Edit
</BackButton>
Expand Down
6 changes: 3 additions & 3 deletions src/components/desktop/SidePaneSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ const SidePaneSwitch = () => (
<Route>
<NavPane>
<Switch>
<Route path="/entry/:id/edit">
<Route path="/locations/:id/edit">
<EditLocationPage />
</Route>
<Route path="/review/:id/edit">
<EditReviewPage />
</Route>
<Route path="/entry/new">
<Route path="/locations/new">
<LocationForm />
</Route>
<Route path="/settings">
<SettingsPage desktop />
</Route>
<Route path={['/entry/:id', '/entry/:id']}>
<Route path={['/locations/:id', '/locations/:id']}>
<EntryWrapper desktop />
</Route>
<Route>
Expand Down
4 changes: 2 additions & 2 deletions src/components/entry/EntryMobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const EntryMobile = ({
{!isInDrawer && (
<EntryButton
onClick={() =>
history.push(`/entry/${locationData.id}`, {
history.push(`/locations/${locationData.id}`, {
fromPage: '/map',
})
}
Expand All @@ -308,7 +308,7 @@ const EntryMobile = ({
/>
)}
<EntryButton
onClick={() => history.push(`/entry/${locationData.id}/edit`)}
onClick={() => history.push(`/locations/${locationData.id}/edit`)}
icon={<PencilIcon />}
label="edit-button"
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/entry/EntryOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const EntryOverview = ({ locationData, className }) => {

const handleStreetView = () => {
if (!isDesktop) {
history.push(`/entry/${locationData.id}`, { fromPage: '/map' })
history.push(`/locations/${locationData.id}`, { fromPage: '/map' })
}

// TODO: change setTimeout to make it wait for map component to mount
Expand Down Expand Up @@ -158,7 +158,7 @@ const EntryOverview = ({ locationData, className }) => {
<Link
to={{
pathname: `/imports/${locationData.import_id}`,
state: { fromPage: `/entry/${locationData.id}` },
state: { fromPage: `/locations/${locationData.id}` },
}}
>
{locationData.author}
Expand Down
2 changes: 1 addition & 1 deletion src/components/entry/ReviewButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const ReviewButton = (props) => {
window.location.hash = ''
window.location.hash = 'review'
} else {
history.push(`/entry/${id}/review`)
history.push(`/locations/${id}/review`)
}
}}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/EditableForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const EditReviewForm = (props) => (
convertFormData={(review) => ({
review: reviewToForm(review),
})}
getRedirectLink={(review) => `/entry/${review.location_id}`}
getRedirectLink={(review) => `/locations/${review.location_id}`}
{...props}
/>
)
Expand Down
5 changes: 3 additions & 2 deletions src/components/form/LocationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ export const LocationForm = ({
]),
]

onSubmit = onSubmit ?? ((response) => history.push(`/entry/${response.id}`))
onSubmit =
onSubmit ?? ((response) => history.push(`/locations/${response.id}`))
const handleSubmit = async ({
'g-recaptcha-response': recaptcha,
review,
Expand Down Expand Up @@ -342,7 +343,7 @@ export const LocationForm = ({
onClick={(e) => {
e.stopPropagation()
if (editingId) {
history.push(`/entry/${editingId}`)
history.push(`/locations/${editingId}`)
} else {
history.push(state?.fromPage ?? '/map')
}
Expand Down
14 changes: 7 additions & 7 deletions src/components/form/LocationNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,30 @@ const LocationNav = () => {
{({ match }) => (
// TODO: fix going back to correct entry id
<TopBarNav
onBack={() => history.push(`/entry/${match.params.id}`)}
onBack={() => history.push(`/locations/${match.params.id}`)}
title="Editing Review"
/>
)}
</Route>
<Route path="/entry/:id/review">
<Route path="/locations/:id/review">
{({ match }) => (
<TopBarNav
onBack={() => history.push(`/entry/${match.params.id}`)}
onBack={() => history.push(`/locations/${match.params.id}`)}
title="Adding Review"
/>
)}
</Route>
<Route path="/entry/:id/edit">
<Route path="/locations/:id/edit">
{({ match }) => (
<TopBarNav
onBack={() => history.push(`/entry/${match.params.id}`)}
onBack={() => history.push(`/locations/${match.params.id}`)}
title="Editing Location"
/>
)}
</Route>
<Route path="/entry/new/details">
<Route path="/locations/new/details">
<TopBarNav
onBack={() => history.push('/entry/new')}
onBack={() => history.push('/locations/new')}
title="New Location"
/>
</Route>
Expand Down
2 changes: 1 addition & 1 deletion src/components/list/InfiniteList.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const InfiniteList = ({

const handleEntryClick = (id) => {
history.push({
pathname: `/entry/${id}`,
pathname: `/locations/${id}`,
state: { fromPage: '/list' },
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/list/PagedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const PagedList = () => {

const handleEntryClick = (id) => {
history.push({
pathname: `/entry/${id}`,
pathname: `/locations/${id}`,
state: { fromPage: '/list' },
})
dispatch(setHoveredLocationId(null))
Expand Down
6 changes: 3 additions & 3 deletions src/components/map/MapPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const BottomLeftLoadingIndicator = styled(LoadingIndicator)`
const MapPage = ({ isDesktop }) => {
const history = useAppHistory()
const match = useRouteMatch({
path: '/entry/:entryId',
path: '/locations/:entryId',
})

const isAddingLocation = match?.params.entryId === 'new'
Expand Down Expand Up @@ -57,13 +57,13 @@ const MapPage = ({ isDesktop }) => {

const handleLocationClick = (location) => {
history.push({
pathname: `/entry/${location.id}`,
pathname: `/locations/${location.id}`,
state: { fromPage: '/map' },
})
}

const handleAddLocationClick = () => {
history.push('/entry/new')
history.push('/locations/new')
}

return (
Expand Down
30 changes: 16 additions & 14 deletions src/components/mobile/MobileLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,26 @@ const MobileLayout = () => {
<EditReviewForm stepped editingId={match.params.id} />
)}
</Route>
<Route path="/entry/:id/review">
<Route path="/locations/:id/review">
{({ match }) => (
<ReviewForm
stepped
onSubmit={() => history.push(`/entry/${match.params.id}`)}
onSubmit={() => history.push(`/locations/${match.params.id}`)}
/>
)}
</Route>
<Route path="/entry/:id/edit">
<Route path="/locations/:id/edit">
{({ match }) => <EditLocationForm editingId={match.params.id} />}
</Route>
<Route path="/entry/new/details">
<Route path="/locations/new/details">
<LocationForm />
</Route>
<Route path={['/map', '/entry', '/list', '/settings']}>
<Route path={['/map', '/locations', '/list', '/settings']}>
<Switch>
<Route path="/entry/new" />
<Route path="/entry/:id">{!streetView && <EntryWrapper />}</Route>
<Route path="/locations/new" />
<Route path="/locations/:id">
{!streetView && <EntryWrapper />}
</Route>
</Switch>
<Switch>
<Route path="/list">
Expand All @@ -105,22 +107,22 @@ const MobileLayout = () => {
<Route
path={[
'/review/:id/edit',
'/entry/:id/review',
'/entry/:id/edit',
'/entry/new/details',
'/locations/:id/review',
'/locations/:id/edit',
'/locations/new/details',
]}
/>
<Route path={['/map', '/entry']}>
<Route path={['/map', '/locations']}>
{(pathname.includes('/map') || !isFromList) && <MapPage />}
</Route>
</Switch>
<Switch>
<Route
path={[
'/review/:id/edit',
'/entry/:id/review',
'/entry/:id/edit',
'/entry/new/details',
'/locations/:id/review',
'/locations/:id/edit',
'/locations/new/details',
]}
/>
<Route>
Expand Down
8 changes: 4 additions & 4 deletions src/components/mobile/TopBarSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ const TopBarSwitch = () => {
<Route
path={[
'/review/:id/edit',
'/entry/:id/review',
'/entry/:id/edit',
'/entry/new',
'/locations/:id/review',
'/locations/:id/edit',
'/locations/new',
]}
>
<TopBar>
<LocationNav />
</TopBar>
</Route>
{isFromList && <Route path="/entry/:id" />}
{isFromList && <Route path="/locations/:id" />}
<Route>
<TopBar>
<Search />
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getInitialUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const parseUrl = () => {
const { pathname } = window.location
const geocoordMatch = pathname.substring(pathname.indexOf('@'))

const isEntryPage = !!matchPath(pathname, '/entry/:id')
const isEntryPage = !!matchPath(pathname, '/locations/:id')
const coords = getValidCoord(geocoordMatch)

if (coords) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/useRoutedTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const useRoutedTabs = (tabPaths, defaultTabIndex = 0) => {
if (
// TODO: remove this edge case when refactoring Reach Tabs into NavLinks
tabIndex === 0 &&
pathname.includes('/entry') &&
pathname.includes('/locations') &&
state?.fromPage === '/list'
) {
history.push(pathname, { state: { fromPage: '/map' } })
Expand Down

0 comments on commit 52041c5

Please sign in to comment.