From ec1408fbd140b1ac2016ceb62d4605a3664f3f2d Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Thu, 3 Jun 2021 12:54:16 -0400 Subject: [PATCH] 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. --- .../src/components/JobCancelButton/JobCancelButton.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/components/JobCancelButton/JobCancelButton.jsx b/awx/ui_next/src/components/JobCancelButton/JobCancelButton.jsx index 3bbee07474..b9098836e5 100644 --- a/awx/ui_next/src/components/JobCancelButton/JobCancelButton.jsx +++ b/awx/ui_next/src/components/JobCancelButton/JobCancelButton.jsx @@ -27,11 +27,14 @@ function JobCancelButton({ cancelError ); + const isAlreadyCancelled = cancelError?.response?.status === 405; + return ( <> - + {showIconButton ? ( ) : (