nathadfield commented on code in PR #61448:
URL: https://github.com/apache/airflow/pull/61448#discussion_r2871541956


##########
airflow-core/src/airflow/ui/src/components/Clear/useRunOnLatestVersion.ts:
##########
@@ -0,0 +1,93 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { useState } from "react";
+
+import { useConfig } from "src/queries/useConfig";
+
+type UseRunOnLatestVersionProps = {
+  /**
+   * Current DAG bundle version
+   */
+  currentBundleVersion?: string | null;
+
+  /**
+   * DAG-level configuration from the DAG details.
+   * If defined (true or false), takes precedence over global config.
+   */
+  dagLevelConfig?: boolean | null;
+
+  /**
+   * DAG run bundle version
+   */
+  runBundleVersion?: string | null;
+};
+
+type UseRunOnLatestVersionResult = {
+  /**
+   * Setter for the checkbox value
+   */
+  setValue: (value: boolean) => void;
+
+  /**
+   * Whether the checkbox should be shown
+   */
+  shouldShowCheckbox: boolean;
+
+  /**
+   * Current value of the checkbox (controlled)
+   */
+  value: boolean;
+};
+
+/**
+ * Custom hook for managing "Run on Latest Version" checkbox state.
+ *
+ * Implements the three-level precedence hierarchy:
+ * 1. DAG-level configuration (highest priority)
+ * 2. Global configuration
+ * 3. System default (false)
+ *
+ * Uses nullable override pattern: state is null until user interacts,
+ * avoiding the useState + useEffect synchronization anti-pattern.
+ */
+export const useRunOnLatestVersion = ({
+  currentBundleVersion,
+  dagLevelConfig,
+  runBundleVersion,
+}: UseRunOnLatestVersionProps): UseRunOnLatestVersionResult => {
+  const globalConfigValue = useConfig("run_on_latest_version");
+  const globalDefault = globalConfigValue === "true";

Review Comment:
   Good catch! Fixed to `Boolean(globalConfigValue)`



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to