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


##########
airflow-core/src/airflow/ui/public/i18n/locales/en/dag.json:
##########
@@ -149,6 +149,10 @@
         "description": "Dag parsing request failed. There could be pending 
parsing requests yet to be processed.",
         "title": "Dag Failed to Reparse"
       },
+      "forbidden": {
+        "description": "You do not have permission to reparse this DAG.",
+        "title": "Access Denied"
+      },

Review Comment:
   Here we can move that to 'common.json' and update this to a generic message.
   `"You do not have permission to perform this action."`



##########
airflow-core/src/airflow/ui/src/queries/useDagParsing.ts:
##########
@@ -24,16 +24,23 @@ import {
   UseDagServiceGetDagDetailsKeyFn,
   UseDagSourceServiceGetDagSourceKeyFn,
 } from "openapi/queries";
+import { ApiError } from "openapi/requests";
 import { toaster } from "src/components/ui";
 
 export const useDagParsing = ({ dagId }: { readonly dagId: string }) => {
   const queryClient = useQueryClient();
   const { t: translate } = useTranslation("dag");
 
-  const onError = () => {
+  const onError = (error: unknown) => {
+    const isForbidden = error instanceof ApiError && error.status === 403;
+
     toaster.create({
-      description: translate("parse.toaster.error.description"),
-      title: translate("parse.toaster.error.title"),
+      description: isForbidden
+        ? translate("parse.toaster.forbidden.description")
+        : translate("parse.toaster.error.description"),
+      title: isForbidden
+        ? translate("parse.toaster.forbidden.title")
+        : translate("parse.toaster.error.title"),
       type: "error",

Review Comment:
   Move this toaster creation to a common function handler use it everywhere we 
create an 'error' toaster basically. `const createToaster = (error ?:) => {}`
   
   Then https://github.com/apache/airflow/pull/61588 will take care of removing 
all the calls to the manual toaster handler and centralize this into a 
MutationCache.



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