dheerajturaga commented on code in PR #73763:
URL: https://github.com/apache/airflow/pull/73763#discussion_r4171088862


##########
airflow-core/src/airflow/ui/src/components/TriggerDag/PausedDagOptions.tsx:
##########
@@ -0,0 +1,112 @@
+/*!
+ * 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 { Box, HStack, Text } from "@chakra-ui/react";
+import { useTranslation } from "react-i18next";
+
+import { useBackfillServiceListBackfillsUi, useDagRunServiceGetDagRuns } from 
"openapi/queries";
+import type { DagRunType } from "openapi/requests/types.gen";
+
+import { RadioCardItem, RadioCardRoot } from "src/system-components";
+
+import type { PausedDagAction } from "./types";
+
+const PAUSED_DAG_OPTIONS = [
+  { description: "pausedDag.unpauseDescription", label: "pausedDag.unpause", 
value: "unpause" },
+  { description: "pausedDag.drainDescription", label: "pausedDag.drain", 
value: "drain" },
+  { description: "pausedDag.keepPausedDescription", label: 
"pausedDag.keepPaused", value: "keepPaused" },
+] as const satisfies Array<{ description: string; label: string; value: 
PausedDagAction }>;
+
+const NON_BACKFILL_RUN_TYPES: Array<Exclude<DagRunType, "backfill">> = [
+  "scheduled",
+  "manual",
+  "operator_triggered",
+  "asset_triggered",
+  "asset_materialization",
+];
+
+type PausedDagOptionsProps = {
+  readonly dagId: string;
+  readonly onChange: (action: PausedDagAction) => void;
+  readonly value: PausedDagAction;
+};
+
+const PausedDagOptions = ({ dagId, onChange, value }: PausedDagOptionsProps) 
=> {
+  const { t: translate } = useTranslation("components");
+  // Unpausing or draining lets every unfinished run proceed, not only the one 
being created. The cached
+  // count can predate runs that have since finished (e.g. the run of an 
earlier drain), so it is
+  // refetched and only trusted once fetched for this form.
+  const { data: activeBackfills } = useBackfillServiceListBackfillsUi({ 
active: true, dagId }, undefined, {
+    staleTime: 0,
+  });
+  // A paused backfill's runs do not start while it stays paused, whichever 
option is chosen.
+  const isBackfillPaused = activeBackfills?.backfills.some((backfill) => 
backfill.is_paused) ?? false;
+  const { data: unfinishedRuns, isFetchedAfterMount } = 
useDagRunServiceGetDagRuns(

Review Comment:
   The run-count query now waits for a fresh, successful backfill fetch before 
choosing its `runType` filter. Stale or failed counts stay hidden. Moved the 
title to `RadioCardLabel` inside the root, with regression coverage for 
delayed/cached queries and the accessible group name.
   
   ---
   Drafted-by: Codex (GPT-6); reviewed by @dheerajturaga before posting



-- 
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