Skip to content

Fix instance templates pagination (17-0-stable-ee)

What does this MR do and why?

This is a backport of !152921 (merged) to 17-0-stable-ee (see request for backport)

Fixes the broken UI when paginating instance templates on the new project (from template) page.

MR acceptance checklist

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

Screenshots or screen recordings

Before After
Screen_Recording_2024-05-15_at_09.07.19.2024-05-15_09_15_02 Screen_Recording_2024-05-15_at_09.11.03.2024-05-15_09_16_19

How to set up and validate locally

Note: Testing requires an instance with many Project templates, for testing it might be easier to force pagination with the following patch

diff --git a/ee/app/controllers/ee/users_controller.rb b/ee/app/controllers/ee/users_controller.rb
index 4caf45581ab4..a21cfeb44593 100644
--- a/ee/app/controllers/ee/users_controller.rb
+++ b/ee/app/controllers/ee/users_controller.rb
@@ -22,7 +22,7 @@ module UsersController
     # https://gitlab.com/gitlab-org/gitlab/-/issues/345897
     def available_project_templates
       @custom_project_templates = # rubocop:disable Gitlab/ModuleWithInstanceVariables
-        user.available_custom_project_templates(search: params[:search]).page(params[:page])
+        user.available_custom_project_templates(search: params[:search]).page(params[:page]).per(3)
 
       render layout: false
     end
  1. Create a new group.
  2. Navigate to the group and create many projects within the group.
  3. Navigate to http://gdk.test:3000/admin/application_settings/templates.
  4. Under Custom project templates select the group created in step 1, and click on Save changes.
  5. Navigate to http://gdk.test:3000/projects/new#create_from_template.
  6. Click on the tab labeled Instance.
  7. The projects created in Step 2 should be listed.
  8. The pagination on both the Instance and Group tab should work as expected.

Related to #456061 (closed)

Edited by Jacques Erasmus

Merge request reports