bbovenzi commented on code in PR #70149:
URL: https://github.com/apache/airflow/pull/70149#discussion_r3622730545


##########
airflow-core/src/airflow/ui/src/pages/ReactPlugin.tsx:
##########
@@ -67,15 +82,37 @@ const loadPlugin = (reactApp: ReactAppResponse): Promise<{ 
default: PluginCompon
 export const ReactPlugin = ({ reactApp }: { readonly reactApp: 
ReactAppResponse }) => {
   const { assetId, dagId, mapIndex, runId, taskId } = useParams();
 
-  // The asset URI is not part of the route, so resolve it from the asset 
record. This is a
-  // cache hit because the asset details page has already fetched it.
+  // Context objects are not part of the route, so resolve them from the query 
cache. Each query
+  // is gated on the route params it needs, so it stays disabled where those 
params are absent
+  // (e.g. base/dashboard mounts) and is a cache hit where the parent details 
page already fetched.
   const { data: asset } = useAssetServiceGetAsset(
     { assetId: assetId === undefined ? 0 : parseInt(assetId, 10) },
     undefined,
     { enabled: Boolean(assetId) },
   );
   const assetUri = asset?.uri;
 
+  const { data: dag } = useDagServiceGetDagDetails({ dagId: dagId ?? "" }, 
undefined, {
+    enabled: Boolean(dagId),
+  });
+
+  const { data: dagRun } = useDagRunServiceGetDagRun(
+    { dagId: dagId ?? "", dagRunId: runId ?? "" },
+    undefined,
+    { enabled: Boolean(dagId) && Boolean(runId) },
+  );
+
+  const { data: taskInstance } = useTaskInstanceServiceGetMappedTaskInstance(
+    {
+      dagId: dagId ?? "",
+      dagRunId: runId ?? "",
+      mapIndex: mapIndex === undefined ? -1 : parseInt(mapIndex, 10),
+      taskId: taskId ?? "",
+    },
+    undefined,
+    { enabled: Boolean(dagId) && Boolean(runId) && Boolean(taskId) },
+  );

Review Comment:
   These _should_ be fine  and not firing any extra queries since they should 
already be cached.



##########
airflow-core/src/airflow/ui/src/pages/ReactPlugin.tsx:
##########
@@ -85,12 +122,16 @@ export const ReactPlugin = ({ reactApp }: { readonly 
reactApp: ReactAppResponse
 
     return (
       <Plugin
+        asset={asset}
         assetId={assetId}
         assetUri={assetUri}
+        dag={dag}
         dagId={dagId}
+        dagRun={dagRun}
         mapIndex={mapIndex}
         runId={runId}
         taskId={taskId}
+        taskInstance={taskInstance}

Review Comment:
   Let's just make this a `const pluginProps = {}` and then we can pass the 
same content to plugin and lazy plugin. A little more DRY



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