Browse Source

fix(doc integrations): Sort DocIntegrations by popularity as well (#30974)

See API-2345

This PR sorts the doc integrations by popularity. We were ignoring their popularity values before, now they will be used to determine ranking on the integrations directory.
Leander Rodrigues 3 years ago
parent
commit
ea3b6dfcb5

+ 4 - 5
static/app/views/organizationIntegrations/integrationListDirectory.tsx

@@ -235,11 +235,10 @@ export class IntegrationListDirectory extends AsyncComponent<
   }
 
   getPopularityWeight = (integration: AppOrProviderOrPlugin) => {
-    return (
-      this.state.publishedApps?.find(i => i === integration)?.popularity ??
-      POPULARITY_WEIGHT[integration.slug] ??
-      1
-    );
+    if (isSentryApp(integration) || isDocIntegration(integration)) {
+      return integration?.popularity ?? 1;
+    }
+    return POPULARITY_WEIGHT[integration.slug] ?? 1;
   };
 
   sortByName = (a: AppOrProviderOrPlugin, b: AppOrProviderOrPlugin) =>

+ 7 - 6
tests/js/spec/views/organizationIntegrations/integrationListDirectory.spec.jsx

@@ -52,12 +52,13 @@ describe('IntegrationListDirectory', function () {
       expect(wrapper.find('IntegrationRow')).toHaveLength(7);
 
       [
-        'bitbucket',
-        'pagerduty',
-        'my-headband-washer-289499',
-        'clickup',
-        'amazon-sqs',
-        'la-croix-monitor',
+        'bitbucket', // 10
+        'pagerduty', // 10
+        'my-headband-washer-289499', // 10
+        'sample-doc', // 10
+        'clickup', // 9
+        'amazon-sqs', // 8
+        'la-croix-monitor', // 8
       ].map((name, index) =>
         expect(wrapper.find('IntegrationRow').at(index).props().slug).toEqual(name)
       );