Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dropdown instead of buttons when there are more than 10 retries in log tab #36025

Merged
merged 2 commits into from
Dec 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 41 additions & 16 deletions airflow/www/static/js/dag/details/taskInstance/Logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
Checkbox,
Icon,
Spinner,
Select,
} from "@chakra-ui/react";
import { MdWarning } from "react-icons/md";

Expand Down Expand Up @@ -152,6 +153,9 @@ const Logs = ({
[data, fileSourceFilters, logLevelFilters, timezone]
);

const logAttemptDropdownLimit = 10;
const showDropdown = internalIndexes.length > logAttemptDropdownLimit;

useEffect(() => {
// Reset fileSourceFilters and selected attempt when changing to
// a task that do not have those filters anymore.
Expand Down Expand Up @@ -193,24 +197,45 @@ const Logs = ({
{tryNumber !== undefined && (
<>
<Box>
<Text as="span"> (by attempts)</Text>
<Flex my={1} justifyContent="space-between">
<Flex flexWrap="wrap">
{internalIndexes.map((index) => (
<Button
key={index}
variant={taskTryNumber === index ? "solid" : "ghost"}
colorScheme="blue"
onClick={() => setSelectedTryNumber(index)}
data-testid={`log-attempt-select-button-${index}`}
>
{index}
</Button>
))}
</Flex>
</Flex>
{!showDropdown && (
<Box>
<Text as="span"> (by attempts)</Text>
<Flex my={1} justifyContent="space-between">
<Flex flexWrap="wrap">
{internalIndexes.map((index) => (
<Button
key={index}
variant={taskTryNumber === index ? "solid" : "ghost"}
colorScheme="blue"
onClick={() => setSelectedTryNumber(index)}
data-testid={`log-attempt-select-button-${index}`}
>
{index}
</Button>
))}
</Flex>
</Flex>
</Box>
)}
<Flex my={1} justifyContent="space-between" flexWrap="wrap">
<Flex alignItems="center" flexGrow={1} mr={10}>
{showDropdown && (
<Box width="100%" mr={2}>
<Select
size="sm"
placeholder="Select log attempt"
tirkarthi marked this conversation as resolved.
Show resolved Hide resolved
onChange={(e) => {
setSelectedTryNumber(Number(e.target.value));
}}
>
{internalIndexes.map((index) => (
<option key={index} value={index}>
{index}
</option>
))}
</Select>
</Box>
)}
<Box width="100%" mr={2}>
<MultiSelect
size="sm"
Expand Down