rtexelm commented on code in PR #27022:
URL: https://github.com/apache/superset/pull/27022#discussion_r1522433233


##########
superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.jsx:
##########
@@ -298,74 +306,142 @@ class AnnotationLayer extends React.PureComponent {
     });
   }
 
-  fetchOptions(annotationType, sourceType, isLoadingOptions) {
-    if (isLoadingOptions) {
-      if (sourceType === ANNOTATION_SOURCE_TYPES.NATIVE) {
-        const queryParams = rison.encode({
-          page: 0,
-          page_size: FILTER_OPTIONS_LIMIT,
-        });
-        SupersetClient.get({
-          endpoint: `/api/v1/annotation_layer/?q=${queryParams}`,
-        }).then(({ json }) => {
-          const layers = json
-            ? json.result.map(layer => ({
-                value: layer.id,
-                label: layer.name,
-              }))
-            : [];
-          this.setState({
-            isLoadingOptions: false,
-            valueOptions: layers,
-          });
-        });
-      } else if (requiresQuery(sourceType)) {
-        const queryParams = rison.encode({
-          filters: [
-            {
-              col: 'id',
-              opr: 'chart_owned_created_favored_by_me',
-              value: true,
+  handleTextValue(inputValue) {
+    this.setState({
+      value: inputValue,
+    });
+  }
+
+  asyncFetch = async (_, page, pageSize) => {
+    const { annotationType, sourceType } = this.state;
+
+    if (sourceType === ANNOTATION_SOURCE_TYPES.NATIVE) {
+      const queryParams = rison.encode({
+        page,
+        page_size: pageSize,
+      });
+
+      const { json } = await SupersetClient.get({
+        endpoint: `/api/v1/annotation_layer/?q=${queryParams}`,
+      });
+
+      const { result, count } = json;
+
+      const layersObj = result.reduce((acc, layer) => {
+        acc[layer.id] = {
+          value: layer.id,
+          label: layer.name,
+        };
+        return acc;
+      }, {});
+
+      const layersArray = Object.values(layersObj);
+
+      this.setState(prevState => ({
+        valueOptions: { ...prevState.valueOptions, ...layersObj },
+      }));
+
+      return {
+        data: layersArray,
+        totalCount: count,
+      };
+    }
+
+    if (requiresQuery(sourceType)) {

Review Comment:
   hopefully I addressed this correctly



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