From 18266a86c1d236d8f57668e1ee322b0183c27b0b Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Fri, 27 Sep 2024 13:31:28 -0700 Subject: [PATCH] Move the preferences to be sent along with the call to launch(), not added by the mutation --- .../InstantLaunchButtonWrapper.js | 79 +++++++++---------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/src/components/instantlaunches/InstantLaunchButtonWrapper.js b/src/components/instantlaunches/InstantLaunchButtonWrapper.js index 7f7c20d97..423b09a8b 100644 --- a/src/components/instantlaunches/InstantLaunchButtonWrapper.js +++ b/src/components/instantlaunches/InstantLaunchButtonWrapper.js @@ -60,54 +60,46 @@ function InstantLaunchButtonWrapper(props) { } }, [ilUrl]); - const { mutate: launch } = useMutation( - (args) => { - args.preferences = bootstrapInfo?.preferences; - return instantlyLaunch(args); - }, - { - onSuccess: (listing) => { - if (listing.analyses.length > 0) { - const analysis = listing.analyses[0]; - if (analysis.interactive_urls?.length > 0) { - setIlUrl( - `${ - constants.VICE_LOADING_PAGE - }/${encodeURIComponent( - analysis.interactive_urls[0] - )}` - ); - } else { - setOpen(false); - } + const { mutate: launch } = useMutation(instantlyLaunch, { + onSuccess: (listing) => { + if (listing.analyses.length > 0) { + const analysis = listing.analyses[0]; + if (analysis.interactive_urls?.length > 0) { + setIlUrl( + `${constants.VICE_LOADING_PAGE}/${encodeURIComponent( + analysis.interactive_urls[0] + )}` + ); } else { setOpen(false); } - }, - onError: (err) => { + } else { setOpen(false); + } + }, + onError: (err) => { + setOpen(false); - const respData = err.response?.data; - const runErrorCode = respData?.error_code; - const details = respData?.details; + const respData = err.response?.data; + const runErrorCode = respData?.error_code; + const details = respData?.details; - if (runErrorCode === ERROR_CODES.ERR_PERMISSION_NEEDED) { - if (details?.pendingRequest) { - setPendingRequestDlgOpen(true); - } else { - setAccessRequestDialogOpen(true); - } - } else if ( - runErrorCode === ERROR_CODES.ERR_LIMIT_REACHED || - runErrorCode === ERROR_CODES.ERR_FORBIDDEN - ) { - setRunErrorDetails({ runErrorCode, ...details }); + if (runErrorCode === ERROR_CODES.ERR_PERMISSION_NEEDED) { + if (details?.pendingRequest) { + setPendingRequestDlgOpen(true); } else { - showErrorAnnouncer(err.message, err); + setAccessRequestDialogOpen(true); } - }, - } - ); + } else if ( + runErrorCode === ERROR_CODES.ERR_LIMIT_REACHED || + runErrorCode === ERROR_CODES.ERR_FORBIDDEN + ) { + setRunErrorDetails({ runErrorCode, ...details }); + } else { + showErrorAnnouncer(err.message, err); + } + }, + }); const onClick = () => { if (userProfile?.id) { @@ -115,7 +107,12 @@ function InstantLaunchButtonWrapper(props) { showErrorAnnouncer(t("computeLimitExceededMsg")); } else { setOpen(true); - launch({ instantLaunch, resource, output_dir }); + launch({ + instantLaunch, + resource, + output_dir, + preferences: bootstrapInfo?.preferences, + }); } } else { setSignInDlgOpen(true);