diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-04-10 07:29:06 +0300 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-05-07 09:54:07 +0300 |
commit | 91f358942e8a02322423b7eb664985baf78510eb (patch) | |
tree | 476b8c1cb50c5af692f6944b75746edf45e693cf /app/controllers/groups/runners_controller.rb | |
parent | 1ef9e9c2aaaffb202f09bf6a245a01bfb5516b6e (diff) |
Allow to pause,resume,show,edit,destroy group runners (#10244)
Diffstat (limited to 'app/controllers/groups/runners_controller.rb')
-rw-r--r-- | app/controllers/groups/runners_controller.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/app/controllers/groups/runners_controller.rb b/app/controllers/groups/runners_controller.rb new file mode 100644 index 00000000000..19ab4a50959 --- /dev/null +++ b/app/controllers/groups/runners_controller.rb @@ -0,0 +1,54 @@ +class Groups::RunnersController < Groups::ApplicationController + before_action :authorize_admin_pipeline! + before_action :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show] + + def show + end + + def edit + end + + def update + if Ci::UpdateRunnerService.new(@runner).update(runner_params) + redirect_to group_runner_path(@group, @runner), notice: 'Runner was successfully updated.' + else + render 'edit' + end + end + + def destroy + @runner.destroy + + redirect_to group_settings_ci_cd_path(@group), status: 302 + end + + def resume + if Ci::UpdateRunnerService.new(@runner).update(active: true) + redirect_to group_settings_ci_cd_path(@group), notice: 'Runner was successfully updated.' + else + redirect_to group_settings_ci_cd_path(@group), alert: 'Runner was not updated.' + end + end + + def pause + if Ci::UpdateRunnerService.new(@runner).update(active: false) + redirect_to group_settings_ci_cd_path(@group), notice: 'Runner was successfully updated.' + else + redirect_to group_settings_ci_cd_path(@group), alert: 'Runner was not updated.' + end + end + + private + + def set_runner + @runner ||= @group.runners.find(params[:id]) + end + + def authorize_admin_pipeline! + return render_404 unless can?(current_user, :admin_pipeline, group) + end + + def runner_params + params.require(:runner).permit(Ci::Runner::FORM_EDITABLE) + end +end |