Anurag-S1ngh commented on code in PR #77095:
URL: https://github.com/apache/airflow/pull/77095#discussion_r4612800472


##########
airflow-core/src/airflow/config_templates/config.yml:
##########
@@ -2048,6 +2048,16 @@ api:
       type: boolean
       example: ~
       default: "False"
+    default_match_anywhere:
+      description: |
+        Default search mode for Dag and task search in the web UI. When set to 
``True``, search

Review Comment:
   Done, updated the wording as suggested. Commit a3dd38b621.



##########
airflow-core/src/airflow/ui/src/hooks/useUserSettings.test.tsx:
##########
@@ -155,12 +161,35 @@ describe("useClearKeepTaskStateDefault", () => {
 });
 
 describe("useDefaultMatchAnywhere", () => {

Review Comment:
   Updated. useAdvancedSearch.test.tsx now covers the server default and the 
stored value winning over it, and I added default_match_anywhere to the other 
config mocks and the MSW /ui/config handler. Commit fd30a878c6.



##########
airflow-core/src/airflow/ui/src/hooks/useUserSettings.ts:
##########
@@ -53,9 +54,16 @@ export const useDefaultTaskGroupsExpanded = () =>
 
 /**
  * Fallback for the per-searchbar "match anywhere" (substring) toggle: the 
value a searchbar uses
- * when neither the URL nor its own localStorage entry says otherwise. 
Defaults to off (prefix).
+ * when neither the URL nor its own localStorage entry says otherwise. The 
user's stored choice wins;
+ * when they never saved one, the admin's server-side default ([api] 
default_match_anywhere) is used,
+ * and defaults to off (prefix).
  */
-export const useDefaultMatchAnywhere = () => 
useLocalStorage<boolean>(DEFAULT_MATCH_ANYWHERE_KEY, false);
+export const useDefaultMatchAnywhere = () => {
+  const serverDefault = useConfig("default_match_anywhere");
+  const [stored, setStored] = useLocalStorage<boolean | 
undefined>(DEFAULT_MATCH_ANYWHERE_KEY, undefined);
+
+  return [stored ?? Boolean(serverDefault), setStored] as const;
+};

Review Comment:
   Done, switched it to the same useLocalStorage pattern as default_wrap. 
Commit fd30a878c6.



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