Commit 226a8605 authored by Jose Vargas's avatar Jose Vargas Committed by Adrien Kohlbecker

Paginate project_runners in ci_cd settings

This pagination applies to the project
ci_cd settings page
parent 9d660d49
...@@ -5,6 +5,8 @@ module Projects ...@@ -5,6 +5,8 @@ module Projects
class CiCdController < Projects::ApplicationController class CiCdController < Projects::ApplicationController
include RunnerSetupScripts include RunnerSetupScripts
NUMBER_OF_RUNNERS_PER_PAGE = 20
before_action :authorize_admin_pipeline! before_action :authorize_admin_pipeline!
before_action :define_variables before_action :define_variables
before_action do before_action do
...@@ -108,13 +110,13 @@ module Projects ...@@ -108,13 +110,13 @@ module Projects
end end
def define_runners_variables def define_runners_variables
@project_runners = @project.runners.ordered @project_runners = @project.runners.ordered.page(params[:page]).per(NUMBER_OF_RUNNERS_PER_PAGE)
@assignable_runners = current_user @assignable_runners = current_user
.ci_owned_runners .ci_owned_runners
.assignable_for(project) .assignable_for(project)
.ordered .ordered
.page(params[:page]).per(20) .page(params[:page]).per(NUMBER_OF_RUNNERS_PER_PAGE)
@shared_runners = ::Ci::Runner.instance_type.active @shared_runners = ::Ci::Runner.instance_type.active
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
%h4.underlined-title= _('Runners activated for this project') %h4.underlined-title= _('Runners activated for this project')
%ul.bordered-list.activated-specific-runners %ul.bordered-list.activated-specific-runners
= render partial: 'projects/runners/runner', collection: @project_runners, as: :runner = render partial: 'projects/runners/runner', collection: @project_runners, as: :runner
= paginate @project_runners, theme: "gitlab", :params => { :anchor => '#js-runners-settings' }
- if @assignable_runners.any? - if @assignable_runners.any?
%h4.underlined-title= _('Available specific runners') %h4.underlined-title= _('Available specific runners')
......
---
title: Paginate project_runners in ci_cd settings
merge_request: 45830
author:
type: fixed
...@@ -122,6 +122,19 @@ RSpec.describe 'Runners' do ...@@ -122,6 +122,19 @@ RSpec.describe 'Runners' do
end end
end end
context 'when multiple runners are configured' do
let!(:specific_runner) { create(:ci_runner, :project, projects: [project]) }
let!(:specific_runner_2) { create(:ci_runner, :project, projects: [project]) }
it 'adds pagination to the runner list' do
stub_const('Projects::Settings::CiCdController::NUMBER_OF_RUNNERS_PER_PAGE', 1)
visit project_runners_path(project)
expect(find('.pagination')).not_to be_nil
end
end
context 'when a specific runner exists in another project' do context 'when a specific runner exists in another project' do
let(:another_project) { create(:project) } let(:another_project) { create(:project) }
let!(:specific_runner) { create(:ci_runner, :project, projects: [another_project]) } let!(:specific_runner) { create(:ci_runner, :project, projects: [another_project]) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment