pierrejeambrun commented on code in PR #35393: URL: https://github.com/apache/airflow/pull/35393#discussion_r1405477686
########## 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); Review Comment: When you have states that are bound to each other by some logic, I recommend using a useReducer. This way coupled logic between states get hidden behind a common action, (easy to re-use and understand). https://react.dev/reference/react/useReducer Action could for instance be `CONFIRM_SUCCESS`, `CONFIRM_FAILURE` etc. Then it would take care of switching all the appropriate states. When needed, you can just dispatch the appropriate action. -- 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