Commit 75dedcd4 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch '335128-consolidate-webhook-deliveries-table' into 'master'

Create partial for webhook deliveries table

See merge request gitlab-org/gitlab!71792
parents 5c15e31e 2b87d524
......@@ -36,6 +36,15 @@ module HooksHelper
admin_hook_path(hook)
end
end
def hook_log_path(hook, hook_log)
case hook
when ProjectHook
hook_log.present.details_path
when SystemHook
admin_hook_hook_log_path(hook, hook_log)
end
end
end
HooksHelper.prepend_mod_with('HooksHelper')
......@@ -4,34 +4,4 @@
= _('Recent Deliveries')
%p= _('When an event in GitLab triggers a webhook, you can use the request details to figure out if something went wrong.')
.col-lg-9
- if hook_logs.present?
%table.table
%thead
%tr
%th= _('Status')
%th= _('Trigger')
%th= _('URL')
%th= _('Elapsed time')
%th= _('Request time')
%th
- hook_logs.each do |hook_log|
%tr
%td
= render partial: 'shared/hook_logs/status_label', locals: { hook_log: hook_log }
%td.d-none.d-sm-block
%span.badge.badge-gray.deploy-project-label
= hook_log.trigger.singularize.titleize
%td
= truncate(hook_log.url, length: 50)
%td.light
#{number_with_precision(hook_log.execution_duration, precision: 2)} sec
%td.light
= time_ago_with_tooltip(hook_log.created_at)
%td
= link_to _('View details'), admin_hook_hook_log_path(hook, hook_log)
= paginate hook_logs, theme: 'gitlab'
- else
.settings-message.text-center
= _("You don't have any webhooks deliveries")
= render partial: 'shared/hook_logs/recent_deliveries_table', locals: { hook: hook, hook_logs: hook_logs }
.row.gl-mt-7.gl-mb-3
.row.gl-mt-3.gl-mb-3
.col-lg-3
%h4.gl-mt-0
Recent Deliveries
%p When an event in GitLab triggers a webhook, you can use the request details to figure out if something went wrong.
= _('Recent Deliveries')
%p= _('When an event in GitLab triggers a webhook, you can use the request details to figure out if something went wrong.')
.col-lg-9
- if hook_logs.present?
%table.table
%thead
%tr
%th Status
%th Trigger
%th URL
%th Elapsed time
%th Request time
%th
- hook_logs.each do |hook_log|
%tr
%td
= render partial: 'shared/hook_logs/status_label', locals: { hook_log: hook_log }
%td.d-none.d-sm-block
%span.badge.badge-gray.deploy-project-label
= hook_log.trigger.singularize.titleize
%td
= truncate(hook_log.url, length: 50)
%td.light
#{number_with_precision(hook_log.execution_duration, precision: 2)} sec
%td.light
= time_ago_with_tooltip(hook_log.created_at)
%td
= link_to 'View details', hook_log.present.details_path
= paginate hook_logs, theme: 'gitlab'
- else
.settings-message.text-center
You don't have any webhooks deliveries
= render partial: 'shared/hook_logs/recent_deliveries_table', locals: { hook: hook, hook_logs: hook_logs }
......@@ -5,8 +5,8 @@
.row.gl-mt-3.gl-mb-3
.col-lg-3
%h4.gl-mt-0
Request details
= _("Request details")
.col-lg-9
= link_to 'Resend Request', @hook_log.present.retry_path, method: :post, class: "btn gl-button btn-default float-right gl-ml-3"
= link_to _('Resend Request'), @hook_log.present.retry_path, method: :post, class: "btn gl-button btn-default float-right gl-ml-3"
= render partial: 'shared/hook_logs/content', locals: { hook_log: @hook_log }
- if hook_logs.present?
%table.table
%thead
%tr
%th= _('Status')
%th.d-none.d-sm-table-cell= _('Trigger')
%th= _('URL')
%th= _('Elapsed time')
%th= _('Request time')
%th
- hook_logs.each do |hook_log|
%tr
%td
= render partial: 'shared/hook_logs/status_label', locals: { hook_log: hook_log }
%td.d-none.d-sm-table-cell
%span.badge.badge-gray.deploy-project-label
= hook_log.trigger.singularize.titleize
%td
= truncate(hook_log.url, length: 50)
%td
#{number_with_precision(hook_log.execution_duration, precision: 2)} sec
%td
= time_ago_with_tooltip(hook_log.created_at)
%td
= link_to _('View details'), hook_log_path(hook, hook_log)
= paginate hook_logs, theme: 'gitlab'
- else
.settings-message.text-center
= _("You don't have any webhooks deliveries")
......@@ -6,9 +6,10 @@ RSpec.describe HooksHelper do
let(:project) { create(:project) }
let(:project_hook) { create(:project_hook, project: project) }
let(:system_hook) { create(:system_hook) }
let(:trigger) { 'push_events' }
describe '#link_to_test_hook' do
let(:trigger) { 'push_events' }
it 'returns project namespaced link' do
expect(helper.link_to_test_hook(project_hook, trigger))
.to include("href=\"#{test_project_hook_path(project, project_hook, trigger: trigger)}\"")
......@@ -19,4 +20,24 @@ RSpec.describe HooksHelper do
.to include("href=\"#{test_admin_hook_path(system_hook, trigger: trigger)}\"")
end
end
describe '#hook_log_path' do
context 'with a project hook' do
let(:web_hook_log) { create(:web_hook_log, web_hook: project_hook) }
it 'returns project-namespaced link' do
expect(helper.hook_log_path(project_hook, web_hook_log))
.to eq(web_hook_log.present.details_path)
end
end
context 'with a system hook' do
let(:web_hook_log) { create(:web_hook_log, web_hook: system_hook) }
it 'returns admin-namespaced link' do
expect(helper.hook_log_path(system_hook, web_hook_log))
.to eq(admin_hook_hook_log_path(system_hook, web_hook_log))
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment