Module: WebHooks::HookActions
- Extended by:
- ActiveSupport::Concern
- Includes:
- HookExecutionNotice
- Included in:
- Admin::HooksController, Projects::HooksController
- Defined in:
- app/controllers/concerns/web_hooks/hook_actions.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 20 def create organization = Current.organization result = WebHooks::CreateService.new(current_user).execute(hook_params, relation, organization) if result.success? flash[:notice] = _('Webhook created') else self.hooks = relation.select(&:persisted?) flash[:alert] = result. end redirect_to action: :index end |
#destroy ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 54 def destroy destroy_hook(hook) redirect_to action: :index, status: :found end |
#edit ⇒ Object
60 61 62 |
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 60 def edit redirect_to(action: :index) unless hook end |
#index ⇒ Object
15 16 17 18 |
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 15 def index self.hooks = relation.select(&:persisted?) self.hook = relation.new end |
#update ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 35 def update if hook.update(hook_params) flash[:notice] = _('Webhook updated') redirect_to action: :edit else if hook.errors[:custom_headers].present? flash.now[:alert] = format(_("Custom headers validation failed: %{errors}"), errors: hook.errors[:custom_headers].join(', ')) # clean invalid headers before re-rendering hook.custom_headers = filter_valid_headers(hook.custom_headers) elsif hook.errors.any? flash.now[:alert] = format(_("Please fix the following errors: %{errors}"), errors: hook.errors..join(', ')) end render 'edit' end end |