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


##########
airflow-core/src/airflow/ui/src/pages/DagsList/BulkPauseDrainDagsButton.tsx:
##########
@@ -0,0 +1,97 @@
+/*!
+ * 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 { Button, useDisclosure } from "@chakra-ui/react";
+import { useTranslation } from "react-i18next";
+
+import type { DAGWithLatestDagRunsResponse, DagSchedulingState } from 
"openapi/requests/types.gen";
+
+import { ActionErrors } from "src/components/ActionErrors";
+import { ConfirmationModal } from "src/components/ConfirmationModal";
+import { PauseOrDrainChoiceModal } from 
"src/components/PauseOrDrainChoiceModal";
+
+import { useBulkPauseDrainDags } from "src/queries/useBulkPauseDrainDags";
+
+type Props = {
+  readonly deselectKeys: (keys: Array<string>) => void;
+  readonly selectedDags: Array<DAGWithLatestDagRunsResponse>;
+};
+
+const BulkPauseDrainDagsButton = ({ deselectKeys, selectedDags }: Props) => {
+  const { t: translate } = useTranslation(["common", "dags"]);
+  const { onClose, onOpen, open } = useDisclosure();
+  const { bulkAction, data, error, isPending, reset } = useBulkPauseDrainDags({
+    deselectKeys,
+    onSuccessConfirm: onClose,
+  });
+
+  // Nothing is running in any selected Dag, so draining and pausing now are 
equivalent
+  // for the whole batch — skip the drain-vs-pause choice, same as the 
single-Dag toggle does.
+  const allIdle = selectedDags.every((dag) => !dag.has_unfinished_runs);

Review Comment:
   Added in e391a9f: "skips the drain choice and pauses every selected Dag when 
…" in `DagsList.test.tsx` checks that an all-idle selection gets the plain 
confirm dialog instead of the drain choice, and that every Dag is sent as 
`paused`.
   
   Writing it turned up a bug: an already-paused Dag with unfinished runs 
counted as not idle, and picking Drain would have unpaused it, letting the 
scheduler resume its runs. Paused Dags are now left out of `allIdle` and always 
sent as `paused`; the test's second case covers that.
   
   ---
   Drafted-by: Claude Code (Opus 5.5); reviewed by @dheerajturaga before posting
   



##########
airflow-core/src/airflow/ui/src/pages/DagsList/DagsList.test.tsx:
##########
@@ -102,6 +102,50 @@ describe("Dag Filters", () => {
   });
 });
 
+describe("Bulk pause/drain Dags", () => {
+  it("pauses every selected Dag in one bulk request", async () => {

Review Comment:
   Added in e391a9f: "offers the drain choice once for a mix of idle and 
running Dags …" selects a Dag with running runs, an idle Dag and an 
already-paused Dag. It checks that the drain choice is shown once instead of 
the confirm dialog, and, for both Drain and Pause now, that the running and 
idle Dags get that state while the paused one stays `paused`.
   
   ---
   Drafted-by: Claude Code (Opus 5.5); 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