Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the standalone instant launch page show errors immediately #610

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/components/instantlaunches/launch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand All @@ -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(
Expand Down Expand Up @@ -81,14 +86,24 @@ const InstantLaunchStandalone = (props) => {
isFetchingUsageSummary,
]);

useEffect(() => {
if (error || resourceError) {
setDialogError(error || resourceError);
setErrDialogOpen(true);
}
}, [error, resourceError, setErrDialogOpen, setDialogError]);

if (isLoading) {
return <LoadingAnimation />;
} else if (error || resourceError) {
const err = error || resourceError;
return (
<ErrorTypographyWithDialog
errorMessage={t("instantLaunchError")}
errorObject={err}
<DEErrorDialog
open={errDialogOpen}
errorObject={dialogError}
handleClose={() => {
setErrDialogOpen(false);
router.push("/");
}}
ianmcorvidae marked this conversation as resolved.
Show resolved Hide resolved
/>
);
} else {
Expand Down
Loading