From 12488c7b40bbb8d060138760aa780dec4a1165fc Mon Sep 17 00:00:00 2001 From: Victor Chiapaikeo Date: Fri, 3 Nov 2023 07:06:38 -0400 Subject: [PATCH 1/8] Add multiselect to run state in grid view --- airflow/www/static/js/dag/nav/FilterBar.tsx | 54 +++++++++++++++------ airflow/www/static/js/dag/useFilters.tsx | 25 ++++++++-- airflow/www/views.py | 7 +-- tests/www/views/test_views_grid.py | 11 +++++ 4 files changed, 76 insertions(+), 21 deletions(-) diff --git a/airflow/www/static/js/dag/nav/FilterBar.tsx b/airflow/www/static/js/dag/nav/FilterBar.tsx index fc3a56f1d5a3f..15b15f989de15 100644 --- a/airflow/www/static/js/dag/nav/FilterBar.tsx +++ b/airflow/www/static/js/dag/nav/FilterBar.tsx @@ -20,9 +20,11 @@ /* global moment */ import { Box, Button, Flex, Input, Select } from "@chakra-ui/react"; +import MultiSelect from "src/components/MultiSelect"; import React from "react"; import type { DagRun, RunState, TaskState } from "src/types"; import AutoRefresh from "src/components/AutoRefresh"; +import type { Size } from "chakra-react-select"; import { useTimezone } from "src/context/timezone"; import { isoFormatWithoutTZ } from "src/datetime_utils"; @@ -51,7 +53,10 @@ const FilterBar = () => { // @ts-ignore const formattedTime = time.tz(timezone).format(isoFormatWithoutTZ); - const inputStyles = { backgroundColor: "white", size: "lg" }; + const inputStyles: { backgroundColor: string; size: Size } = { + backgroundColor: "white", + size: "lg", + }; return ( { - - + isMulti + value={ + filters.runState === null + ? [] + : filters.runState + .split(",") + .map((option) => ({ label: option, value: option })) + } + onChange={(stateOptions) => + onRunStateChange( + stateOptions.map((stateOption) => stateOption.value).join(",") + ) + } + options={ + filters.runStateOptions === null + ? [] + : filters.runStateOptions + .split(",") + .map((option) => ({ label: option, value: option })) + } + placeholder="All State Types" + hideSelectedOptions + tagVariant="solid" + isClearable={false} + chakraStyles={{ + container: (provided) => ({ + ...provided, + bg: "white", + }), + }} + />