bbovenzi commented on code in PR #43793:
URL: https://github.com/apache/airflow/pull/43793#discussion_r1833170976


##########
airflow/ui/src/pages/Events/Events.tsx:
##########
@@ -0,0 +1,142 @@
+/*!
+ * 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 } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { useParams } from "react-router-dom";
+
+import { useEventLogServiceGetEventLogs } from "openapi/queries";
+import type { EventLogResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import Time from "src/components/Time";
+
+export const Events = () => {
+  const { dagId } = useParams();
+
+  const { setTableURLState, tableURLState } = useTableURLState({
+    sorting: [{ desc: true, id: "when" }],
+  });
+  const { pagination, sorting } = tableURLState;
+  const [sort] = sorting;
+
+  const orderBy = sort ? `${sort.desc ? "-" : ""}${sort.id}` : undefined;
+
+  const {
+    data,
+    error: EventsError,
+    isFetching,
+    isLoading,
+  } = useEventLogServiceGetEventLogs({
+    dagId,
+    limit: pagination.pageSize,
+    offset: pagination.pageIndex * pagination.pageSize,
+    orderBy,
+  });
+
+  const columns: Array<ColumnDef<EventLogResponse>> = [
+    {
+      accessorKey: "when",
+      cell: ({ row: { original } }) => <Time datetime={original.when} />,
+      enableSorting: true,
+      header: "When",
+      meta: {
+        skeletonWidth: 10,
+      },
+    },
+    ...(Boolean(dagId)
+      ? []
+      : [
+          {
+            accessorKey: "dag_id",
+            enableSorting: true,
+            header: "Dag ID",
+            meta: {
+              skeletonWidth: 10,
+            },
+          },
+        ]),
+    {
+      accessorKey: "run_id",
+      enableSorting: true,
+      header: "Run ID",
+      meta: {
+        skeletonWidth: 10,
+      },
+    },
+    {
+      accessorKey: "task_id",
+      enableSorting: true,
+      header: "Task ID",
+      meta: {
+        skeletonWidth: 10,
+      },
+    },
+    {
+      accessorKey: "map_index",
+      enableSorting: false,
+      header: "Map Index",
+      meta: {
+        skeletonWidth: 10,
+      },
+    },
+    {
+      accessorKey: "try_number",
+      enableSorting: false,
+      header: "Try Number",
+      meta: {
+        skeletonWidth: 10,
+      },
+    },
+    {
+      accessorKey: "event",
+      enableSorting: true,
+      header: "Event",
+      meta: {
+        skeletonWidth: 10,
+      },
+    },
+    {
+      accessorKey: "owner",
+      enableSorting: true,
+      header: "User",
+      meta: {
+        skeletonWidth: 10,
+      },
+    },
+  ];
+
+  return (
+    <Box>
+      <ErrorAlert error={EventsError} />
+      <DataTable
+        columns={columns}
+        data={data ? data.event_logs : []}
+        displayMode="table"
+        initialState={tableURLState}
+        isFetching={isFetching}
+        isLoading={isLoading}
+        modelName="Events"

Review Comment:
   ```suggestion
           modelName="Event"
   ```



##########
airflow/ui/src/pages/Events/Events.tsx:
##########
@@ -0,0 +1,142 @@
+/*!
+ * 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 } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { useParams } from "react-router-dom";
+
+import { useEventLogServiceGetEventLogs } from "openapi/queries";
+import type { EventLogResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import Time from "src/components/Time";
+
+export const Events = () => {
+  const { dagId } = useParams();
+
+  const { setTableURLState, tableURLState } = useTableURLState({
+    sorting: [{ desc: true, id: "when" }],
+  });
+  const { pagination, sorting } = tableURLState;
+  const [sort] = sorting;
+
+  const orderBy = sort ? `${sort.desc ? "-" : ""}${sort.id}` : undefined;
+
+  const {
+    data,
+    error: EventsError,
+    isFetching,
+    isLoading,
+  } = useEventLogServiceGetEventLogs({
+    dagId,
+    limit: pagination.pageSize,
+    offset: pagination.pageIndex * pagination.pageSize,
+    orderBy,
+  });
+
+  const columns: Array<ColumnDef<EventLogResponse>> = [
+    {
+      accessorKey: "when",
+      cell: ({ row: { original } }) => <Time datetime={original.when} />,
+      enableSorting: true,
+      header: "When",
+      meta: {
+        skeletonWidth: 10,
+      },
+    },
+    ...(Boolean(dagId)

Review Comment:
   With columns defined outside of the react component. we might need to turn 
`const columns` into a function in order to accept a dagId



##########
airflow/ui/src/pages/Events/Events.tsx:
##########
@@ -0,0 +1,142 @@
+/*!
+ * 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 } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { useParams } from "react-router-dom";
+
+import { useEventLogServiceGetEventLogs } from "openapi/queries";
+import type { EventLogResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import Time from "src/components/Time";
+
+export const Events = () => {
+  const { dagId } = useParams();
+
+  const { setTableURLState, tableURLState } = useTableURLState({
+    sorting: [{ desc: true, id: "when" }],
+  });
+  const { pagination, sorting } = tableURLState;
+  const [sort] = sorting;
+
+  const orderBy = sort ? `${sort.desc ? "-" : ""}${sort.id}` : undefined;
+
+  const {
+    data,
+    error: EventsError,
+    isFetching,
+    isLoading,
+  } = useEventLogServiceGetEventLogs({
+    dagId,
+    limit: pagination.pageSize,
+    offset: pagination.pageIndex * pagination.pageSize,
+    orderBy,
+  });
+
+  const columns: Array<ColumnDef<EventLogResponse>> = [

Review Comment:
   We can define `columns` just outside of the Events component on line 29



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