debian-mirror-gitlab/app/controllers/projects/variables_controller.rb

48 lines
1.2 KiB
Ruby
Raw Normal View History

2015-10-24 18:46:33 +05:30
class Projects::VariablesController < Projects::ApplicationController
2016-04-02 18:10:28 +05:30
before_action :authorize_admin_build!
2015-10-24 18:46:33 +05:30
layout 'project_settings'
2016-06-02 11:05:42 +05:30
def index
2017-08-17 22:00:37 +05:30
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
2016-06-02 11:05:42 +05:30
end
2015-10-24 18:46:33 +05:30
def show
2016-06-02 11:05:42 +05:30
@variable = @project.variables.find(params[:id])
2015-10-24 18:46:33 +05:30
end
def update
2016-06-02 11:05:42 +05:30
@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
2017-08-17 22:00:37 +05:30
flash[:notice] = 'Variables were successfully updated.'
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project)
2015-10-24 18:46:33 +05:30
else
2017-08-17 22:00:37 +05:30
render "show"
2015-10-24 18:46:33 +05:30
end
end
2016-06-02 11:05:42 +05:30
def destroy
@key = @project.variables.find(params[:id])
@key.destroy
2017-08-17 22:00:37 +05:30
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), notice: 'Variable was successfully removed.'
2016-06-02 11:05:42 +05:30
end
2015-10-24 18:46:33 +05:30
private
def project_params
2016-06-02 11:05:42 +05:30
params.require(:variable).permit([:id, :key, :value, :_destroy])
2015-10-24 18:46:33 +05:30
end
end