Skip to content
代码片段 群组 项目
提交 a5792762 编辑于 作者: Miguel Rincon's avatar Miguel Rincon 提交者: Simon Knox
浏览文件

Remove job list in runner Edit page

This change removes the redundant job list in runner Edit page that is
already visible in the runner View page.

Changelog: changed
上级 625d9ad9
No related branches found
No related tags found
无相关合并请求
...@@ -22,7 +22,7 @@ def show ...@@ -22,7 +22,7 @@ def show
end end
def edit def edit
assign_builds_and_projects assign_projects
end end
def update def update
...@@ -31,7 +31,7 @@ def update ...@@ -31,7 +31,7 @@ def update
format.html { redirect_to edit_admin_runner_path(@runner) } format.html { redirect_to edit_admin_runner_path(@runner) }
end end
else else
assign_builds_and_projects assign_projects
render 'show' render 'show'
end end
end end
...@@ -87,12 +87,7 @@ def permitted_attrs ...@@ -87,12 +87,7 @@ def permitted_attrs
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def assign_builds_and_projects def assign_projects
@builds = runner
.builds
.order_id_desc
.preload_project_and_pipeline_project.first(30)
@projects = @projects =
if params[:search].present? if params[:search].present?
::Project.search(params[:search]) ::Project.search(params[:search])
......
- add_page_specific_style 'page_bundles/ci_status'
- runner_name = "##{@runner.id} (#{@runner.short_sha})" - runner_name = "##{@runner.id} (#{@runner.short_sha})"
- if Feature.enabled?(:runner_read_only_admin_view, default_enabled: :yaml) - if Feature.enabled?(:runner_read_only_admin_view, default_enabled: :yaml)
- breadcrumb_title _('Edit') - breadcrumb_title _('Edit')
...@@ -12,84 +10,47 @@ ...@@ -12,84 +10,47 @@
#js-admin-runner-edit{ data: {runner_id: @runner.id} } #js-admin-runner-edit{ data: {runner_id: @runner.id} }
.row .gl-overflow-auto
.col-md-6 %h4= _('Restrict projects for this runner')
%h4= _('Restrict projects for this runner')
- if @runner.runner_projects.any?
%table.table{ data: { testid: 'assigned-projects' } }
%thead
%tr
%th= _('Assigned projects')
- @runner.runner_projects.each do |runner_project|
- project = runner_project.project
- if project
%tr
%td
= render Pajamas::AlertComponent.new(variant: :danger,
dismissible: false,
title: project.full_name) do
.gl-alert-actions
= link_to _('Disable'), admin_namespace_project_runner_project_path(project.namespace, project, runner_project), method: :delete, class: 'btn gl-alert-action btn-confirm btn-md gl-button'
%table.table{ data: { testid: 'unassigned-projects' } }
%thead
%tr
%th= _('Project')
%th
- if @runner.runner_projects.any?
%table.table{ data: { testid: 'assigned-projects' } }
%thead
%tr %tr
%td %th= _('Assigned projects')
= form_tag edit_admin_runner_path(@runner), id: 'runner-projects-search', class: 'form-inline', method: :get do - @runner.runner_projects.each do |runner_project|
.input-group - project = runner_project.project
= search_field_tag :search, params[:search], class: 'form-control gl-form-input', spellcheck: false - if project
.input-group-append
= submit_tag _('Search'), class: 'gl-button btn btn-default'
%td
- @projects.each do |project|
%tr %tr
%td %td
= project.full_name = render Pajamas::AlertComponent.new(variant: :danger,
%td dismissible: false,
.float-right title: project.full_name) do
= form_for project.runner_projects.new, url: admin_namespace_project_runner_projects_path(project.namespace, project), method: :post do |f| .gl-alert-actions
= f.hidden_field :runner_id, value: @runner.id = link_to _('Disable'), admin_namespace_project_runner_project_path(project.namespace, project, runner_project), method: :delete, class: 'btn gl-alert-action btn-confirm btn-md gl-button'
= f.submit _('Enable'), aria: { label: s_('Runners|Change to project runner') }, class: 'gl-button btn btn-sm', data: { confirm: (s_('Runners|You are about to change this instance runner to a project runner. This operation is not reversible. Are you sure you want to continue?') if @runner.instance_type?), confirm_btn_variant: 'danger' }
= paginate_without_count @projects %table.table{ data: { testid: 'unassigned-projects' } }
%thead
.col-md-6 %tr
%h4= _('Recent jobs served by this runner') %th= _('Project')
%table.table.ci-table.runner-builds %th
%thead
%tr %tr
%th= _('Job') %td
%th= _('Status') = form_tag edit_admin_runner_path(@runner), id: 'runner-projects-search', class: 'form-inline', method: :get do
%th= _('Project') .input-group
%th= _('Commit') = search_field_tag :search, params[:search], class: 'form-control gl-form-input', spellcheck: false
%th= _('Finished at') .input-group-append
= submit_tag _('Search'), class: 'gl-button btn btn-default'
- @builds.each do |build|
- project = build.project %td
%tr.build - @projects.each do |project|
%td.id %tr
- if project %td
= link_to project_job_path(project, build) do = project.full_name
%strong ##{build.id} %td
- else .float-right
%strong ##{build.id} = form_for project.runner_projects.new, url: admin_namespace_project_runner_projects_path(project.namespace, project), method: :post do |f|
= f.hidden_field :runner_id, value: @runner.id
%td.status = f.submit _('Enable'), aria: { label: s_('Runners|Change to project runner') }, class: 'gl-button btn btn-sm', data: { confirm: (s_('Runners|You are about to change this instance runner to a project runner. This operation is not reversible. Are you sure you want to continue?') if @runner.instance_type?), confirm_btn_variant: 'danger' }
= render 'ci/status/badge', status: build.detailed_status(current_user) = paginate_without_count @projects
%td.status
- if project
= project.full_name
%td.build-link
- if project
= link_to pipeline_path(build.pipeline) do
%strong= build.pipeline.short_sha
%td.timestamp
- if build.finished_at
%span= time_ago_with_tooltip build.finished_at
...@@ -16065,9 +16065,6 @@ msgstr "" ...@@ -16065,9 +16065,6 @@ msgstr ""
msgid "Finished" msgid "Finished"
msgstr "" msgstr ""
   
