Copilot commented on code in PR #64374:
URL: https://github.com/apache/airflow/pull/64374#discussion_r3025327265


##########
airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx:
##########
@@ -167,14 +163,10 @@ export const DetailsLayout = ({ children, error, 
isLoading, tabs }: Props) => {
                   dagView={dagView}
                   limit={limit}
                   panelGroupRef={panelGroupRef}
-                  runAfterGte={runAfterGte}
-                  runAfterLte={runAfterLte}
                   runTypeFilter={runTypeFilter}
                   setDagRunStateFilter={setDagRunStateFilter}
                   setDagView={setDagView}
                   setLimit={setLimit}
-                  setRunAfterGte={setRunAfterGte}
-                  setRunAfterLte={setRunAfterLte}
                   setRunTypeFilter={setRunTypeFilter}

Review Comment:
   This PR also removes the `runAfterGte` / `runAfterLte` local-storage state 
and stops passing those props downstream (previously used for date range 
filtering). That’s a functional behavior change but isn’t called out in the PR 
description’s change list. Please either (a) update the PR description to 
explicitly mention this removal and why it’s safe, or (b) split this into a 
separate PR if it’s unrelated to the stale/deactivated DAG UI work.



##########
airflow-core/src/airflow/ui/src/pages/Dag/Header.test.tsx:
##########
@@ -0,0 +1,65 @@
+/*!
+ * 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 "@testing-library/jest-dom";
+import { render, screen } from "@testing-library/react";
+import type { DAGDetailsResponse } from "openapi-gen/requests/types.gen";
+import { describe, expect, it } from "vitest";
+
+import "src/i18n/config";
+import { MOCK_DAG } from "src/mocks/handlers/dag";
+import { Wrapper } from "src/utils/Wrapper";
+
+import { Header } from "./Header";
+
+const mockDag = {
+  ...MOCK_DAG,
+  active_runs_count: 0,
+  allowed_run_types: [],
+  bundle_name: "dags-folder",
+  bundle_version: "1",
+  default_args: {},
+  fileloc: "/files/dags/stale_dag.py",
+  is_favorite: false,
+  is_stale: true,
+  last_parse_duration: 0.23,
+  // `null` matches the API response shape for DAGs without version metadata.
+  // eslint-disable-next-line unicorn/no-null
+  latest_dag_version: null,
+  next_dagrun_logical_date: "2024-08-22T00:00:00+00:00",
+  next_dagrun_run_after: "2024-08-22T19:00:00+00:00",
+  owner_links: {},
+  relative_fileloc: "stale_dag.py",
+  tags: [],
+  timetable_partitioned: false,
+  timetable_summary: "* * * * *",
+} as unknown as DAGDetailsResponse;
+
+describe("Header", () => {
+  it("shows a deactivated badge and hides stale-only next actions for stale 
dags", () => {
+    render(
+      <Wrapper>
+        <Header dag={mockDag} />
+      </Wrapper>,
+    );
+
+    expect(screen.getByText("header.status.deactivated")).toBeInTheDocument();
+    expect(screen.queryByText("dagDetails.nextRun")).not.toBeInTheDocument();

Review Comment:
   These assertions look like they’re checking for i18n keys rather than the 
rendered, translated UI text. Since `src/i18n/config` is loaded and `dag.json` 
defines `header.status.deactivated` as \"Deactivated\", the component will 
likely render \"Deactivated\" (not the key), causing this test to fail. Prefer 
asserting against the translated string (e.g., \"Deactivated\") or use the i18n 
instance to resolve the key in the test before asserting; similarly for the 
\"Next run\" label.
   ```suggestion
       expect(screen.getByText("Deactivated")).toBeInTheDocument();
       expect(screen.queryByText("Next run")).not.toBeInTheDocument();
   ```



##########
airflow-core/src/airflow/ui/src/pages/Dag/Header.tsx:
##########
@@ -132,16 +140,20 @@ export const Header = ({
               />
             )}
             <FavoriteDagButton dagId={dag.dag_id} isFavorite={dag.is_favorite} 
/>
-            <ParseDagButton dagId={dag.dag_id} fileToken={dag.file_token} />
+            {dag.is_stale ? undefined : <ParseDagButton dagId={dag.dag_id} 
fileToken={dag.file_token} />}

Review Comment:
   The stale check is written in a few different ways (`dag?.is_stale === 
true`, `dag.is_stale`, `dag?.is_stale`). Aligning on a single pattern within 
this component would reduce cognitive overhead and avoid subtle differences if 
the type ever expands beyond strict booleans. Consider consistently using 
`dag?.is_stale` for checks that happen outside the `dag !== undefined` guard, 
and `dag.is_stale` only inside the guarded block.



##########
airflow-core/src/airflow/ui/src/pages/Dag/Header.tsx:
##########
@@ -57,6 +58,21 @@ export const Header = ({
   // We would still like to show the dagId even if the dag object hasn't 
loaded yet
   const { dagId } = useParams();
 
+  const nextRunStat =
+    dag?.is_stale === true

Review Comment:
   The stale check is written in a few different ways (`dag?.is_stale === 
true`, `dag.is_stale`, `dag?.is_stale`). Aligning on a single pattern within 
this component would reduce cognitive overhead and avoid subtle differences if 
the type ever expands beyond strict booleans. Consider consistently using 
`dag?.is_stale` for checks that happen outside the `dag !== undefined` guard, 
and `dag.is_stale` only inside the guarded block.
   ```suggestion
       dag?.is_stale
   ```



##########
airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx:
##########
@@ -48,8 +48,6 @@ import {
   dagRunStateFilterKey,
   dagViewKey,
   DEFAULT_DAG_VIEW_KEY,
-  runAfterGteKey,
-  runAfterLteKey,
   runTypeFilterKey,
   showGanttKey,
   triggeringUserFilterKey,

Review Comment:
   This PR also removes the `runAfterGte` / `runAfterLte` local-storage state 
and stops passing those props downstream (previously used for date range 
filtering). That’s a functional behavior change but isn’t called out in the PR 
description’s change list. Please either (a) update the PR description to 
explicitly mention this removal and why it’s safe, or (b) split this into a 
separate PR if it’s unrelated to the stale/deactivated DAG UI work.



##########
airflow-core/src/airflow/ui/src/pages/Dag/Header.tsx:
##########
@@ -132,16 +140,20 @@ export const Header = ({
               />
             )}
             <FavoriteDagButton dagId={dag.dag_id} isFavorite={dag.is_favorite} 
/>
-            <ParseDagButton dagId={dag.dag_id} fileToken={dag.file_token} />
+            {dag.is_stale ? undefined : <ParseDagButton dagId={dag.dag_id} 
fileToken={dag.file_token} />}
             <DeleteDagButton dagDisplayName={dag.dag_display_name} 
dagId={dag.dag_id} />
           </>
         )
       }
       icon={<DagIcon />}
       stats={stats}
       subTitle={
-        dag !== undefined && (
-          <TogglePause dagDisplayName={dag.dag_display_name} 
dagId={dag.dag_id} isPaused={dag.is_paused} />
+        dag?.is_stale ? (

Review Comment:
   The stale check is written in a few different ways (`dag?.is_stale === 
true`, `dag.is_stale`, `dag?.is_stale`). Aligning on a single pattern within 
this component would reduce cognitive overhead and avoid subtle differences if 
the type ever expands beyond strict booleans. Consider consistently using 
`dag?.is_stale` for checks that happen outside the `dag !== undefined` guard, 
and `dag.is_stale` only inside the guarded block.



##########
airflow-core/src/airflow/ui/src/layouts/Details/DetailsLayout.tsx:
##########
@@ -78,9 +76,7 @@ export const DetailsLayout = ({ children, error, isLoading, 
tabs }: Props) => {
   const [defaultDagView] = useLocalStorage<"graph" | 
"grid">(DEFAULT_DAG_VIEW_KEY, "grid");
   const panelGroupRef = useRef<ImperativePanelGroupHandle | null>(null);
   const [dagView, setDagView] = useLocalStorage<"graph" | 
"grid">(dagViewKey(dagId), defaultDagView);
-  const [limit, setLimit] = useLocalStorage<number>(dagRunsLimitKey(dagId), 
10);
-  const [runAfterGte, setRunAfterGte] = useLocalStorage<string | 
undefined>(runAfterGteKey(dagId), undefined);
-  const [runAfterLte, setRunAfterLte] = useLocalStorage<string | 
undefined>(runAfterLteKey(dagId), undefined);
+  const [limit, setLimit] = useLocalStorage(dagRunsLimitKey(dagId), 10);

Review Comment:
   This PR also removes the `runAfterGte` / `runAfterLte` local-storage state 
and stops passing those props downstream (previously used for date range 
filtering). That’s a functional behavior change but isn’t called out in the PR 
description’s change list. Please either (a) update the PR description to 
explicitly mention this removal and why it’s safe, or (b) split this into a 
separate PR if it’s unrelated to the stale/deactivated DAG UI work.



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