Disable cancel button on http 405

When a 405 is received, it means the job is already cancelled. Treat the
request as a success and don't show an error modal.

We disable the button to handle a rare scenario where we receive the 405 long before
the job status is properly updated to "cancelled" over websockets. We want to prevent
more cancel requests when this happens. We're disabling instead of hiding the button
because, assuming the status hasn't changed over sockets, the buttons that usually
replace the cancel button on the toolbar won't be shown yet and we don't want to
needlessly flicker and shift button positions around by rapidly loading and unloading
a different number of buttons onto the bar.
This commit is contained in:
Jake McDermott 2021-06-03 12:54:16 -04:00
parent d360fb212e
commit ec1408fbd1
No known key found for this signature in database
GPG Key ID: 0E56ED990CDFCB4F

View File

@ -27,11 +27,14 @@ function JobCancelButton({
cancelError
);
const isAlreadyCancelled = cancelError?.response?.status === 405;
return (
<>
<Tooltip content={title}>
<Tooltip content={isAlreadyCancelled ? null : title}>
{showIconButton ? (
<Button
isDisabled={isAlreadyCancelled}
aria-label={title}
ouiaId="cancel-job-button"
onClick={() => setIsOpen(true)}
@ -41,6 +44,7 @@ function JobCancelButton({
</Button>
) : (
<Button
isDisabled={isAlreadyCancelled}
aria-label={title}
variant="secondary"
ouiaId="cancel-job-button"
@ -83,7 +87,7 @@ function JobCancelButton({
{t`Are you sure you want to cancel this job?`}
</AlertModal>
)}
{error && (
{error && !isAlreadyCancelled && (
<AlertModal
isOpen={error}
variant="danger"