theaadya commented on code in PR #35393:
URL: https://github.com/apache/airflow/pull/35393#discussion_r1407580794


##########
airflow/www/static/js/dag/details/dagRun/MarkRunAs.tsx:
##########
@@ -58,42 +65,115 @@ const MarkRunAs = ({ runId, state, ...otherProps }: Props) 
=> {
     markSuccess({ confirmed: true });
   };
 
+  useEffect(() => {
+    const storedSuccessValue = localStorage.getItem("doNotShowAgainSuccess");
+    const storedFailedValue = localStorage.getItem("doNotShowAgainFailed");
+
+    if (storedSuccessValue) {
+      setDoNotShowAgainSuccess(JSON.parse(storedSuccessValue));
+    }
+    if (storedFailedValue) {
+      setDoNotShowAgainFailed(JSON.parse(storedFailedValue));
+    }
+  }, []);
+
+  const confirmAction = () => {
+    localStorage.setItem(
+      "doNotShowAgainSuccess",
+      JSON.stringify(doNotShowAgainSuccess)
+    );
+    localStorage.setItem(
+      "doNotShowAgainFailed",
+      JSON.stringify(doNotShowAgainFailed)
+    );
+
+    if (confirmingAction === "failed") {
+      markAsFailed();
+    } else if (confirmingAction === "success") {
+      markAsSuccess();
+    }
+    setShowConfirmationModal(false);
+  };
+
   useKeysPress(keyboardShortcutIdentifier.dagMarkSuccess, () => {
-    if (state !== "success") markAsSuccess();
+    if (state !== "success") {
+      if (!doNotShowAgainSuccess) {
+        setConfirmingAction("success");
+        setShowConfirmationModal(true);
+      } else markAsSuccess();
+    }
   });
   useKeysPress(keyboardShortcutIdentifier.dagMarkFailed, () => {
-    if (state !== "failed") markAsFailed();
+    if (state !== "failed") {
+      if (!doNotShowAgainFailed) {
+        setConfirmingAction("failed");
+        setShowConfirmationModal(true);
+      } else markAsFailed();
+    }
   });
 
   const markLabel = "Manually set dag run state";
   return (
-    <Menu>
-      <MenuButton
-        as={Button}
-        colorScheme="blue"
-        transition="all 0.2s"
-        title={markLabel}
-        aria-label={markLabel}
-        disabled={!canEdit || isMarkFailedLoading || isMarkSuccessLoading}
-        {...otherProps}
-        mt={2}
+    <>
+      <Menu>
+        <MenuButton
+          as={Button}
+          colorScheme="blue"
+          transition="all 0.2s"
+          title={markLabel}
+          aria-label={markLabel}
+          disabled={!canEdit || isMarkFailedLoading || isMarkSuccessLoading}
+          {...otherProps}
+          mt={2}
+        >
+          <Flex>
+            Mark state as...
+            <MdArrowDropDown size="16px" />
+          </Flex>
+        </MenuButton>
+        <MenuList>
+          <MenuItem onClick={markAsFailed} isDisabled={state === "failed"}>

Review Comment:
   The primary reason for implementing the confirmation was to avoid 
unintentional clearing or marking of the DAGs through keyboard shortcuts. 
That's why it is only displayed when the action is initiated using those 
shortcuts. However, I am open to further discussion.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to