Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects/hooks_controller.rb')
-rw-r--r--app/controllers/projects/hooks_controller.rb51
1 files changed, 7 insertions, 44 deletions
diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb
index 99eba32e00f..50f388324f1 100644
--- a/app/controllers/projects/hooks_controller.rb
+++ b/app/controllers/projects/hooks_controller.rb
@@ -15,52 +15,21 @@ class Projects::HooksController < Projects::ApplicationController
feature_category :integrations
urgency :low, [:test]
- def index
- @hooks = @project.hooks.load
- @hook = ProjectHook.new
- end
-
- def create
- @hook = @project.hooks.new(hook_params)
- @hook.save
-
- unless @hook.valid?
- @hooks = @project.hooks.select(&:persisted?)
- flash[:alert] = @hook.errors.full_messages.join.html_safe
- end
-
- redirect_to action: :index
- end
-
- def edit
- redirect_to(action: :index) unless hook
- end
-
- def update
- if hook.update(hook_params)
- flash[:notice] = _('Hook was successfully updated.')
- redirect_to action: :index
- else
- render 'edit'
- end
- end
-
def test
- result = TestHooks::ProjectService.new(hook, current_user, params[:trigger]).execute
+ trigger = params.fetch(:trigger, ::ProjectHook.triggers.each_value.first.to_s)
+ result = TestHooks::ProjectService.new(hook, current_user, trigger).execute
set_hook_execution_notice(result)
redirect_back_or_default(default: { action: :index })
end
- def destroy
- destroy_hook(hook)
+ private
- redirect_to action: :index, status: :found
+ def relation
+ @project.hooks
end
- private
-
def hook
@hook ||= @project.hooks.find(params[:id])
end
@@ -69,13 +38,7 @@ class Projects::HooksController < Projects::ApplicationController
@hook_logs ||= hook.web_hook_logs.recent.page(params[:page])
end
- def hook_params
- params.require(:hook).permit(
- :enable_ssl_verification,
- :token,
- :url,
- :push_events_branch_filter,
- *ProjectHook.triggers.values
- )
+ def trigger_values
+ ProjectHook.triggers.values
end
end