kgabryje commented on a change in pull request #16200:
URL: https://github.com/apache/superset/pull/16200#discussion_r687824785



##########
File path: superset-frontend/src/addSlice/AddSliceContainer.tsx
##########
@@ -126,19 +118,47 @@ export default class AddSliceContainer extends 
React.PureComponent<
     window.location.href = this.exploreUrl();
   }
 
-  changeDatasource(value: string) {
-    this.setState({
-      datasourceValue: value,
-      datasourceId: value.split('__')[0],
-    });
+  changeDatasource(datasource: { label: string; value: string }) {
+    this.setState({ datasource });
   }
 
   changeVisType(visType: string | null) {
     this.setState({ visType });
   }
 
   isBtnDisabled() {
-    return !(this.state.datasourceId && this.state.visType);
+    return !(this.state.datasource?.value && this.state.visType);
+  }
+
+  loadDatasources(search: string, page: number, pageSize: number) {
+    const query = rison.encode({
+      columns: ['id', 'table_name', 'description', 'datasource_type'],
+      filter: search,
+      page,
+      page_size: pageSize,
+    });
+    return SupersetClient.get({
+      endpoint: `/api/v1/dataset?q=${query}`,
+    }).then(response => {
+      const list = response.json.result.map(
+        (item: {
+          id: number;
+          table_name: string;
+          description: string;
+          datasource_type: string;
+        }) => ({
+          value: `${item.id}__${item.datasource_type}`,
+          label: item.table_name,
+          title: `${item.table_name}\n\n${

Review comment:
       Can we replace `\n\n` with a span with some padding, so that we have 
more control over the spacings and can use grid unit from theme?




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