From 89e8c117b9648c684c09dd58a9a3c4d1b47bff78 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Mon, 14 Oct 2024 11:47:34 -0700 Subject: [PATCH 1/3] When autolaunching an instant launch, redirect to the analysis landing page --- .../instantlaunches/InstantLaunchButtonWrapper.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/instantlaunches/InstantLaunchButtonWrapper.js b/src/components/instantlaunches/InstantLaunchButtonWrapper.js index 3886f7636..91fa36fac 100644 --- a/src/components/instantlaunches/InstantLaunchButtonWrapper.js +++ b/src/components/instantlaunches/InstantLaunchButtonWrapper.js @@ -12,6 +12,10 @@ import React, { useEffect, useCallback } from "react"; import { useMutation } from "react-query"; +import { useRouter } from "next/router"; + +import NavigationConstants from "common/NavigationConstants"; + import { useDefaultOutputDir } from "components/data/utils"; import withErrorAnnouncer from "components/error/withErrorAnnouncer"; import { getHost } from "components/utils/getHost"; @@ -52,6 +56,7 @@ function InstantLaunchButtonWrapper(props) { const [runErrorDetails, setRunErrorDetails] = React.useState(null); const [ilUrl, setIlUrl] = React.useState(); + const router = useRouter(); const { t } = useTranslation("launch"); React.useEffect(() => { @@ -75,6 +80,12 @@ function InstantLaunchButtonWrapper(props) { } else { setOpen(false); } + if (autolaunch) { + // go to the analysis landing + router.push( + `/${NavigationConstants.ANALYSES}/${analysis?.id}` + ); + } } else { setOpen(false); } From 656e2f26d47437e817a3b0bb0cd6add4cfd3763a Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Mon, 14 Oct 2024 12:46:18 -0700 Subject: [PATCH 2/3] Use router.replace so the autolaunched instant launch page doesn't remain in history --- src/components/instantlaunches/InstantLaunchButtonWrapper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/instantlaunches/InstantLaunchButtonWrapper.js b/src/components/instantlaunches/InstantLaunchButtonWrapper.js index 91fa36fac..119d61f25 100644 --- a/src/components/instantlaunches/InstantLaunchButtonWrapper.js +++ b/src/components/instantlaunches/InstantLaunchButtonWrapper.js @@ -81,8 +81,8 @@ function InstantLaunchButtonWrapper(props) { setOpen(false); } if (autolaunch) { - // go to the analysis landing - router.push( + // go to the analysis landing, not keeping this page in browser history + router.replace( `/${NavigationConstants.ANALYSES}/${analysis?.id}` ); } From ed3d4059b1b01f5f722b3a686483a3133a89f99b Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Mon, 14 Oct 2024 16:09:07 -0700 Subject: [PATCH 3/3] Set a landingUrl state value and move the autolaunch navigation into the useEffect after opening the VICE analysis URL --- .../InstantLaunchButtonWrapper.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/instantlaunches/InstantLaunchButtonWrapper.js b/src/components/instantlaunches/InstantLaunchButtonWrapper.js index 119d61f25..5016dde90 100644 --- a/src/components/instantlaunches/InstantLaunchButtonWrapper.js +++ b/src/components/instantlaunches/InstantLaunchButtonWrapper.js @@ -55,22 +55,30 @@ function InstantLaunchButtonWrapper(props) { React.useState(false); const [runErrorDetails, setRunErrorDetails] = React.useState(null); const [ilUrl, setIlUrl] = React.useState(); + const [landingUrl, setLandingUrl] = React.useState(); const router = useRouter(); const { t } = useTranslation("launch"); React.useEffect(() => { - if (ilUrl) { + if (ilUrl && landingUrl) { window.open(`${getHost()}${ilUrl}`); setIlUrl(null); setOpen(false); + if (autolaunch) { + // go to the analysis landing, not keeping this page in browser history + router.replace(landingUrl); + } } - }, [ilUrl]); + }, [ilUrl, landingUrl, autolaunch, router]); const { mutate: launch } = useMutation(instantlyLaunch, { onSuccess: (listing) => { if (listing.analyses.length > 0) { const analysis = listing.analyses[0]; + setLandingUrl( + `/${NavigationConstants.ANALYSES}/${analysis?.id}` + ); if (analysis.interactive_urls?.length > 0) { setIlUrl( `${constants.VICE_LOADING_PAGE}/${encodeURIComponent( @@ -80,12 +88,6 @@ function InstantLaunchButtonWrapper(props) { } else { setOpen(false); } - if (autolaunch) { - // go to the analysis landing, not keeping this page in browser history - router.replace( - `/${NavigationConstants.ANALYSES}/${analysis?.id}` - ); - } } else { setOpen(false); }