From 52041c578e3fe1101257171467a3261aca04e5a0 Mon Sep 17 00:00:00 2001 From: ezwelty Date: Tue, 27 Dec 2022 09:44:47 +0100 Subject: [PATCH] Replace /entry path with existing /locations - /entry/:id -> /locations/:id - /entry/new -> /locations/new - /entry/edit -> /locations/edit See #246. --- src/components/desktop/MainPane.js | 2 +- src/components/desktop/NavBack.js | 8 +++---- src/components/desktop/SidePaneSwitch.js | 6 ++--- src/components/entry/EntryMobile.js | 4 ++-- src/components/entry/EntryOverview.js | 4 ++-- src/components/entry/ReviewButton.js | 2 +- src/components/form/EditableForm.js | 2 +- src/components/form/LocationForm.js | 5 ++-- src/components/form/LocationNav.js | 14 +++++------ src/components/list/InfiniteList.js | 2 +- src/components/list/PagedList.js | 2 +- src/components/map/MapPage.js | 6 ++--- src/components/mobile/MobileLayout.js | 30 +++++++++++++----------- src/components/mobile/TopBarSwitch.js | 8 +++---- src/utils/getInitialUrl.js | 2 +- src/utils/useRoutedTabs.js | 2 +- 16 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/components/desktop/MainPane.js b/src/components/desktop/MainPane.js index 397b3dfa..a30d54f3 100644 --- a/src/components/desktop/MainPane.js +++ b/src/components/desktop/MainPane.js @@ -36,7 +36,7 @@ const MainPane = () => { secondary onClick={() => history.push({ - pathname: '/entry/new', + pathname: '/locations/new', state: { fromPage: '/map' }, }) } diff --git a/src/components/desktop/NavBack.js b/src/components/desktop/NavBack.js index 5c7ff35a..b254e8a4 100644 --- a/src/components/desktop/NavBack.js +++ b/src/components/desktop/NavBack.js @@ -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 { @@ -46,7 +46,7 @@ const NavBack = ({ isEntry }) => { {t('Back')} {isEntry && match && !isEditingEntry && ( - history.push(`/entry/${entryId}/edit`)}> + history.push(`/locations/${entryId}/edit`)}> Edit diff --git a/src/components/desktop/SidePaneSwitch.js b/src/components/desktop/SidePaneSwitch.js index 9ba9cf17..c0596e78 100644 --- a/src/components/desktop/SidePaneSwitch.js +++ b/src/components/desktop/SidePaneSwitch.js @@ -15,19 +15,19 @@ const SidePaneSwitch = () => ( - + - + - + diff --git a/src/components/entry/EntryMobile.js b/src/components/entry/EntryMobile.js index 929f0db4..7fe25755 100644 --- a/src/components/entry/EntryMobile.js +++ b/src/components/entry/EntryMobile.js @@ -299,7 +299,7 @@ const EntryMobile = ({ {!isInDrawer && ( - history.push(`/entry/${locationData.id}`, { + history.push(`/locations/${locationData.id}`, { fromPage: '/map', }) } @@ -308,7 +308,7 @@ const EntryMobile = ({ /> )} history.push(`/entry/${locationData.id}/edit`)} + onClick={() => history.push(`/locations/${locationData.id}/edit`)} icon={} label="edit-button" /> diff --git a/src/components/entry/EntryOverview.js b/src/components/entry/EntryOverview.js index beb65646..22b256b9 100644 --- a/src/components/entry/EntryOverview.js +++ b/src/components/entry/EntryOverview.js @@ -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 @@ -158,7 +158,7 @@ const EntryOverview = ({ locationData, className }) => { {locationData.author} diff --git a/src/components/entry/ReviewButton.js b/src/components/entry/ReviewButton.js index 3df26761..89dc1321 100644 --- a/src/components/entry/ReviewButton.js +++ b/src/components/entry/ReviewButton.js @@ -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} diff --git a/src/components/form/EditableForm.js b/src/components/form/EditableForm.js index 9172ea1e..b6a58a5c 100644 --- a/src/components/form/EditableForm.js +++ b/src/components/form/EditableForm.js @@ -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} /> ) diff --git a/src/components/form/LocationForm.js b/src/components/form/LocationForm.js index 126b90b7..489c5b44 100644 --- a/src/components/form/LocationForm.js +++ b/src/components/form/LocationForm.js @@ -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, @@ -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') } diff --git a/src/components/form/LocationNav.js b/src/components/form/LocationNav.js index 47f17c98..051de1e6 100644 --- a/src/components/form/LocationNav.js +++ b/src/components/form/LocationNav.js @@ -20,30 +20,30 @@ const LocationNav = () => { {({ match }) => ( // TODO: fix going back to correct entry id history.push(`/entry/${match.params.id}`)} + onBack={() => history.push(`/locations/${match.params.id}`)} title="Editing Review" /> )} - + {({ match }) => ( history.push(`/entry/${match.params.id}`)} + onBack={() => history.push(`/locations/${match.params.id}`)} title="Adding Review" /> )} - + {({ match }) => ( history.push(`/entry/${match.params.id}`)} + onBack={() => history.push(`/locations/${match.params.id}`)} title="Editing Location" /> )} - + history.push('/entry/new')} + onBack={() => history.push('/locations/new')} title="New Location" /> diff --git a/src/components/list/InfiniteList.js b/src/components/list/InfiniteList.js index e624044e..f1980bd2 100644 --- a/src/components/list/InfiniteList.js +++ b/src/components/list/InfiniteList.js @@ -20,7 +20,7 @@ const InfiniteList = ({ const handleEntryClick = (id) => { history.push({ - pathname: `/entry/${id}`, + pathname: `/locations/${id}`, state: { fromPage: '/list' }, }) } diff --git a/src/components/list/PagedList.js b/src/components/list/PagedList.js index 21f6f38f..bc0a25c2 100644 --- a/src/components/list/PagedList.js +++ b/src/components/list/PagedList.js @@ -62,7 +62,7 @@ const PagedList = () => { const handleEntryClick = (id) => { history.push({ - pathname: `/entry/${id}`, + pathname: `/locations/${id}`, state: { fromPage: '/list' }, }) dispatch(setHoveredLocationId(null)) diff --git a/src/components/map/MapPage.js b/src/components/map/MapPage.js index 3889bb44..e063ac2f 100644 --- a/src/components/map/MapPage.js +++ b/src/components/map/MapPage.js @@ -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' @@ -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 ( diff --git a/src/components/mobile/MobileLayout.js b/src/components/mobile/MobileLayout.js index e1ff65b9..9ee91004 100644 --- a/src/components/mobile/MobileLayout.js +++ b/src/components/mobile/MobileLayout.js @@ -68,24 +68,26 @@ const MobileLayout = () => { )} - + {({ match }) => ( history.push(`/entry/${match.params.id}`)} + onSubmit={() => history.push(`/locations/${match.params.id}`)} /> )} - + {({ match }) => } - + - + - - {!streetView && } + + + {!streetView && } + @@ -105,12 +107,12 @@ const MobileLayout = () => { - + {(pathname.includes('/map') || !isFromList) && } @@ -118,9 +120,9 @@ const MobileLayout = () => { diff --git a/src/components/mobile/TopBarSwitch.js b/src/components/mobile/TopBarSwitch.js index 864090fc..5562eba0 100644 --- a/src/components/mobile/TopBarSwitch.js +++ b/src/components/mobile/TopBarSwitch.js @@ -24,16 +24,16 @@ const TopBarSwitch = () => { - {isFromList && } + {isFromList && } diff --git a/src/utils/getInitialUrl.js b/src/utils/getInitialUrl.js index 0aae73a6..f1860c62 100644 --- a/src/utils/getInitialUrl.js +++ b/src/utils/getInitialUrl.js @@ -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) { diff --git a/src/utils/useRoutedTabs.js b/src/utils/useRoutedTabs.js index 6a065326..4843be72 100644 --- a/src/utils/useRoutedTabs.js +++ b/src/utils/useRoutedTabs.js @@ -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' } })