44bb70c8c9
Also updated the #update action inside the variables controller as to render the show and not redirect back to the settings route
34 lines
816 B
Ruby
34 lines
816 B
Ruby
class Projects::TriggersController < Projects::ApplicationController
|
|
before_action :authorize_admin_build!
|
|
|
|
layout 'project_settings'
|
|
|
|
def index
|
|
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
|
|
end
|
|
|
|
def create
|
|
@trigger = project.triggers.new
|
|
@trigger.save
|
|
|
|
if @trigger.valid?
|
|
redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Trigger was created successfully.'
|
|
else
|
|
@triggers = project.triggers.select(&:persisted?)
|
|
render action: "show"
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
trigger.destroy
|
|
flash[:alert] = "Trigger removed"
|
|
|
|
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @project)
|
|
end
|
|
|
|
private
|
|
|
|
def trigger
|
|
@trigger ||= project.triggers.find(params[:id])
|
|
end
|
|
end
|