Commit 61aec427 authored by Stan Hu's avatar Stan Hu

Merge branch 'jivanvl-add-pagination-specific-runners' into 'master'

Paginate project_runners in ci_cd settings

See merge request gitlab-org/gitlab!45830
parents 377ae7ea 2e7f8cfd
...@@ -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[:project_page]).per(NUMBER_OF_RUNNERS_PER_PAGE).with_tags
@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[:specific_page]).per(NUMBER_OF_RUNNERS_PER_PAGE)
@shared_runners = ::Ci::Runner.instance_type.active @shared_runners = ::Ci::Runner.instance_type.active
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
- if runner.description.present? - if runner.description.present?
%p.runner-description %p.runner-description
= runner.description = runner.description
- if runner.tag_list.present? - if runner.tags.present?
%p %p
- runner.tag_list.sort.each do |tag| - runner.tags.map(&:name).sort.each do |tag|
%span.badge.badge-primary %span.badge.badge-primary
= tag = tag
...@@ -17,9 +17,10 @@ ...@@ -17,9 +17,10 @@
%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", param_name: "project_page", params: { expand_runners: true, anchor: 'js-runners-settings' }
- if @assignable_runners.any? - if @assignable_runners.any?
%h4.underlined-title= _('Available specific runners') %h4.underlined-title= _('Available specific runners')
%ul.bordered-list.available-specific-runners %ul.bordered-list.available-specific-runners
= render partial: 'projects/runners/runner', collection: @assignable_runners, as: :runner = render partial: 'projects/runners/runner', collection: @assignable_runners, as: :runner
= paginate @assignable_runners, theme: "gitlab", :params => { :anchor => '#js-runners-settings' } = paginate @assignable_runners, theme: "gitlab", param_name: "specific_page", :params => { :anchor => 'js-runners-settings'}
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
= render_if_exists 'projects/settings/ci_cd/protected_environments', expanded: expanded = render_if_exists 'projects/settings/ci_cd/protected_environments', expanded: expanded
%section.settings.no-animate#js-runners-settings{ class: ('expanded' if expanded), data: { qa_selector: 'runners_settings_content' } } %section.settings.no-animate#js-runners-settings{ class: ('expanded' if expanded || params[:expand_runners]), data: { qa_selector: 'runners_settings_content' } }
.settings-header .settings-header
%h4 %h4
= _("Runners") = _("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