pierrejeambrun commented on code in PR #55811:
URL: https://github.com/apache/airflow/pull/55811#discussion_r2394831710


##########
airflow-core/src/airflow/ui/src/pages/Dag/Tasks/TaskFilters/TaskFilters.tsx:
##########
@@ -78,59 +53,129 @@ export const TaskFilters = ({ tasksData }: { readonly 
tasksData: TaskCollectionR
     { key: "true", label: translate("mapped") },
     { key: "false", label: translate("notMapped") },
   ];
-  const taskNamePattern = searchParams.get(NAME_PATTERN) ?? "";
-  const handleSearchChange = (value: string) => {
-    if (value) {
-      searchParams.set(NAME_PATTERN, value);
-    } else {
-      searchParams.delete(NAME_PATTERN);
+
+  // Convert to FilterBar select option shape (label/value)
+  const operatorOptions = allOperatorNames
+    .map((value) => ({ label: value, value }))
+    .sort((left, right) => left.label.localeCompare(right.label));
+  const triggerRuleOptions = allTriggerRules
+    .map((value) => ({ label: value, value }))
+    .sort((left, right) => left.label.localeCompare(right.label));
+  const retryValueOptions = allRetryValues
+    .map((value) => ({ label: value, value }))
+    .sort((left, right) => left.label.localeCompare(right.label));
+  const mappedOptions = allMappedValues.map(({ key, label }) => ({ label, 
value: key }));
+
+  // Narrow falsy entries without hard casts
+  const isFilterConfig = (x: FilterConfig | false): x is FilterConfig => x !== 
false;
+
+  // FilterBar configs (keys unchanged; labels stick to prior wording)
+  const configsUnfiltered: Array<FilterConfig | false> = [
+    {
+      hotkeyDisabled: true,
+      key: NAME_PATTERN,
+      label: translate("searchTasks"),
+      placeholder: translate("searchTasks"),
+      type: "text",
+    },
+    operatorOptions.length > 0 && {
+      key: OPERATOR,
+      label: translate("selectOperator", { defaultValue: "Operators" }),
+      multiple: true,
+      options: operatorOptions,
+      type: "select",
+    },
+    triggerRuleOptions.length > 0 && {
+      key: TRIGGER_RULE,
+      label: translate("selectTriggerRules", { defaultValue: "Trigger rules" 
}),
+      multiple: true,
+      options: triggerRuleOptions,
+      type: "select",
+    },
+    retryValueOptions.length > 0 && {
+      key: RETRIES,
+      label: translate("retries", { defaultValue: "Retry values" }),
+      multiple: true,
+      options: retryValueOptions,
+      type: "select",
+    },
+    {
+      key: MAPPED,
+      label: translate("mapped", { defaultValue: "Mapped" }),
+      multiple: false,
+      options: mappedOptions,
+      type: "select",
+    },
+  ];
+
+  // Make this a mutable array type to satisfy FilterBar's prop
+  const configs: Array<FilterConfig> = 
configsUnfiltered.filter(isFilterConfig);
+
+  // Initial values mirror previous local names
+  const initialValues = {
+    [MAPPED]: selectedMapped,
+    [NAME_PATTERN]: taskNamePattern || undefined,
+    [OPERATOR]: selectedOperators.length ? selectedOperators : undefined,
+    [RETRIES]: selectedRetries.length ? selectedRetries : undefined,
+    [TRIGGER_RULE]: selectedTriggerRules.length ? selectedTriggerRules : 
undefined,
+  };
+
+  // Single place to write the URL params (replaces the old individual 
handlers)
+  const onFiltersChange = (record: Record<string, unknown>): void => {
+    const next = new URLSearchParams(searchParams);
+
+    // clear the filter-related keys before writing
+    [NAME_PATTERN, OPERATOR, TRIGGER_RULE, RETRIES, MAPPED, 
"page"].forEach((key) => next.delete(key));

Review Comment:
   Filters are not persisted to the URL query params.



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