From 78a1d23130ed1cb206009c1cb5567daf3fd6831a Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Wed, 4 Dec 2024 09:45:13 -0700 Subject: [PATCH 1/3] Make the standalone instant launch page show errors immediately, not behind a button --- .../instantlaunches/launch/index.js | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/components/instantlaunches/launch/index.js b/src/components/instantlaunches/launch/index.js index 1ae5f7f2a..c974e70d2 100644 --- a/src/components/instantlaunches/launch/index.js +++ b/src/components/instantlaunches/launch/index.js @@ -3,10 +3,12 @@ * * The component that launches a provided instant launch, immediately. */ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { useQuery } from "react-query"; +import { useRouter } from "next/router"; + import { GET_INSTANT_LAUNCH_FULL_KEY, getFullInstantLaunch, @@ -26,7 +28,7 @@ import InstantLaunchButtonWrapper from "components/instantlaunches/InstantLaunch import withErrorAnnouncer from "components/error/withErrorAnnouncer"; import LoadingAnimation from "components/vice/loading/LoadingAnimation"; -import ErrorTypographyWithDialog from "components/error/ErrorTypographyWithDialog"; +import DEErrorDialog from "components/error/DEErrorDialog"; const InstantLaunchStandalone = (props) => { const { @@ -40,7 +42,10 @@ const InstantLaunchStandalone = (props) => { !!config?.subscriptions?.enforce ); const [resource, setResource] = useState(null); + const [errDialogOpen, setErrDialogOpen] = useState(false); + const [dialogError, setDialogError] = useState(null); + const router = useRouter(); const { t } = useTranslation(["instantlaunches", "common"]); const { data, status, error } = useQuery( @@ -81,14 +86,24 @@ const InstantLaunchStandalone = (props) => { isFetchingUsageSummary, ]); + useEffect(() => { + if (error || resourceError) { + setDialogError(error || resourceError); + setErrDialogOpen(true); + } + }, [error, resourceError, setErrDialogOpen, setDialogError]); + if (isLoading) { return ; } else if (error || resourceError) { - const err = error || resourceError; return ( - { + setErrDialogOpen(false); + router.push("/"); + }} /> ); } else { From a3c80926d942db9a69e05fbed4f1e11ca4a0acb4 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Thu, 5 Dec 2024 09:22:09 -0700 Subject: [PATCH 2/3] Use WrappedErrorHandler instead --- .../instantlaunches/launch/index.js | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/components/instantlaunches/launch/index.js b/src/components/instantlaunches/launch/index.js index c974e70d2..406507026 100644 --- a/src/components/instantlaunches/launch/index.js +++ b/src/components/instantlaunches/launch/index.js @@ -3,12 +3,10 @@ * * The component that launches a provided instant launch, immediately. */ -import React, { useState, useEffect } from "react"; +import React, { useState } from "react"; import { useQuery } from "react-query"; -import { useRouter } from "next/router"; - import { GET_INSTANT_LAUNCH_FULL_KEY, getFullInstantLaunch, @@ -28,7 +26,7 @@ import InstantLaunchButtonWrapper from "components/instantlaunches/InstantLaunch import withErrorAnnouncer from "components/error/withErrorAnnouncer"; import LoadingAnimation from "components/vice/loading/LoadingAnimation"; -import DEErrorDialog from "components/error/DEErrorDialog"; +import WrappedErrorHandler from "components/error/WrappedErrorHandler"; const InstantLaunchStandalone = (props) => { const { @@ -42,10 +40,7 @@ const InstantLaunchStandalone = (props) => { !!config?.subscriptions?.enforce ); const [resource, setResource] = useState(null); - const [errDialogOpen, setErrDialogOpen] = useState(false); - const [dialogError, setDialogError] = useState(null); - const router = useRouter(); const { t } = useTranslation(["instantlaunches", "common"]); const { data, status, error } = useQuery( @@ -86,26 +81,10 @@ const InstantLaunchStandalone = (props) => { isFetchingUsageSummary, ]); - useEffect(() => { - if (error || resourceError) { - setDialogError(error || resourceError); - setErrDialogOpen(true); - } - }, [error, resourceError, setErrDialogOpen, setDialogError]); - if (isLoading) { return ; } else if (error || resourceError) { - return ( - { - setErrDialogOpen(false); - router.push("/"); - }} - /> - ); + return ; } else { return ( Date: Mon, 9 Dec 2024 11:07:49 -0700 Subject: [PATCH 3/3] Add some sort of base ID to the error handler --- src/components/instantlaunches/launch/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/instantlaunches/launch/index.js b/src/components/instantlaunches/launch/index.js index 406507026..9b2548951 100644 --- a/src/components/instantlaunches/launch/index.js +++ b/src/components/instantlaunches/launch/index.js @@ -21,6 +21,7 @@ import { useConfig } from "contexts/config"; import { useUserProfile } from "contexts/userProfile"; import globalConstants from "../../../constants"; import { useTranslation } from "i18n"; +import ids from "components/instantlaunches/ids"; import isQueryLoading from "components/utils/isQueryLoading"; import InstantLaunchButtonWrapper from "components/instantlaunches/InstantLaunchButtonWrapper"; import withErrorAnnouncer from "components/error/withErrorAnnouncer"; @@ -84,7 +85,12 @@ const InstantLaunchStandalone = (props) => { if (isLoading) { return ; } else if (error || resourceError) { - return ; + return ( + + ); } else { return (