diff --git a/src/components/instantlaunches/launch/index.js b/src/components/instantlaunches/launch/index.js index b23cded93..1ae5f7f2a 100644 --- a/src/components/instantlaunches/launch/index.js +++ b/src/components/instantlaunches/launch/index.js @@ -15,6 +15,7 @@ import { getResourceUsageSummary, RESOURCE_USAGE_QUERY_KEY, } from "serviceFacades/dashboard"; +import { useDataDetails } from "serviceFacades/filesystem"; import { getUserQuota } from "common/resourceUsage"; import { useConfig } from "contexts/config"; import { useUserProfile } from "contexts/userProfile"; @@ -25,17 +26,21 @@ import InstantLaunchButtonWrapper from "components/instantlaunches/InstantLaunch import withErrorAnnouncer from "components/error/withErrorAnnouncer"; import LoadingAnimation from "components/vice/loading/LoadingAnimation"; -import ErrorTypography from "components/error/ErrorTypography"; -import DEErrorDialog from "components/error/DEErrorDialog"; +import ErrorTypographyWithDialog from "components/error/ErrorTypographyWithDialog"; const InstantLaunchStandalone = (props) => { - const { id: instant_launch_id, showErrorAnnouncer } = props; + const { + id: instant_launch_id, + resource: resource_path, + showErrorAnnouncer, + } = props; const [config] = useConfig(); const [userProfile] = useUserProfile(); const [computeLimitExceeded, setComputeLimitExceeded] = useState( !!config?.subscriptions?.enforce ); - const [errorDialogOpen, setErrorDialogOpen] = useState(false); + const [resource, setResource] = useState(null); + const { t } = useTranslation(["instantlaunches", "common"]); const { data, status, error } = useQuery( @@ -61,28 +66,36 @@ const InstantLaunchStandalone = (props) => { }, }); - const isLoading = isQueryLoading([status, isFetchingUsageSummary]); + const { isFetching: isLoadingResource, error: resourceError } = + useDataDetails({ + paths: [resource_path], + enabled: !!resource_path, + onSuccess: (resp) => { + setResource(resp?.paths[resource_path]); + }, + }); + + const isLoading = isQueryLoading([ + status, + isLoadingResource, + isFetchingUsageSummary, + ]); if (isLoading) { return ; - } else if (error) { + } else if (error || resourceError) { + const err = error || resourceError; return ( - <> - setErrorDialogOpen(true)} - /> - setErrorDialogOpen(false)} - /> - + ); } else { return ( diff --git a/src/pages/instantlaunch/[id]/index.js b/src/pages/instantlaunch/[id]/index.js index a3289106c..c1c244c7a 100644 --- a/src/pages/instantlaunch/[id]/index.js +++ b/src/pages/instantlaunch/[id]/index.js @@ -15,9 +15,9 @@ import InstantLaunchStandalone from "components/instantlaunches/launch"; export default function InstantLaunch() { const router = useRouter(); - const { id } = router.query; + const { id, resource } = router.query; - return ; + return ; } export async function getServerSideProps({ locale }) {