bbovenzi commented on code in PR #73580: URL: https://github.com/apache/airflow/pull/73580#discussion_r4275589313
########## airflow-core/src/airflow/ui/src/pages/Run/CallbackLogs.tsx: ########## @@ -0,0 +1,227 @@ +/*! + * 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 { useState } from "react"; + +import { Box, Heading, Link } from "@chakra-ui/react"; +import { useTranslation } from "react-i18next"; +import { FiArrowLeft } from "react-icons/fi"; +import { Link as RouterLink, useParams, useSearchParams } from "react-router-dom"; +import { useLocalStorage } from "usehooks-ts"; + +import { useDagRunServiceGetDagRun, useDeadlinesServiceGetDeadlines } from "openapi/queries"; + +import { Modal } from "src/system-components"; + +import { TaskLogContent, type TaskLogContentProps } from "src/pages/TaskInstance/Logs/TaskLogContent"; +import { TaskLogHeader, type TaskLogHeaderProps } from "src/pages/TaskInstance/Logs/TaskLogHeader"; +import { getDownloadText } from "src/pages/TaskInstance/Logs/utils"; + +import { DataTable } from "src/components/DataTable"; + +import { + LOG_SHOW_LOG_LEVEL_KEY, + LOG_SHOW_SOURCE_KEY, + LOG_SHOW_TIMESTAMP_KEY, + LOG_WRAP_KEY, +} from "src/constants/localStorage"; +import { SearchParamsKeys } from "src/constants/searchParams"; +import { SHORTCUTS } from "src/context/keyboardShortcuts"; +import { useShortcut } from "src/hooks/useShortcut"; +import { useConfig } from "src/queries/useConfig"; +import { useCallbackLogs } from "src/queries/useLogs"; +import { useDurationFormat } from "src/utils"; + +import { getCallbackColumns } from "./Callbacks"; + +export const CallbackLogs = () => { + const { callbackId = "", dagId = "", runId = "" } = useParams(); + const [searchParams] = useSearchParams(); + const { t: translate } = useTranslation("dag"); + + const logLevelFilters = searchParams.getAll(SearchParamsKeys.LOG_LEVEL); + const sourceFilters = searchParams.getAll(SearchParamsKeys.SOURCE); + + const defaultWrap = Boolean(useConfig("default_wrap")); + + const [wrap, setWrap] = useLocalStorage<boolean>(LOG_WRAP_KEY, defaultWrap); + const [showTimestamp, setShowTimestamp] = useLocalStorage<boolean>(LOG_SHOW_TIMESTAMP_KEY, true); + const [showSource, setShowSource] = useLocalStorage<boolean>(LOG_SHOW_SOURCE_KEY, false); + const [showLogLevel, setShowLogLevel] = useLocalStorage<boolean>(LOG_SHOW_LOG_LEVEL_KEY, true); + const [fullscreen, setFullscreen] = useState(false); + const [expanded, setExpanded] = useState(false); + const [searchQuery, setSearchQuery] = useState(""); + const [activeSearchIndex, setActiveSearchIndex] = useState(0); + + // Same params as the Callbacks tab's first page, so this is usually served from its cache. + const pageSize = useConfig("fallback_page_limit") as number; + const { data: deadlines } = useDeadlinesServiceGetDeadlines({ + dagId, + dagRunId: runId, + limit: pageSize, + offset: 0, + }); + const deadline = deadlines?.deadlines.find((dl) => dl.callback_id === callbackId); Review Comment: We should have an endpoint to get a single callback or at least include it in the useCallbackLogs. This one relies on filtering the entirely list and if our callback isn't on the first page then we never find it. -- 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]
