pierrejeambrun commented on code in PR #24249: URL: https://github.com/apache/airflow/pull/24249#discussion_r892873827
########## airflow/www/static/js/grid/details/content/taskInstance/Logs/index.jsx: ########## @@ -0,0 +1,163 @@ +/*! + * 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 React, { useState } from 'react'; +import { + Text, + Box, + Flex, + Divider, + Textarea, + Button, + Checkbox, +} from '@chakra-ui/react'; + +import { getMetaValue } from '../../../../../utils'; +import LogLink from './LogLink'; +import useTaskLog from '../../../../api/useTaskLog'; +import LinkButton from '../../../../components/LinkButton'; + +const showExternalLogRedirect = getMetaValue('show_external_log_redirect') === 'True'; +const externalLogName = getMetaValue('external_log_name'); +const logUrl = getMetaValue('log_url'); + +const getLinkIndexes = (tryNumber) => { + const internalIndexes = []; + const externalIndexes = []; + + [...Array(tryNumber + 1 || 0)].forEach((_, index) => { + if (index === 0 && tryNumber < 2) return; + const isExternal = index !== 0 && showExternalLogRedirect; + if (isExternal) { + externalIndexes.push(index); + } else { + internalIndexes.push(index); + } + }); + + return [internalIndexes, externalIndexes]; +}; + +const Logs = ({ + dagId, + dagRunId, + taskId, + executionDate, + tryNumber, + isGroup, +}) => { + const [internalIndexes, externalIndexes] = getLinkIndexes(tryNumber); + const [selectedAttempt, setSelectedAttempt] = useState(1); + const [shouldRequestFullContent, setShouldRequestFullContent] = useState(false); + const { data, isSuccess } = useTaskLog({ Review Comment: I can group everything that is related to the log parsing into a different PR to keep this one easy to follow. (it is becoming quite substantial, still have a few tests to add). What do you think ? I can start working on it right away. -- 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]
