Commit f88d5974 authored by Mario de la Ossa's avatar Mario de la Ossa

Add pause/resume button to specific project runners

parent 3d56d93f
...@@ -29,17 +29,17 @@ class Projects::RunnersController < Projects::ApplicationController ...@@ -29,17 +29,17 @@ class Projects::RunnersController < Projects::ApplicationController
def resume def resume
if Ci::UpdateRunnerService.new(@runner).update(active: true) if Ci::UpdateRunnerService.new(@runner).update(active: true)
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.' redirect_to runners_path(@project), notice: 'Runner was successfully updated.'
else else
redirect_to runner_path(@runner), alert: 'Runner was not updated.' redirect_to runners_path(@project), alert: 'Runner was not updated.'
end end
end end
def pause def pause
if Ci::UpdateRunnerService.new(@runner).update(active: false) if Ci::UpdateRunnerService.new(@runner).update(active: false)
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.' redirect_to runners_path(@project), notice: 'Runner was successfully updated.'
else else
redirect_to runner_path(@runner), alert: 'Runner was not updated.' redirect_to runners_path(@project), alert: 'Runner was not updated.'
end end
end end
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
.pull-right .pull-right
- if @project_runners.include?(runner) - if @project_runners.include?(runner)
- if runner.active?
= link_to 'Pause', pause_project_runner_path(@project, runner), method: :post, class: 'btn btn-sm btn-danger', data: { confirm: "Are you sure?" }
- else
= link_to 'Resume', resume_project_runner_path(@project, runner), method: :post, class: 'btn btn-success btn-sm'
- if runner.belongs_to_one_project? - if runner.belongs_to_one_project?
= link_to 'Remove Runner', runner_path(runner), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm' = link_to 'Remove Runner', runner_path(runner), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm'
- else - else
......
---
title: Add pause/resume button to project runners
merge_request: 16032
author: Mario de la Ossa
type: added
...@@ -383,8 +383,8 @@ constraints(ProjectUrlConstrainer.new) do ...@@ -383,8 +383,8 @@ constraints(ProjectUrlConstrainer.new) do
resources :runners, only: [:index, :edit, :update, :destroy, :show] do resources :runners, only: [:index, :edit, :update, :destroy, :show] do
member do member do
get :resume post :resume
get :pause post :pause
end end
collection do collection do
......
...@@ -33,6 +33,26 @@ feature 'Runners' do ...@@ -33,6 +33,26 @@ feature 'Runners' do
expect(page).to have_content(specific_runner.platform) expect(page).to have_content(specific_runner.platform)
end end
scenario 'user can pause and resume the specific runner' do
visit runners_path(project)
within '.activated-specific-runners' do
expect(page).to have_content('Pause')
end
click_on 'Pause'
within '.activated-specific-runners' do
expect(page).to have_content('Resume')
end
click_on 'Resume'
within '.activated-specific-runners' do
expect(page).to have_content('Pause')
end
end
scenario 'user removes an activated specific runner if this is last project for that runners' do scenario 'user removes an activated specific runner if this is last project for that runners' do
visit runners_path(project) visit runners_path(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