Merge pull request #10346 from jakemcdermott/fix-9905

Disable cancel button on http 405

SUMMARY
for #9905
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.

Reviewed-by: Keith Grant <keithjgrant@gmail.com>
Reviewed-by: Sarah Akus <sarah.akus@gmail.com>
This commit is contained in:
softwarefactory-project-zuul[bot] 2021-06-07 21:25:05 +00:00 committed by GitHub
commit e4931bde6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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"