msgid "Finished at"
msgstr ""
msgid "First Name" msgid "First Name"
msgstr "" msgstr ""
   
...@@ -30940,9 +30937,6 @@ msgstr "" ...@@ -30940,9 +30937,6 @@ msgstr ""
msgid "Recent events" msgid "Recent events"
msgstr "" msgstr ""
   
msgid "Recent jobs served by this runner"
msgstr ""
msgid "Recent searches" msgid "Recent searches"
msgstr "" msgstr ""
   
......
...@@ -26,12 +26,6 @@ ...@@ -26,12 +26,6 @@
describe '#show' do describe '#show' do
render_views render_views
let_it_be(:project) { create(:project) }
before_all do
create(:ci_build, runner: runner, project: project)
end
it 'shows a runner show page' do it 'shows a runner show page' do
get :show, params: { id: runner.id } get :show, params: { id: runner.id }
...@@ -55,11 +49,6 @@ ...@@ -55,11 +49,6 @@
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:project_two) { create(:project) } let_it_be(:project_two) { create(:project) }
before_all do
create(:ci_build, runner: runner, project: project)
create(:ci_build, runner: runner, project: project_two)
end
it 'shows a runner edit page' do it 'shows a runner edit page' do
get :edit, params: { id: runner.id } get :edit, params: { id: runner.id }
...@@ -77,9 +66,6 @@ ...@@ -77,9 +66,6 @@
control_count = ActiveRecord::QueryRecorder.new { get :edit, params: { id: runner.id } }.count control_count = ActiveRecord::QueryRecorder.new { get :edit, params: { id: runner.id } }.count
new_project = create(:project)
create(:ci_build, runner: runner, project: new_project)
# There is one additional query looking up subject.group in ProjectPolicy for the # There is one additional query looking up subject.group in ProjectPolicy for the
# needs_new_sso_session permission # needs_new_sso_session permission
expect { get :edit, params: { id: runner.id } }.not_to exceed_query_limit(control_count + 1) expect { get :edit, params: { id: runner.id } }.not_to exceed_query_limit(control_count + 1)
...@@ -89,17 +75,42 @@ ...@@ -89,17 +75,42 @@
end end
describe '#update' do describe '#update' do
it 'updates the runner and ticks the queue' do let(:new_desc) { runner.description.swapcase }
new_desc = runner.description.swapcase let(:runner_params) { { id: runner.id, runner: { description: new_desc } } }
expect do subject(:request) { post :update, params: runner_params }
post :update, params: { id: runner.id, runner: { description: new_desc } }
end.to change { runner.ensure_runner_queue_value }
runner.reload context 'with update succeeding' do
before do
expect_next_instance_of(Ci::Runners::UpdateRunnerService, runner) do |service|
expect(service).to receive(:update).with(anything).and_call_original
end
end
expect(response).to have_gitlab_http_status(:found) it 'updates the runner and ticks the queue' do
expect(runner.description).to eq(new_desc) expect { request }.to change { runner.ensure_runner_queue_value }
runner.reload
expect(response).to have_gitlab_http_status(:found)
expect(runner.description).to eq(new_desc)
end
end
context 'with update failing' do
before do
expect_next_instance_of(Ci::Runners::UpdateRunnerService, runner) do |service|
expect(service).to receive(:update).with(anything).and_return(false)
end
end
it 'does not update runner or tick the queue' do
expect { request }.not_to change { runner.ensure_runner_queue_value }
expect { request }.not_to change { runner.reload.description }
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:show)
end
end end
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册