diff options
author | Phil Hughes <me@iamphill.com> | 2016-04-27 09:01:43 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-05-16 10:21:51 +0100 |
commit | bda2c44a0b2f032d8c3eb9b9b8d79933fb40e651 (patch) | |
tree | b58ad47cd56e32ede3cf0054b176148e9edb0f4b /app/controllers/projects/variables_controller.rb | |
parent | 78a67fc48dab434b43a080e5b15491963656661a (diff) | |
download | gitlab-ce-bda2c44a0b2f032d8c3eb9b9b8d79933fb40e651.tar.gz |
Project variables UI
Closes #14091
Diffstat (limited to 'app/controllers/projects/variables_controller.rb')
-rw-r--r-- | app/controllers/projects/variables_controller.rb | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index 00234654578..6f068729390 100644 --- a/app/controllers/projects/variables_controller.rb +++ b/app/controllers/projects/variables_controller.rb @@ -3,20 +3,44 @@ class Projects::VariablesController < Projects::ApplicationController layout 'project_settings' + def index + @variable = Ci::Variable.new + end + def show + @variable = @project.variables.find(params[:id]) end def update - if project.update_attributes(project_params) + @variable = @project.variables.find(params[:id]) + + if @variable.update_attributes(project_params) + redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variable was successfully updated.' + else + render action: "show" + end + end + + def create + @variable = Ci::Variable.new(project_params) + + if @variable.valid? && @project.variables << @variable redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variables were successfully updated.' else - render action: 'show' + render action: "index" end end + def destroy + @key = @project.variables.find(params[:id]) + @key.destroy + + redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variable was successfully removed.' + end + private def project_params - params.require(:project).permit({ variables_attributes: [:id, :key, :value, :_destroy] }) + params.require(:variable).permit([:id, :key, :value, :_destroy]) end end |