2015-09-29 04:37:31 -04:00
|
|
|
class Projects::TriggersController < Projects::ApplicationController
|
2016-02-01 17:58:04 -05:00
|
|
|
before_action :authorize_admin_build!
|
2015-09-29 04:37:31 -04:00
|
|
|
|
|
|
|
layout 'project_settings'
|
|
|
|
|
|
|
|
def index
|
2015-12-10 11:44:06 -05:00
|
|
|
@triggers = project.triggers
|
2015-09-29 04:37:31 -04:00
|
|
|
@trigger = Ci::Trigger.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2015-12-10 11:44:06 -05:00
|
|
|
@trigger = project.triggers.new
|
2015-09-29 04:37:31 -04:00
|
|
|
@trigger.save
|
|
|
|
|
|
|
|
if @trigger.valid?
|
|
|
|
redirect_to namespace_project_triggers_path(@project.namespace, @project)
|
|
|
|
else
|
2015-12-10 11:44:06 -05:00
|
|
|
@triggers = project.triggers.select(&:persisted?)
|
2015-09-29 04:37:31 -04:00
|
|
|
render :index
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
trigger.destroy
|
|
|
|
|
|
|
|
redirect_to namespace_project_triggers_path(@project.namespace, @project)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def trigger
|
2015-12-10 11:44:06 -05:00
|
|
|
@trigger ||= project.triggers.find(params[:id])
|
2015-09-29 04:37:31 -04:00
|
|
|
end
|
|
|
|
end
|