msyavuz commented on code in PR #34620:
URL: https://github.com/apache/superset/pull/34620#discussion_r2263330714


##########
superset-frontend/src/components/Chart/ChartContextMenu/ChartContextMenu.tsx:
##########
@@ -166,43 +157,17 @@ const ChartContextMenu = (
     canDrillBy &&
     isDisplayed(ContextMenuItem.DrillBy);
 
-  useEffect(() => {
-    async function fetchDataset() {
-      if (!visible || dataset || (!showDrillBy && !showDrillToDetail)) return;
-
-      const datasetId = Number(formData.datasource.split('__')[0]);
-      try {
-        setIsLoadingDataset(true);
-        let response;
-
-        if (loadDrillByOptionsExtension) {
-          response = await loadDrillByOptionsExtension(datasetId, formData);
-        } else {
-          const endpoint = 
`/api/v1/dataset/${datasetId}/drill_info/?q=(dashboard_id:${dashboardId})`;
-          response = await cachedSupersetGet({ endpoint });
-        }
-
-        const { json } = response;
-        const { result } = json;
-
-        setDataset(result);
-      } catch (error) {
-        logging.error('Failed to load dataset:', error);
-        supersetGetCache.delete(`/api/v1/dataset/${datasetId}/drill_info/`);
-      } finally {
-        setIsLoadingDataset(false);
-      }
-    }
-
-    fetchDataset();
-  }, [
-    visible,
-    showDrillBy,
-    showDrillToDetail,
+  const datasetResource = useDatasetDrillInfo(
     formData.datasource,
-    loadDrillByOptionsExtension,
     dashboardId,
-  ]);
+    formData,
+  );
+
+  const dataset =
+    datasetResource.status === ResourceStatus.Complete
+      ? datasetResource.result
+      : undefined;

Review Comment:
   Is this defaulting to undefined correct here? I don't think it makes sense 
to do this if we are going to assert types below.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to