From 491ea7dc1d94e568b7ba923f38e2fc4059cc7318 Mon Sep 17 00:00:00 2001 From: Eric Gauzens Date: Sat, 22 Jun 2024 19:14:22 -0400 Subject: [PATCH 1/4] fixed history stack when internally redirecting --- pages/about/[aboutDetailsId].vue | 3 ++- pages/about/get-involved/[id].vue | 3 ++- pages/about/sparc-portal/metrics/index.vue | 3 ++- pages/about/team-and-leadership/[id].vue | 3 ++- pages/about/what-we-offer/[id].vue | 3 ++- pages/data/index.vue | 3 ++- pages/maps/index.vue | 3 ++- pages/news-and-events/community-spotlight/submit/index.vue | 5 +++-- .../community-spotlight/success-stories/index.vue | 3 ++- pages/news-and-events/submit/index.vue | 5 +++-- pages/projects/[projectId].vue | 3 ++- pages/resources/[resourceId].vue | 3 ++- 12 files changed, 26 insertions(+), 14 deletions(-) diff --git a/pages/about/[aboutDetailsId].vue b/pages/about/[aboutDetailsId].vue index d4be84ff..5f594d7d 100644 --- a/pages/about/[aboutDetailsId].vue +++ b/pages/about/[aboutDetailsId].vue @@ -88,7 +88,8 @@ export default { return await $contentfulClient.getEntry(params.aboutDetailsId).then(async (response) => { const slug = pathOr("", ['fields', 'slug'], response) if (!isEmpty(slug)) { - await navigateTo(`/about/${slug}`) + const router = useRouter() + await router.replace({ path: `/about/${slug}` }) } return response }) diff --git a/pages/about/get-involved/[id].vue b/pages/about/get-involved/[id].vue index 0a10c98c..0e64810c 100644 --- a/pages/about/get-involved/[id].vue +++ b/pages/about/get-involved/[id].vue @@ -3,7 +3,8 @@ export default { async setup() { const route = useRoute() const newPath = route.href.replace('/about/get-involved', '/about') - await navigateTo(newPath, { redirectCode: 301 }) + const router = useRouter() + await router.replace({ path: newPath }) } } diff --git a/pages/about/sparc-portal/metrics/index.vue b/pages/about/sparc-portal/metrics/index.vue index bf2ad234..6d95863b 100644 --- a/pages/about/sparc-portal/metrics/index.vue +++ b/pages/about/sparc-portal/metrics/index.vue @@ -3,7 +3,8 @@ export default { name: 'MetricsPage', async setup() { - await navigateTo("/about/metrics", { redirectCode: 301 }) + const router = useRouter() + await router.replace({ path: "/about/metrics" }) }, } diff --git a/pages/about/team-and-leadership/[id].vue b/pages/about/team-and-leadership/[id].vue index 3103d898..e4b7aebe 100644 --- a/pages/about/team-and-leadership/[id].vue +++ b/pages/about/team-and-leadership/[id].vue @@ -3,7 +3,8 @@ export default { async setup() { const route = useRoute() const newPath = route.href.replace('/about/team-and-leadership', '/about') - await navigateTo(newPath, { redirectCode: 301 }) + const router = useRouter() + await router.replace({ path: newPath }) } } diff --git a/pages/about/what-we-offer/[id].vue b/pages/about/what-we-offer/[id].vue index 69def0f0..d087f20c 100644 --- a/pages/about/what-we-offer/[id].vue +++ b/pages/about/what-we-offer/[id].vue @@ -3,7 +3,8 @@ export default { async setup() { const route = useRoute() const newPath = route.href.replace('/about/what-we-offer', '/about') - await navigateTo(newPath, { redirectCode: 301 }) + const router = useRouter() + await router.replace({ path: newPath }) } } diff --git a/pages/data/index.vue b/pages/data/index.vue index 1353c677..e79093c6 100644 --- a/pages/data/index.vue +++ b/pages/data/index.vue @@ -170,7 +170,8 @@ export default { if (focusQuery) { newPath += `&selectedProjectsAnatomicalFocusIds=${focusQuery}` } - return navigateTo(newPath) + const router = useRouter() + await router.replace({ path: newPath }) } const { $algoliaClient } = useNuxtApp() const algoliaSortOptions = [ diff --git a/pages/maps/index.vue b/pages/maps/index.vue index 92ac1ba9..a028c270 100644 --- a/pages/maps/index.vue +++ b/pages/maps/index.vue @@ -12,7 +12,8 @@ export default { } else { newPath = route.href.replace('/maps', '/apps/maps') } - await navigateTo(newPath, { redirectCode: 301 }) + const router = useRouter() + await router.replace({ path: newPath }) } } diff --git a/pages/news-and-events/community-spotlight/submit/index.vue b/pages/news-and-events/community-spotlight/submit/index.vue index 454f856a..faa0ed45 100644 --- a/pages/news-and-events/community-spotlight/submit/index.vue +++ b/pages/news-and-events/community-spotlight/submit/index.vue @@ -1,7 +1,8 @@ diff --git a/pages/news-and-events/community-spotlight/success-stories/index.vue b/pages/news-and-events/community-spotlight/success-stories/index.vue index 3bf43ed6..a925484f 100644 --- a/pages/news-and-events/community-spotlight/success-stories/index.vue +++ b/pages/news-and-events/community-spotlight/success-stories/index.vue @@ -1,7 +1,8 @@ \ No newline at end of file diff --git a/pages/news-and-events/submit/index.vue b/pages/news-and-events/submit/index.vue index 454f856a..faa0ed45 100644 --- a/pages/news-and-events/submit/index.vue +++ b/pages/news-and-events/submit/index.vue @@ -1,7 +1,8 @@ diff --git a/pages/projects/[projectId].vue b/pages/projects/[projectId].vue index 9d7a3159..cf274078 100644 --- a/pages/projects/[projectId].vue +++ b/pages/projects/[projectId].vue @@ -2,8 +2,9 @@ export default { async setup() { const route = useRoute() + const router = useRouter() const newPath = route.href.replace('/projects', '/about/projects') - await navigateTo(newPath, { redirectCode: 301 }) + await router.replace({ path: newPath }) }, } diff --git a/pages/resources/[resourceId].vue b/pages/resources/[resourceId].vue index 1d6e57a1..97751a57 100644 --- a/pages/resources/[resourceId].vue +++ b/pages/resources/[resourceId].vue @@ -2,8 +2,9 @@ export default { async setup() { const route = useRoute() + const router = useRouter() const newPath = route.href.replace('/resources/', '/tools-and-resources/') - await navigateTo(newPath, { redirectCode: 301 }) + await router.replace({ path: newPath }) }, } From c1345e7ea15e54d660de288763a93108bfaf842a Mon Sep 17 00:00:00 2001 From: Eric Gauzens Date: Sat, 22 Jun 2024 20:20:35 -0400 Subject: [PATCH 2/4] linter fix --- .../community-spotlight/success-stories/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/news-and-events/community-spotlight/success-stories/index.vue b/pages/news-and-events/community-spotlight/success-stories/index.vue index a925484f..07562441 100644 --- a/pages/news-and-events/community-spotlight/success-stories/index.vue +++ b/pages/news-and-events/community-spotlight/success-stories/index.vue @@ -5,4 +5,4 @@ export default { await router.replace({ path: "/news-and-events/community-spotlight?selectedSpotlightTypes=successStory" }) } } - \ No newline at end of file + From 6ae4d321351f0ae968292ce894f9d4564989c8b1 Mon Sep 17 00:00:00 2001 From: Eric Gauzens Date: Fri, 28 Jun 2024 13:17:23 -0400 Subject: [PATCH 3/4] removed await which was causing failing tests --- pages/maps/index.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/maps/index.vue b/pages/maps/index.vue index a028c270..860b781a 100644 --- a/pages/maps/index.vue +++ b/pages/maps/index.vue @@ -2,7 +2,7 @@ import { pathOr, isEmpty } from 'ramda' import { infoMessage } from '@/utils/notification-messages' export default { - async setup() { + setup() { const route = useRoute() const emptyParam = pathOr('', ['query'], route) let newPath = '' @@ -13,7 +13,7 @@ export default { newPath = route.href.replace('/maps', '/apps/maps') } const router = useRouter() - await router.replace({ path: newPath }) + router.replace({ path: newPath }) } } From 9ca60338c6335f5263b2ceac17aee5bf38119c9f Mon Sep 17 00:00:00 2001 From: Eric Gauzens Date: Fri, 28 Jun 2024 14:41:14 -0400 Subject: [PATCH 4/4] Fixed remaining issue discovered by failing tests --- pages/maps/index.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/maps/index.vue b/pages/maps/index.vue index 860b781a..1469a475 100644 --- a/pages/maps/index.vue +++ b/pages/maps/index.vue @@ -4,16 +4,16 @@ import { infoMessage } from '@/utils/notification-messages' export default { setup() { const route = useRoute() - const emptyParam = pathOr('', ['query'], route) + const query = pathOr('', ['query'], route) let newPath = '' - if (isEmpty(emptyParam)) { + if (isEmpty(query)) { newPath = route.href.replace('/maps', '/apps') infoMessage('All available map viewers have now been integrated with SPARC Apps and can be found below!') } else { - newPath = route.href.replace('/maps', '/apps/maps') + newPath = route.href.replace('/maps', `/apps/maps?${query}`) } const router = useRouter() - router.replace({ path: newPath }) + router.replace({ path: newPath, query: query }) } }