Skip to content

Commit e5b0066

Browse files
committed
Disable Test Delivery and Replay webhook buttons when webhook is inactive
These buttons are now disabled when the webhook is not active. Signed-off-by: Yarden Shoham <[email protected]>
1 parent 0ee7cbf commit e5b0066

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

options/locale/locale_en-US.ini

+2
Original file line numberDiff line numberDiff line change
@@ -2133,12 +2133,14 @@ settings.webhook_deletion_desc = Removing a webhook deletes its settings and del
21332133
settings.webhook_deletion_success = The webhook has been removed.
21342134
settings.webhook.test_delivery = Test Delivery
21352135
settings.webhook.test_delivery_desc = Test this webhook with a fake event.
2136+
settings.webhook.test_delivery_desc_disabled = To test this webhook with a fake event, activate it.
21362137
settings.webhook.request = Request
21372138
settings.webhook.response = Response
21382139
settings.webhook.headers = Headers
21392140
settings.webhook.payload = Content
21402141
settings.webhook.body = Body
21412142
settings.webhook.replay.description = Replay this webhook.
2143+
settings.webhook.replay.description_disabled = To replay this webhook, activate it.
21422144
settings.webhook.delivery.success = An event has been added to the delivery queue. It may take few seconds before it shows up in the delivery history.
21432145
settings.githooks_desc = "Git Hooks are powered by Git itself. You can edit hook files below to set up custom operations."
21442146
settings.githook_edit_desc = If the hook is inactive, sample content will be presented. Leaving content to an empty value will disable this hook.

templates/repo/settings/webhook/history.tmpl

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
{{$isNew:=or .PageIsSettingsHooksNew .PageIsAdminDefaultHooksNew .PageIsAdminSystemHooksNew}}
12
{{if .PageIsSettingsHooksEdit}}
23
<h4 class="ui top attached header">
34
{{.locale.Tr "repo.settings.recent_deliveries"}}
45
{{if .Permission.IsAdmin}}
56
<div class="ui right">
6-
<button class="ui teal tiny button" id="test-delivery" data-tooltip-content="{{.locale.Tr "repo.settings.webhook.test_delivery_desc"}}" data-link="{{.Link}}/test" data-redirect="{{.Link}}">{{.locale.Tr "repo.settings.webhook.test_delivery"}}</button>
7+
<!-- 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 -->
8+
<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}}">
9+
<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>
10+
</span>
711
</div>
812
{{end}}
913
</h4>
@@ -43,7 +47,9 @@
4347
<div class="right menu">
4448
<form class="item" action="{{$.Link}}/replay/{{.UUID}}" method="post">
4549
{{$.CsrfTokenHtml}}
46-
<button class="ui tiny button" data-tooltip-content="{{$.locale.Tr "repo.settings.webhook.replay.description"}}">{{svg "octicon-sync"}}</button>
50+
<span data-tooltip-content="{{if $.Webhook.IsActive}}{{$.locale.Tr "repo.settings.webhook.replay.description"}}{{else}}{{$.locale.Tr "repo.settings.webhook.replay.description_disabled"}}{{end}}">
51+
<button class="ui tiny button{{if not $.Webhook.IsActive}} disabled{{end}}">{{svg "octicon-sync"}}</button>
52+
</span>
4753
</form>
4854
</div>
4955
{{end}}

0 commit comments

Comments
 (0)