guan404ming commented on code in PR #60718:
URL: https://github.com/apache/airflow/pull/60718#discussion_r2732397958


##########
airflow-core/src/airflow/ui/src/queries/useBulkDeleteDagRuns.ts:
##########
@@ -0,0 +1,89 @@
+/*!
+ * 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 { useQueryClient } from "@tanstack/react-query";
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+
+import {
+  useDagRunServiceDeleteDagRun,
+  useDagRunServiceGetDagRunsKey,
+  UseDagRunServiceGetDagRunKeyFn,
+  useTaskInstanceServiceGetTaskInstancesKey,
+  useTaskInstanceServiceGetHitlDetailsKey,
+} from "openapi/queries";
+import { toaster } from "src/components/ui";
+
+export type SelectedRun = { dagId: string; dagRunId: string };
+
+export const useBulkDeleteDagRuns = (onSuccessConfirm?: () => void) => {
+  const { t: translate } = useTranslation();
+  const queryClient = useQueryClient();
+  const deleteMutation = useDagRunServiceDeleteDagRun();
+  const [error, setError] = useState<unknown>(undefined);
+  const bulkDelete = async (runs: Array<SelectedRun>): Promise<void> => {

Review Comment:
   Here is not real bulk delete of dagrun. We don't have bulk dagrun endpoint 
now. We need to update backend to support this or we would need N queries for N 
dagruns.



##########
airflow-core/src/airflow/ui/src/pages/DagRuns.tsx:
##########
@@ -58,7 +66,55 @@ const {
   TRIGGERING_USER_NAME_PATTERN: TRIGGERING_USER_NAME_PATTERN_PARAM,
 }: SearchParamsKeysType = SearchParamsKeys;
 
-const runColumns = (translate: TFunction, dagId?: string): 
Array<ColumnDef<DAGRunResponse>> => [
+type SelectedRun = { dagId: string; dagRunId: string };

Review Comment:
   This is duplicated, let use the one at `useBulkDeleteDagRuns.ts:32`



##########
airflow-core/src/airflow/ui/src/queries/useBulkDeleteDagRuns.ts:
##########
@@ -0,0 +1,89 @@
+/*!
+ * 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 { useQueryClient } from "@tanstack/react-query";
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+
+import {
+  useDagRunServiceDeleteDagRun,
+  useDagRunServiceGetDagRunsKey,
+  UseDagRunServiceGetDagRunKeyFn,
+  useTaskInstanceServiceGetTaskInstancesKey,
+  useTaskInstanceServiceGetHitlDetailsKey,
+} from "openapi/queries";
+import { toaster } from "src/components/ui";
+
+export type SelectedRun = { dagId: string; dagRunId: string };
+
+export const useBulkDeleteDagRuns = (onSuccessConfirm?: () => void) => {

Review Comment:
   nit: The hook is kind of inconsistent here. We could try follow the pattern 
in `useBulkDeleteVariables.ts:31` and `useBulkDeleteConnections.tsx:31`:       
     - Accept clearSelections as a parameter                                    
                                   
     - Return { error, isPending, mutate }                                      
                                   
     - Keep consistency across the codebase



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