Add infinite scroll to GitHub organizations box

What does this MR do and why?

Since the backend does not provide pageInfo, we assume there are more items to load when the response is exactly 25 items (PAGE_LENGTH in github_groups_controller.rb).

Changelog: changed

References

Related to #526310 (closed)

Screenshots or screen recordings

GitHub_organizations_with_infinite_scroll

How to set up and validate locally

  1. Click + (Create new...) in the sidebar and select New project/repository.
  2. Select Import project then choose GitHub.
  3. Create a GitHub PAT and fill it in the field. Click Authenticate.
  4. On the page "Import repositories from GitHub", select the Organizations tab.
  5. Apply this diff to simulate multiple pages of organizations:
diff --git a/app/controllers/import/github_groups_controller.rb b/app/controllers/import/github_groups_controller.rb
index 0585df9dd848..35c1d5da1e05 100644
--- a/app/controllers/import/github_groups_controller.rb
+++ b/app/controllers/import/github_groups_controller.rb
@@ -24,6 +24,8 @@ def serialized_provider_groups
     end
 
     def importable_orgs
+      return generate_dummy_orgs(PAGE_LENGTH) if Rails.env.development?
+
       client_orgs.map(&:to_h)
     end
 
@@ -53,5 +55,16 @@ def access_token_key
     def provider_name
       :github
     end
+
+    def generate_dummy_orgs(count)
+      return [] if pagination_options[:page] > 3
+
+      (1..count).map do |i|
+        {
+          login: "Organization #{i + (pagination_options[:page] - 1) * PAGE_LENGTH}",
+          description: "Description for Organization #{i + (pagination_options[:page] - 1) * PAGE_LENGTH}"
+        }
+      end
+    end
   end
 end

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading