diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-08-21 12:20:25 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-08-21 12:21:08 +0100 |
commit | fe9a1e31f5255b34b43974c303410063c07cc292 (patch) | |
tree | 95d0e0325d08eac6e87863d49c40afe1a9fd1341 | |
parent | ee7e4fd34196003d8f3899704e5c537d965b7a9a (diff) | |
download | gitlab-ci-fe9a1e31f5255b34b43974c303410063c07cc292.tar.gz |
Update variables from within it's own controller not the project's
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/variables_controller.rb | 16 | ||||
-rw-r--r-- | app/views/variables/show.html.haml (renamed from app/views/variables/index.html.haml) | 2 | ||||
-rw-r--r-- | config/routes.rb | 2 |
4 files changed, 18 insertions, 3 deletions
@@ -15,6 +15,7 @@ v7.14.0 (unreleased) - Add missing stage when doing retry - Require variable keys to be not-empty and unique - Fix variable saving issue + - Display variable saving errors in variables page not the project's v7.13.1 - Fix: user could steal specific runner diff --git a/app/controllers/variables_controller.rb b/app/controllers/variables_controller.rb index 6eb908e..754ebf3 100644 --- a/app/controllers/variables_controller.rb +++ b/app/controllers/variables_controller.rb @@ -6,7 +6,17 @@ class VariablesController < ApplicationController layout 'project' - def index + def show + end + + def update + if project.update_attributes(project_params) + EventService.new.change_project_settings(current_user, project) + + redirect_to :back, notice: 'Variables was successfully updated.' + else + render action: 'show' + end end private @@ -14,4 +24,8 @@ class VariablesController < ApplicationController def project @project ||= Project.find(params[:project_id]) end + + def project_params + params.require(:project).permit({ variables_attributes: [:id, :key, :value, :_destroy] }) + end end diff --git a/app/views/variables/index.html.haml b/app/views/variables/show.html.haml index 64a4451..e296e17 100644 --- a/app/views/variables/index.html.haml +++ b/app/views/variables/show.html.haml @@ -7,7 +7,7 @@ %hr -= nested_form_for @project, html: { class: 'form-horizontal' } do |f| += nested_form_for @project, url: url_for(controller: 'variables', action: 'update'), html: { class: 'form-horizontal' } do |f| - if @project.errors.any? #error_explanation %p.lead= "#{pluralize(@project.errors.count, "error")} prohibited this project from being saved:" diff --git a/config/routes.rb b/config/routes.rb index e92e726..cd0054f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -66,7 +66,7 @@ Rails.application.routes.draw do resources :runner_projects, only: [:create, :destroy] resources :events, only: [:index] - resources :variables, only: [:index] + resource :variables, only: [:show, :update] end resource :user_sessions do |