nytai commented on a change in pull request #10335:
URL: 
https://github.com/apache/incubator-superset/pull/10335#discussion_r460310881



##########
File path: superset-frontend/src/views/CRUD/dataset/DatasetList.tsx
##########
@@ -69,128 +66,191 @@ interface DatasetListProps {
   addDangerToast: (msg: string) => void;
   addSuccessToast: (msg: string) => void;
 }
+interface Database {
+  allow_csv_upload: boolean;
+  allow_ctas: boolean;
+  allow_cvas: null | boolean;
+  allow_dml: boolean;
+  allow_multi_schema_metadata_fetch: boolean;
+  allow_run_async: boolean;
+  allows_cost_estimate: boolean;
+  allows_subquery: boolean;
+  allows_virtual_table_explore: boolean;
+  backend: string;
+  database_name: string;
+  explore_database_id: number;
+  expose_in_sqllab: boolean;
+  force_ctas_schema: null | boolean;
+  function_names: string[];
+  id: number;
+}
+
+const createFetchDatabases = (handleError: (err: Response) => void) => async (
+  filterValue = '',
+  pageIndex?: number,
+  pageSize?: number,
+) => {
+  const resourceEndpoint = `/api/v1/database/`;
+
+  try {
+    const queryParams = rison.encode({
+      columns: ['database_name', 'id'],
+      keys: ['none'],
+      ...(pageIndex ? { page: pageIndex } : {}),
+      ...(pageSize ? { page_ize: pageSize } : {}),
+      ...(filterValue ? { filter: filterValue } : {}),
+    });
+    const { json = {} } = await SupersetClient.get({
+      endpoint: `${resourceEndpoint}?q=${queryParams}`,
+    });
+
+    return json?.result?.map(
+      ({ database_name: label, id: value }: Database) => ({
+        label,
+        value,
+      }),
+    );
+  } catch (e) {
+    console.error(e);

Review comment:
       yea I should probably move to using `handleError` in these views. Will 
look into a followup PR for doing that as it'll require some testing. 




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

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