kgabryje commented on code in PR #20668:
URL: https://github.com/apache/superset/pull/20668#discussion_r918706849


##########
superset-frontend/src/explore/ExplorePage.tsx:
##########
@@ -38,12 +45,58 @@ const fetchExploreData = () => {
   })(exploreUrlParams);
 };
 
+const useExploreInitialData = (
+  shouldUseDashboardData: boolean,
+  sliceId: string | null,
+) => {
+  const slice = useSelector<RootState, Slice | null>(({ sliceEntities }) =>
+    isDefined(sliceId) ? sliceEntities?.slices?.[sliceId] : null,
+  );
+  const formData = slice?.form_data;
+  const { id: datasourceId, type: datasourceType } = useSelector<
+    RootState,
+    { id: number | undefined; type: string | undefined }
+  >(({ datasources }) =>
+    formData?.datasource
+      ? pick(datasources[formData.datasource], ['id', 'type'])
+      : { id: undefined, type: undefined },
+  );
+  return useCallback(() => {
+    if (
+      !shouldUseDashboardData ||
+      !isDefined(slice) ||
+      !isDefined(formData) ||
+      !isDefined(datasourceId) ||
+      !isDefined(datasourceType)
+    ) {
+      return fetchExploreData();
+    }
+    return SupersetClient.get({
+      endpoint: `/datasource/get/${datasourceType}/${datasourceId}/`,

Review Comment:
   I propose we stick to the legacy `/datasource/get` endpoint for now and 
create a new `/v1/datasource` API in the future and refactor



-- 
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: notifications-unsubscr...@superset.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to