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


##########
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:
   You should be able to get away with something like this. It will avoid hard 
casting at multiple places with `as`.
   
   ```suggestion
       const { data, error, isLoading } = usePoolServiceGetPools<
       PoolServiceGetPoolsDefaultResponse,
       AxiosError<HTTPExceptionResponse>
     >(undefined, undefined, {
       refetchInterval: (query) => {
         const apiError = query.state.error;
   
         return apiError?.status === 403 ? false : refetchInterval;
       },
     });
   
     if (error?.response?.status === 403) {
       return undefined;
     }
   ```



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to