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


##########
airflow-core/src/airflow/ui/src/components/FilterBar/filters/TextSearchFilter.tsx:
##########
@@ -0,0 +1,66 @@
+/*!
+ * 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 { Input } from "@chakra-ui/react";
+import { useRef } from "react";
+import { useHotkeys } from "react-hotkeys-hook";
+
+import { FilterPill } from "../FilterPill";
+import type { FilterPluginProps } from "../types";
+
+export const TextSearchFilter = ({ filter, onChange, onRemove }: 
FilterPluginProps) => {
+  const inputRef = useRef<HTMLInputElement>(null);
+
+  const hasValue = filter.value !== null && filter.value !== undefined && 
String(filter.value).trim() !== "";
+
+  const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+    const newValue = event.target.value;
+
+    onChange(newValue || undefined);
+  };
+
+  useHotkeys(
+    "mod+k",
+    () => {
+      if (!filter.config.hotkeyDisabled) {
+        inputRef.current?.focus();
+      }
+    },
+    { enabled: !filter.config.hotkeyDisabled, preventDefault: true },
+  );
+
+  return (
+    <FilterPill
+      displayValue={hasValue ? String(filter.value) : ""}
+      filter={filter}
+      hasValue={hasValue}
+      onChange={onChange}
+      onRemove={onRemove}
+    >
+      <Input

Review Comment:
   Let's add a `startAddon` 
https://www.chakra-ui.com/docs/components/input#start-addon so we can keep the 
label while the user is editing the filter



##########
airflow-core/src/airflow/ui/src/components/FilterBar/filters/DateFilter.tsx:
##########
@@ -0,0 +1,60 @@
+/*!
+ * 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 { DateTimeInput } from "src/components/DateTimeInput";
+
+import { FilterPill } from "../FilterPill";
+import type { FilterPluginProps } from "../types";
+
+export const DateFilter = ({ filter, onChange, onRemove }: FilterPluginProps) 
=> {
+  const hasValue = filter.value !== null && filter.value !== undefined && 
String(filter.value).trim() !== "";
+  const displayValue = hasValue
+    ? new Date(String(filter.value)).toLocaleString("en-US", {
+        day: "2-digit",
+        hour: "2-digit",
+        minute: "2-digit",
+        month: "short",
+        year: "numeric",
+      })
+    : "";
+
+  const handleDateChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+    const { value } = event.target;
+
+    onChange(value || undefined);
+  };
+
+  return (
+    <FilterPill
+      displayValue={displayValue}
+      filter={filter}
+      hasValue={hasValue}
+      onChange={onChange}
+      onRemove={onRemove}
+    >
+      <DateTimeInput
+        borderRadius="full"
+        onChange={handleDateChange}
+        placeholder={filter.config.placeholder ?? `Select 
${filter.config.label.toLowerCase()}`}

Review Comment:
   Translation needed for this and other placeholders?



##########
airflow-core/src/airflow/ui/src/components/FilterBar/FilterBar.tsx:
##########
@@ -0,0 +1,179 @@
+/*!
+ * 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 { Button, HStack } from "@chakra-ui/react";
+import { useState, useCallback } from "react";
+import { useTranslation } from "react-i18next";
+import { MdAdd, MdClear } from "react-icons/md";
+import { useDebouncedCallback } from "use-debounce";
+
+import { Menu } from "src/components/ui";
+
+import { getDefaultFilterIcon } from "./defaultIcons";
+import { DateFilter } from "./filters/DateFilter";
+import { NumberFilter } from "./filters/NumberFilter";
+import { TextSearchFilter } from "./filters/TextSearchFilter";
+import type { FilterBarProps, FilterConfig, FilterState, FilterValue } from 
"./types";
+
+const defaultInitialValues: Record<string, FilterValue> = {};
+
+const getFilterIcon = (config: FilterConfig) => config.icon ?? 
getDefaultFilterIcon(config.type);
+
+export const FilterBar = ({
+  configs,
+  initialValues = defaultInitialValues,
+  maxVisibleFilters = 10,
+  onFiltersChange,
+}: FilterBarProps) => {
+  const { t: translate } = useTranslation();
+  const [filters, setFilters] = useState<Array<FilterState>>(() =>
+    Object.entries(initialValues)
+      .filter(([, value]) => value !== null && value !== undefined && value 
!== "")
+      .map(([key, value]) => {
+        const config = configs.find((con) => con.key === key);
+
+        if (!config) {
+          throw new Error(`Filter config not found for key: ${key}`);
+        }
+
+        return {
+          config,
+          id: `${key}-${Date.now()}`,
+          value,
+        };
+      }),
+  );
+
+  const debouncedOnFiltersChange = useDebouncedCallback((filtersRecord: 
Record<string, FilterValue>) => {
+    onFiltersChange(filtersRecord);
+  }, 100);
+
+  const updateFiltersRecord = useCallback(
+    (updatedFilters: Array<FilterState>) => {
+      const filtersRecord = updatedFilters.reduce<Record<string, 
FilterValue>>((accumulator, filter) => {
+        if (filter.value !== null && filter.value !== undefined && 
filter.value !== "") {
+          accumulator[filter.config.key] = filter.value;
+        }
+
+        return accumulator;
+      }, {});
+
+      debouncedOnFiltersChange(filtersRecord);
+    },
+    [debouncedOnFiltersChange],
+  );
+
+  const addFilter = (config: FilterConfig) => {
+    const newFilter: FilterState = {
+      config,
+      id: `${config.key}-${Date.now()}`,
+      value: config.defaultValue ?? "",
+    };
+
+    const updatedFilters = [...filters, newFilter];
+
+    setFilters(updatedFilters);
+    updateFiltersRecord(updatedFilters);
+  };
+
+  const updateFilter = (id: string, value: FilterValue) => {
+    const updatedFilters = filters.map((filter) => (filter.id === id ? { 
...filter, value } : filter));
+
+    setFilters(updatedFilters);
+    updateFiltersRecord(updatedFilters);
+  };
+
+  const removeFilter = (id: string) => {
+    const updatedFilters = filters.filter((filter) => filter.id !== id);
+
+    setFilters(updatedFilters);
+    updateFiltersRecord(updatedFilters);
+  };
+
+  const resetFilters = () => {
+    setFilters([]);
+    onFiltersChange({});
+  };
+
+  const availableConfigs = configs.filter(
+    (config) => !filters.some((filter) => filter.config.key === config.key),
+  );
+
+  const renderFilter = (filter: FilterState) => {
+    const props = {
+      filter,
+      onChange: (value: FilterValue) => updateFilter(filter.id, value),
+      onRemove: () => removeFilter(filter.id),
+    };
+
+    switch (filter.config.type) {
+      case "date":
+        return <DateFilter key={filter.id} {...props} />;
+      case "number":
+        return <NumberFilter key={filter.id} {...props} />;
+      case "text":
+        return <TextSearchFilter key={filter.id} {...props} />;
+      default:
+        return undefined;
+    }
+  };
+
+  return (
+    <HStack gap={2} wrap="wrap">
+      {filters.slice(0, maxVisibleFilters).map(renderFilter)}
+      {availableConfigs.length > 0 && (
+        <Menu.Root>
+          <Menu.Trigger asChild>
+            <Button
+              _hover={{ bg: "colorPalette.subtle" }}
+              bg="gray.muted"
+              borderRadius="full"
+              variant="outline"
+            >
+              <MdAdd />
+              {translate("common:filters.filter")}
+            </Button>
+          </Menu.Trigger>
+          <Menu.Content>
+            {availableConfigs.map((config) => (
+              <Menu.Item key={config.key} onClick={() => addFilter(config)} 
value={config.key}>
+                <HStack gap={2}>
+                  {getFilterIcon(config)}
+                  {config.label}
+                </HStack>
+              </Menu.Item>
+            ))}
+          </Menu.Content>
+        </Menu.Root>
+      )}
+      {filters.length > 0 && (
+        <Button
+          _hover={{ bg: "gray.100" }}

Review Comment:
   The reset button looks very different in light and dark mode.



##########
airflow-core/src/airflow/ui/src/components/FilterBar/FilterBar.tsx:
##########
@@ -0,0 +1,179 @@
+/*!
+ * 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 { Button, HStack } from "@chakra-ui/react";
+import { useState, useCallback } from "react";
+import { useTranslation } from "react-i18next";
+import { MdAdd, MdClear } from "react-icons/md";
+import { useDebouncedCallback } from "use-debounce";
+
+import { Menu } from "src/components/ui";
+
+import { getDefaultFilterIcon } from "./defaultIcons";
+import { DateFilter } from "./filters/DateFilter";
+import { NumberFilter } from "./filters/NumberFilter";
+import { TextSearchFilter } from "./filters/TextSearchFilter";
+import type { FilterBarProps, FilterConfig, FilterState, FilterValue } from 
"./types";
+
+const defaultInitialValues: Record<string, FilterValue> = {};
+
+const getFilterIcon = (config: FilterConfig) => config.icon ?? 
getDefaultFilterIcon(config.type);
+
+export const FilterBar = ({
+  configs,
+  initialValues = defaultInitialValues,
+  maxVisibleFilters = 10,
+  onFiltersChange,
+}: FilterBarProps) => {
+  const { t: translate } = useTranslation();
+  const [filters, setFilters] = useState<Array<FilterState>>(() =>
+    Object.entries(initialValues)
+      .filter(([, value]) => value !== null && value !== undefined && value 
!== "")
+      .map(([key, value]) => {
+        const config = configs.find((con) => con.key === key);
+
+        if (!config) {
+          throw new Error(`Filter config not found for key: ${key}`);
+        }
+
+        return {
+          config,
+          id: `${key}-${Date.now()}`,
+          value,
+        };
+      }),
+  );
+
+  const debouncedOnFiltersChange = useDebouncedCallback((filtersRecord: 
Record<string, FilterValue>) => {
+    onFiltersChange(filtersRecord);
+  }, 100);
+
+  const updateFiltersRecord = useCallback(
+    (updatedFilters: Array<FilterState>) => {
+      const filtersRecord = updatedFilters.reduce<Record<string, 
FilterValue>>((accumulator, filter) => {
+        if (filter.value !== null && filter.value !== undefined && 
filter.value !== "") {
+          accumulator[filter.config.key] = filter.value;
+        }
+
+        return accumulator;
+      }, {});
+
+      debouncedOnFiltersChange(filtersRecord);
+    },
+    [debouncedOnFiltersChange],
+  );
+
+  const addFilter = (config: FilterConfig) => {
+    const newFilter: FilterState = {
+      config,
+      id: `${config.key}-${Date.now()}`,
+      value: config.defaultValue ?? "",
+    };
+
+    const updatedFilters = [...filters, newFilter];
+
+    setFilters(updatedFilters);
+    updateFiltersRecord(updatedFilters);
+  };
+
+  const updateFilter = (id: string, value: FilterValue) => {
+    const updatedFilters = filters.map((filter) => (filter.id === id ? { 
...filter, value } : filter));
+
+    setFilters(updatedFilters);
+    updateFiltersRecord(updatedFilters);
+  };
+
+  const removeFilter = (id: string) => {
+    const updatedFilters = filters.filter((filter) => filter.id !== id);
+
+    setFilters(updatedFilters);
+    updateFiltersRecord(updatedFilters);
+  };
+
+  const resetFilters = () => {
+    setFilters([]);
+    onFiltersChange({});
+  };
+
+  const availableConfigs = configs.filter(
+    (config) => !filters.some((filter) => filter.config.key === config.key),
+  );
+
+  const renderFilter = (filter: FilterState) => {
+    const props = {
+      filter,
+      onChange: (value: FilterValue) => updateFilter(filter.id, value),
+      onRemove: () => removeFilter(filter.id),
+    };
+
+    switch (filter.config.type) {
+      case "date":
+        return <DateFilter key={filter.id} {...props} />;
+      case "number":
+        return <NumberFilter key={filter.id} {...props} />;
+      case "text":
+        return <TextSearchFilter key={filter.id} {...props} />;
+      default:
+        return undefined;
+    }
+  };
+
+  return (
+    <HStack gap={2} wrap="wrap">
+      {filters.slice(0, maxVisibleFilters).map(renderFilter)}
+      {availableConfigs.length > 0 && (
+        <Menu.Root>
+          <Menu.Trigger asChild>
+            <Button
+              _hover={{ bg: "colorPalette.subtle" }}
+              bg="gray.muted"
+              borderRadius="full"
+              variant="outline"
+            >
+              <MdAdd />
+              {translate("common:filters.filter")}
+            </Button>
+          </Menu.Trigger>
+          <Menu.Content>
+            {availableConfigs.map((config) => (
+              <Menu.Item key={config.key} onClick={() => addFilter(config)} 
value={config.key}>
+                <HStack gap={2}>
+                  {getFilterIcon(config)}
+                  {config.label}
+                </HStack>
+              </Menu.Item>
+            ))}
+          </Menu.Content>
+        </Menu.Root>
+      )}
+      {filters.length > 0 && (
+        <Button
+          _hover={{ bg: "gray.100" }}

Review Comment:
   We should try to use semantic colors that adjust to light/dark mode so maybe 
`gray.subtle` or `bg.muted`?



##########
airflow-core/src/airflow/ui/src/pages/XCom/XComFilters.tsx:
##########
@@ -16,206 +16,76 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { Box, Button, HStack, Text, VStack } from "@chakra-ui/react";
-import { useCallback, useMemo, useState } from "react";
-import { useTranslation } from "react-i18next";
-import { LuX } from "react-icons/lu";
-import { useSearchParams, useParams } from "react-router-dom";
+import { VStack } from "@chakra-ui/react";
+import { useMemo } from "react";
+import { useParams } from "react-router-dom";
 
-import { useTableURLState } from "src/components/DataTable/useTableUrlState";
-import { DateTimeInput } from "src/components/DateTimeInput";
-import { SearchBar } from "src/components/SearchBar";
-import { NumberInputField, NumberInputRoot } from 
"src/components/ui/NumberInput";
+import { FilterBar, type FilterConfig, type FilterValue } from 
"src/components/FilterBar";
+import { useFilterConfigs } from "src/constants/filterConfigs";
 import { SearchParamsKeys } from "src/constants/searchParams";
-
-const FILTERS = [
-  {
-    hotkeyDisabled: false,
-    key: SearchParamsKeys.KEY_PATTERN,
-    translationKey: "keyPlaceholder",
-    type: "search",
-  },
-  {
-    hotkeyDisabled: true,
-    key: SearchParamsKeys.DAG_DISPLAY_NAME_PATTERN,
-    translationKey: "dagDisplayNamePlaceholder",
-    type: "search",
-  },
-  {
-    hotkeyDisabled: true,
-    key: SearchParamsKeys.RUN_ID_PATTERN,
-    translationKey: "runIdPlaceholder",
-    type: "search",
-  },
-  {
-    hotkeyDisabled: true,
-    key: SearchParamsKeys.TASK_ID_PATTERN,
-    translationKey: "taskIdPlaceholder",
-    type: "search",
-  },
-  {
-    hotkeyDisabled: true,
-    key: SearchParamsKeys.MAP_INDEX,
-    translationKey: "mapIndexPlaceholder",
-    type: "number",
-  },
-  {
-    key: SearchParamsKeys.LOGICAL_DATE_GTE,
-    translationKey: "logicalDateFromPlaceholder",
-    type: "datetime",
-  },
-  {
-    key: SearchParamsKeys.LOGICAL_DATE_LTE,
-    translationKey: "logicalDateToPlaceholder",
-    type: "datetime",
-  },
-  {
-    key: SearchParamsKeys.RUN_AFTER_GTE,
-    translationKey: "runAfterFromPlaceholder",
-    type: "datetime",
-  },
-  {
-    key: SearchParamsKeys.RUN_AFTER_LTE,
-    translationKey: "runAfterToPlaceholder",
-    type: "datetime",
-  },
-] as const satisfies ReadonlyArray<{
-  readonly hotkeyDisabled?: boolean;
-  readonly key: string;
-  readonly translationKey: string;
-  readonly type: "datetime" | "number" | "search";
-}>;
+import { useFiltersHandler } from "src/utils";
 
 export const XComFilters = () => {
-  const [searchParams, setSearchParams] = useSearchParams();
   const { dagId = "~", mapIndex = "-1", runId = "~", taskId = "~" } = 
useParams();
-  const { setTableURLState, tableURLState } = useTableURLState();
-  const { pagination, sorting } = tableURLState;
-  const { t: translate } = useTranslation(["browse", "common"]);
-  const [resetKey, setResetKey] = useState(0);
+  const { getFilterConfig } = useFilterConfigs();
 
-  const visibleFilters = useMemo(
-    () =>
-      FILTERS.filter((filter) => {
-        switch (filter.key) {
-          case SearchParamsKeys.DAG_DISPLAY_NAME_PATTERN:
-            return dagId === "~";
-          case SearchParamsKeys.KEY_PATTERN:
-          case SearchParamsKeys.LOGICAL_DATE_GTE:
-          case SearchParamsKeys.LOGICAL_DATE_LTE:
-          case SearchParamsKeys.RUN_AFTER_GTE:
-          case SearchParamsKeys.RUN_AFTER_LTE:
-            return true;
-          case SearchParamsKeys.MAP_INDEX:
-            return mapIndex === "-1";
-          case SearchParamsKeys.RUN_ID_PATTERN:
-            return runId === "~";
-          case SearchParamsKeys.TASK_ID_PATTERN:
-            return taskId === "~";
-          default:
-            return true;
-        }
-      }),
-    [dagId, mapIndex, runId, taskId],
-  );
+  const filterConfigs: Array<FilterConfig> = useMemo(() => {
+    const configs: Array<FilterConfig> = [
+      getFilterConfig(SearchParamsKeys.KEY_PATTERN),
+      getFilterConfig(SearchParamsKeys.LOGICAL_DATE_GTE),
+      getFilterConfig(SearchParamsKeys.LOGICAL_DATE_LTE),
+      getFilterConfig(SearchParamsKeys.RUN_AFTER_GTE),
+      getFilterConfig(SearchParamsKeys.RUN_AFTER_LTE),
+    ];
 
-  const handleFilterChange = useCallback(
-    (paramKey: string) => (value: string) => {
-      if (value === "") {
-        searchParams.delete(paramKey);
-      } else {
-        searchParams.set(paramKey, value);
-      }
-      setTableURLState({
-        pagination: { ...pagination, pageIndex: 0 },
-        sorting,
-      });
-      setSearchParams(searchParams);
-    },
-    [pagination, searchParams, setSearchParams, setTableURLState, sorting],
-  );
+    if (dagId === "~") {
+      configs.push(getFilterConfig(SearchParamsKeys.DAG_DISPLAY_NAME_PATTERN));
+    }
 
-  const filterCount = useMemo(
-    () =>
-      visibleFilters.filter((filter) => {
-        const value = searchParams.get(filter.key);
+    if (runId === "~") {
+      configs.push(getFilterConfig(SearchParamsKeys.RUN_ID_PATTERN));
+    }
 
-        return value !== null && value !== "";
-      }).length,
-    [searchParams, visibleFilters],
-  );
+    if (taskId === "~") {
+      configs.push(getFilterConfig(SearchParamsKeys.TASK_ID_PATTERN));
+    }
 
-  const handleResetFilters = useCallback(() => {
-    visibleFilters.forEach((filter) => {
-      searchParams.delete(filter.key);
-    });
-    setTableURLState({
-      pagination: { ...pagination, pageIndex: 0 },
-      sorting,
-    });
-    setSearchParams(searchParams);
-    setResetKey((prev) => prev + 1);
-  }, [pagination, searchParams, setSearchParams, setTableURLState, sorting, 
visibleFilters]);
+    if (mapIndex === "-1") {
+      configs.push(getFilterConfig(SearchParamsKeys.MAP_INDEX));
+    }
 
-  const renderFilterInput = (filter: (typeof FILTERS)[number]) => {
-    const { key, translationKey, type } = filter;
+    return configs;
+  }, [dagId, mapIndex, runId, taskId, getFilterConfig]);
 
-    return (
-      <Box key={key} w="200px">
-        <Box marginBottom={1} minHeight="1.2em">
-          {type !== "search" && <Text 
fontSize="xs">{translate(`common:filters.${translationKey}`)}</Text>}
-        </Box>
-        {type === "search" ? (
-          (() => {
-            const { hotkeyDisabled } = filter;
+  const { handleFiltersChange, searchParams } = 
useFiltersHandler(filterConfigs);

Review Comment:
   Could we call `getFilterConfig` inside of `useFiltersHandler` instead of 
manually calling the function for every single search param key?



##########
airflow-core/src/airflow/ui/src/constants/filterConfigs.tsx:
##########
@@ -0,0 +1,110 @@
+/*!
+ * 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 { useMemo } from "react";
+import { useTranslation } from "react-i18next";
+import { FiBarChart } from "react-icons/fi";
+import { MdDateRange, MdNumbers, MdSearch } from "react-icons/md";
+
+import { DagIcon } from "src/assets/DagIcon";
+import { TaskIcon } from "src/assets/TaskIcon";
+import type { FilterConfig } from "src/components/FilterBar";
+
+import { SearchParamsKeys } from "./searchParams";
+
+/**
+ * Hook to get filter configurations with translations
+ */
+export const useFilterConfigs = () => {
+  const { t: translate } = useTranslation(["browse", "common", "admin"]);
+
+  const filterConfigMap = useMemo(
+    () => ({
+      [SearchParamsKeys.DAG_DISPLAY_NAME_PATTERN]: {
+        hotkeyDisabled: true,
+        icon: <DagIcon />,
+        label: translate("common:dagName"),
+        placeholder: translate("common:filters.dagDisplayNamePlaceholder"),
+        type: "text" as const,
+      },
+      [SearchParamsKeys.KEY_PATTERN]: {
+        icon: <MdSearch />,
+        label: translate("admin:columns.key"),
+        placeholder: translate("common:filters.keyPlaceholder"),
+        type: "text" as const,
+      },
+      [SearchParamsKeys.LOGICAL_DATE_GTE]: {
+        icon: <MdDateRange />,
+        label: translate("common:filters.logicalDateFromPlaceholder"),
+        placeholder: translate("common:filters.logicalDateFromPlaceholder"),
+        type: "date" as const,
+      },
+      [SearchParamsKeys.LOGICAL_DATE_LTE]: {
+        icon: <MdDateRange />,
+        label: translate("common:filters.logicalDateToPlaceholder"),
+        placeholder: translate("common:filters.logicalDateToPlaceholder"),
+        type: "date" as const,
+      },
+      [SearchParamsKeys.MAP_INDEX]: {
+        icon: <MdNumbers />,
+        label: translate("common:mapIndex"),
+        min: -1,
+        placeholder: translate("common:filters.mapIndexPlaceholder"),
+        type: "number" as const,
+      },
+      [SearchParamsKeys.RUN_AFTER_GTE]: {
+        icon: <MdDateRange />,
+        label: translate("common:filters.runAfterFromPlaceholder"),
+        placeholder: translate("common:filters.runAfterFromPlaceholder"),
+        type: "date" as const,
+      },
+      [SearchParamsKeys.RUN_AFTER_LTE]: {
+        icon: <MdDateRange />,
+        label: translate("common:filters.runAfterToPlaceholder"),
+        placeholder: translate("common:filters.runAfterToPlaceholder"),
+        type: "date" as const,
+      },
+      [SearchParamsKeys.RUN_ID_PATTERN]: {
+        hotkeyDisabled: true,
+        icon: <FiBarChart />,
+        label: translate("common:runId"),
+        placeholder: translate("common:filters.runIdPlaceholder"),
+        type: "text" as const,
+      },
+      [SearchParamsKeys.TASK_ID_PATTERN]: {
+        hotkeyDisabled: true,
+        icon: <TaskIcon />,
+        label: translate("common:taskId"),
+        placeholder: translate("common:filters.taskIdPlaceholder"),
+        type: "text" as const,
+      },
+    }),
+    [translate],

Review Comment:
   We don't actually want to memoize here. The translate function doesn't 
change so these will never change.



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