yimingpeng commented on code in PR #56163:
URL: https://github.com/apache/airflow/pull/56163#discussion_r2401160461


##########
airflow-core/src/airflow/ui/src/pages/Dashboard/PoolSummary/PoolSummary.tsx:
##########
@@ -23,19 +23,30 @@ import { Link as RouterLink } from "react-router-dom";
 
 import { useAuthLinksServiceGetAuthMenus } from "openapi/queries";
 import { usePoolServiceGetPools } from "openapi/queries/queries";
+import type { ExpandedApiError } from "src/components/ErrorAlert";
 import { PoolBar } from "src/components/PoolBar";
 import { useAutoRefresh } from "src/utils";
 import { type Slots, slotKeys } from "src/utils/slots";
 
 export const PoolSummary = () => {
   const { t: translate } = useTranslation("dashboard");
   const refetchInterval = useAutoRefresh({ checkPendingRuns: true });
-  const { data, isLoading } = usePoolServiceGetPools(undefined, undefined, {
-    refetchInterval,
-  });
+
   const { data: authLinks } = useAuthLinksServiceGetAuthMenus();
   const hasPoolsAccess = authLinks?.authorized_menu_items.includes("Pools");
 
+  const { data, error, isLoading } = usePoolServiceGetPools(undefined, 
undefined, {
+    refetchInterval: (query) => {
+      const apiError = query.state.error as ExpandedApiError | null;
+
+      return apiError?.status === 403 ? false : refetchInterval;
+    },
+  });
+
+  if (Boolean(error) && (error as ExpandedApiError).status === 403) {
+    return undefined;
+  }
+

Review Comment:
   Thanks for the great suggestion, @pierrejeambrun 
   
   I've been testing the proposed changes and found that using `AxiosError` and 
`ApiError` produce different UI behaviors? Perhaps I've done something wrong 
here, so before proceeding further, I would like to seek some clarification on 
expected behavoirs, also I am still learning and investigating why, it would be 
appreciated if you can share some insights, thanks. 
   
   The following is a summary of the differences.
   
   ### Test Scenario 1: Only `can read on Pools` (menu access stays)
   Simply put, using the `ApiError` will hide everything relating to Pools 
Slots/Menu whereas using `AxiosError` will leave a lable of `Pool Slots` & 
`Manage Pools` on the UI. 
   #### using `AxiosError`
   <img width="3404" height="1644" alt="Pasted image 20251002161504" 
src="https://github.com/user-attachments/assets/f401045f-267e-4794-9143-41543bf00b76";
 />
   
   #### using `ApiError`
   <img width="3460" height="1856" alt="Pasted image 20251002161546" 
src="https://github.com/user-attachments/assets/36e7125b-04ac-43db-ad9a-72a6c2658824";
 />
   
   ### Test Scenario 2: Both `can read on Pools` and `menu access on Pools` 
removed
   The use of the `ApiError` still hides everything about Pools, but if using 
`AxiosError`, only the label `Pool Slots` left.
   #### using `AxiosError`
   <img width="3392" height="1710" alt="image" 
src="https://github.com/user-attachments/assets/eb073ed4-09db-4c1c-a1c0-cdad33d7e342";
 />
   
   #### using `ApiError`
   <img width="3460" height="1856" alt="Pasted image 20251002161546" 
src="https://github.com/user-attachments/assets/36e7125b-04ac-43db-ad9a-72a6c2658824";
 />
   
   ### Test Scenario 3: Only `menu access on Pools` removed (`can read on 
Pools` stays)
   This should be fine, they are the same. 
   #### using `AxiosError`
   <img width="3400" height="1512" alt="image" 
src="https://github.com/user-attachments/assets/443bbf70-e03d-4408-a4eb-cac5d7d97425";
 />
   
   #### using `ApiError`
   <img width="1917" height="791" alt="image" 
src="https://github.com/user-attachments/assets/7f4e5c58-2421-413e-adc7-69b23d3bd8b0";
 />
   
   
   



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