Read about our upcoming Code of Conduct on this issue

This instance was upgraded to Heptapod 0.28.0 today

runners_controller.rb 1.71 KB
Newer Older
1
2
3
4
5
6
7
class Projects::RunnersController < Projects::ApplicationController
  before_action :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
  before_action :authorize_admin_project!

  layout 'project_settings'

  def index
8
    @runners = project.runners.ordered
9
    @specific_runners = current_user.ci_authorized_runners.
10
      where.not(id: project.runners).
11
      ordered.page(params[:page]).per(20)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    @shared_runners = Ci::Runner.shared.active
    @shared_runners_count = @shared_runners.count(:all)
  end

  def edit
  end

  def update
    if @runner.update_attributes(runner_params)
      redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
    else
      redirect_to runner_path(@runner), alert: 'Runner was not updated.'
    end
  end

  def destroy
28
    if @runner.only_for?(project)
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
      @runner.destroy
    end

    redirect_to runners_path(@project)
  end

  def resume
    if @runner.update_attributes(active: true)
      redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
    else
      redirect_to runner_path(@runner), alert: 'Runner was not updated.'
    end
  end

  def pause
    if @runner.update_attributes(active: false)
      redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
    else
      redirect_to runner_path(@runner), alert: 'Runner was not updated.'
    end
  end

  def show
  end

54
55
56
57
58
59
  def toggle_shared_runners
    project.toggle!(:shared_runners_enabled)

    redirect_to namespace_project_runners_path(project.namespace, project)
  end

60
61
62
  protected

  def set_runner
63
    @runner ||= project.runners.find(params[:id])
64
65
66
  end

  def runner_params
67
    params.require(:runner).permit(:description, :tag_list, :active)
68
69
  end
end