Skip to content

Commit 9273952

Browse files
committed
"Send now" button
Reolves #35
1 parent d877adb commit 9273952

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66
- Added new “Element is being saved for the first time” and “Element is a provisional draft” webhook filters.
77
- Some webhook filters now disable other mutually-exclusive filters when active and enabled.
8+
- Pending webhook requests now have a “Send now” button, for manually triggering a webhook if the queue job was lost or failed. ([#35](https://github.com/craftcms/webhooks/issues/35))
89
- Added the “Initial Delay” setting. ([#53](https://github.com/craftcms/webhooks/discussions/53))
910
- Added `craft\webhooks\filters\ExclusiveFilterInterface`.
1011

src/assets/activity/ActivityAsset.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use craft\web\AssetBundle;
1111
use craft\web\assets\cp\CpAsset;
12-
use craft\web\View;
1312

1413
/**
1514
* Webhooks index asset bundle
@@ -32,18 +31,4 @@ class ActivityAsset extends AssetBundle
3231
public $js = [
3332
'js/Activity.js',
3433
];
35-
36-
/**
37-
* @inheritdoc
38-
*/
39-
public function registerAssetFiles($view)
40-
{
41-
parent::registerAssetFiles($view);
42-
43-
if ($view instanceof View) {
44-
$view->registerTranslations('webhooks', [
45-
'Are you sure you want to resend this request?',
46-
]);
47-
}
48-
}
4934
}

src/assets/activity/dist/js/Activity.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
});
3030

3131
function initSlideout(slideout, requestId) {
32-
const $redeliverBtn = slideout.$container.find('.redeliver-btn');
33-
$redeliverBtn.on('click', function() {
34-
if (!$redeliverBtn.hasClass('disabled') && confirm(Craft.t('webhooks', 'Are you sure you want to resend this request?'))) {
35-
$redeliverBtn.addClass('disabled');
32+
const $sendBtn = slideout.$container.find('.send-btn');
33+
$sendBtn.on('click', function() {
34+
if (!$sendBtn.hasClass('disabled')) {
35+
$sendBtn.addClass('disabled');
3636
const $spinner = $(this).next('.spinner').removeClass('hidden');
3737
Craft.postActionRequest('webhooks/activity/redeliver', {
3838
requestId: requestId

src/templates/_activity/details.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313
{% endif %}
1414
<div class="data">
1515
<div class="heading">{{ 'Status'|t('webhooks') }}</div>
16-
<div class="value">{{ macros.status(request) }}</div>
16+
<div class="value">
17+
{{ macros.status(request) }}
18+
{% if request.status == 'pending' %}
19+
&nbsp;&nbsp;
20+
<div class="btn small send-btn">{{ 'Send now'|t('webhooks') }}</div>
21+
<div class="spinner hidden"></div>
22+
{% endif %}
23+
</div>
1724
</div>
1825
{% if request.status == 'done' %}
1926
<div class="data">
@@ -27,7 +34,7 @@
2734
<div class="value">
2835
<div class="flex">
2936
<div>{{ request.attempts }}&nbsp;&nbsp;</div>
30-
<div class="btn small redeliver-btn">{{ 'Redeliver'|t('webhooks') }}</div>
37+
<div class="btn small send-btn">{{ 'Redeliver'|t('webhooks') }}</div>
3138
<div class="spinner hidden"></div>
3239
</div>
3340
</div>

0 commit comments

Comments
 (0)