gitlab-org--gitlab-foss/app/controllers/projects/runners_controller.rb
Lin Jen-Shin a065ee341c Merge remote-tracking branch 'upstream/master' into use-update-runner-service
* upstream/master: (488 commits)
  Remove duplicate CHANGELOG.md entries for 8.16.5
  Update CHANGELOG.md for 8.14.9
  Update CHANGELOG.md for 8.15.6
  #27631: Add missing top-area div to activity header page
  Update CHANGELOG.md for 8.16.5
  Update CHANGELOG.md for 8.16.5
  Update CHANGELOG.md for 8.16.5
  Fix yarn lock and package.json mismatch caused by MR 9133
  sync yarn.lock with recent changes to package.json
  Add changelog
  Fix z index bugs
  Add Links to Branches in Calendar Activity
  SidekiqStatus need to be qualified in some cases
  Replace static fixture for behaviors/requires_input_spec.js (!9162)
  API: Consolidate /projects endpoint
  Add MySQL info in install requirements
  Fix timezone on issue boards due date
  Use Gitlab::Database.with_connection_pool from !9192
  Disconnect the pool after done
  Use threads directly, introduce pool later:
  ...
2017-02-15 16:13:14 +08:00

64 lines
1.5 KiB
Ruby

class Projects::RunnersController < Projects::ApplicationController
before_action :authorize_admin_build!
before_action :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
layout 'project_settings'
def index
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
end
def edit
end
def update
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
else
render 'edit'
end
end
def destroy
if @runner.only_for?(project)
@runner.destroy
end
redirect_to runners_path(@project)
end
def resume
if Ci::UpdateRunnerService.new(@runner).update(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 Ci::UpdateRunnerService.new(@runner).update(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
def toggle_shared_runners
project.toggle!(:shared_runners_enabled)
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
end
protected
def set_runner
@runner ||= project.runners.find(params[:id])
end
def runner_params
params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
end
end