mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-30 05:46:09 +01:00
2774a2afc6
Backport #27211 by @yardenshoham These buttons are now disabled when the webhook is not active. The buttons were always enabled before this change. - Fixes #26824 - Replaces #26814 # Before ![image](https://github.com/go-gitea/gitea/assets/20454870/e783d0d8-b433-440e-b95f-50d7c42613d3) ![image](https://github.com/go-gitea/gitea/assets/20454870/b4886151-9f32-4e83-8001-dd3f20c23d70) # After ![image](https://github.com/go-gitea/gitea/assets/20454870/74b76a72-0818-4143-8548-5d42c4119a05) ![image](https://github.com/go-gitea/gitea/assets/20454870/d5ae4e5c-c1ac-4751-a072-e6f7511b1e07) Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: Yarden Shoham <git@yardenshoham.com>
87 lines
3.9 KiB
Handlebars
87 lines
3.9 KiB
Handlebars
{{$isNew:=or .PageIsSettingsHooksNew .PageIsAdminDefaultHooksNew .PageIsAdminSystemHooksNew}}
|
|
{{if .PageIsSettingsHooksEdit}}
|
|
<h4 class="ui top attached header">
|
|
{{.locale.Tr "repo.settings.recent_deliveries"}}
|
|
{{if .Permission.IsAdmin}}
|
|
<div class="ui right">
|
|
<!-- the button is wrapped with a span because the tooltip doesn't show on hover if we put data-tooltip-content directly on the button -->
|
|
<span data-tooltip-content="{{if or $isNew .Webhook.IsActive}}{{.locale.Tr "repo.settings.webhook.test_delivery_desc"}}{{else}}{{.locale.Tr "repo.settings.webhook.test_delivery_desc_disabled"}}{{end}}">
|
|
<button class="ui teal tiny button{{if not (or $isNew .Webhook.IsActive)}} disabled{{end}}" id="test-delivery" data-link="{{.Link}}/test" data-redirect="{{.Link}}">{{.locale.Tr "repo.settings.webhook.test_delivery"}}</button>
|
|
</span>
|
|
</div>
|
|
{{end}}
|
|
</h4>
|
|
<div class="ui attached segment">
|
|
<div class="ui list">
|
|
{{range .History}}
|
|
<div class="item">
|
|
<div class="flex-text-block gt-sb">
|
|
<div class="flex-text-inline">
|
|
{{if .IsSucceed}}
|
|
<span class="text green">{{svg "octicon-check"}}</span>
|
|
{{else}}
|
|
<span class="text red">{{svg "octicon-alert"}}</span>
|
|
{{end}}
|
|
<a class="ui primary sha label toggle button show-panel" data-panel="#info-{{.ID}}">{{.UUID}}</a>
|
|
</div>
|
|
<span class="text grey">
|
|
{{TimeSince .Delivered.AsTime $.locale}}
|
|
</span>
|
|
</div>
|
|
<div class="info gt-hidden" id="info-{{.ID}}">
|
|
<div class="ui top attached tabular menu">
|
|
<a class="item active" data-tab="request-{{.ID}}">{{$.locale.Tr "repo.settings.webhook.request"}}</a>
|
|
<a class="item" data-tab="response-{{.ID}}">
|
|
{{$.locale.Tr "repo.settings.webhook.response"}}
|
|
{{if .ResponseInfo}}
|
|
{{if .IsSucceed}}
|
|
<span class="ui green label">{{.ResponseInfo.Status}}</span>
|
|
{{else}}
|
|
<span class="ui red label">{{.ResponseInfo.Status}}</span>
|
|
{{end}}
|
|
{{else}}
|
|
<span class="ui label">-</span>
|
|
{{end}}
|
|
</a>
|
|
{{if or $.Permission.IsAdmin $.IsOrganizationOwner $.PageIsAdmin $.PageIsUserSettings}}
|
|
<div class="right menu">
|
|
<form class="item" action="{{$.Link}}/replay/{{.UUID}}" method="post">
|
|
{{$.CsrfTokenHtml}}
|
|
<span data-tooltip-content="{{if $.Webhook.IsActive}}{{$.locale.Tr "repo.settings.webhook.replay.description"}}{{else}}{{$.locale.Tr "repo.settings.webhook.replay.description_disabled"}}{{end}}">
|
|
<button class="ui tiny button{{if not $.Webhook.IsActive}} disabled{{end}}">{{svg "octicon-sync"}}</button>
|
|
</span>
|
|
</form>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
<div class="ui bottom attached tab segment active" data-tab="request-{{.ID}}">
|
|
{{if .RequestInfo}}
|
|
<h5>{{$.locale.Tr "repo.settings.webhook.headers"}}</h5>
|
|
<pre class="webhook-info"><strong>Request URL:</strong> {{.RequestInfo.URL}}
|
|
<strong>Request method:</strong> {{if .RequestInfo.HTTPMethod}}{{.RequestInfo.HTTPMethod}}{{else}}POST{{end}}
|
|
{{range $key, $val := .RequestInfo.Headers}}<strong>{{$key}}:</strong> {{$val}}
|
|
{{end}}</pre>
|
|
<h5>{{$.locale.Tr "repo.settings.webhook.payload"}}</h5>
|
|
<pre class="webhook-info"><code class="json">{{.PayloadContent}}</code></pre>
|
|
{{else}}
|
|
-
|
|
{{end}}
|
|
</div>
|
|
<div class="ui bottom attached tab segment" data-tab="response-{{.ID}}">
|
|
{{if .ResponseInfo}}
|
|
<h5>{{$.locale.Tr "repo.settings.webhook.headers"}}</h5>
|
|
<pre class="webhook-info">{{range $key, $val := .ResponseInfo.Headers}}<strong>{{$key}}:</strong> {{$val}}
|
|
{{end}}</pre>
|
|
<h5>{{$.locale.Tr "repo.settings.webhook.body"}}</h5>
|
|
<pre class="webhook-info"><code>{{.ResponseInfo.Body}}</code></pre>
|
|
{{else}}
|
|
-
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
{{end}}
|