| 1 |
{% macro panel(base, hooks, csrf, what) %} |
| 2 |
<section class="panel" id="webhooks"> |
| 3 |
<h2>Webhooks</h2> |
| 4 |
<p class="small mute">{{ what }}</p> |
| 5 |
{% if hooks.is_empty() %}<p class="mute small">None.</p>{% else %} |
| 6 |
<ul class="hooks"> |
| 7 |
{% for r in hooks %} |
| 8 |
<li class="hook"> |
| 9 |
<div class="hook-head"> |
| 10 |
<code class="hook-url" title="The path is shortened: webhook URLs often carry a secret token">{{ r.masked }}</code> |
| 11 |
<span class="tag">{{ r.hook.format }}</span> |
| 12 |
{% if r.hook.active %}<span class="tag head">active</span>{% else %}<span class="tag dim">disabled</span>{% endif %} |
| 13 |
</div> |
| 14 |
<p class="small mute">events <code>{{ r.hook.events }}</code> · |
| 15 |
{% if let Some((ok, text)) = r.last_result() %}last delivery {% if ok %}<span class="sig sig-valid">✔</span>{% else %}<span class="sig sig-invalid">✘</span>{% endif %} {{ text }}{% else %}nothing delivered yet{% endif %} |
| 16 |
· <a href="{{ base }}/hooks/{{ r.hook.id }}/deliveries">deliveries</a></p> |
| 17 |
<form class="tiny" method="post" action="{{ base }}/hooks"><input type="hidden" name="_csrf" value="{{ csrf }}"><input type="hidden" name="id" value="{{ r.hook.id }}"><button name="action" value="ping">ping</button> <button name="action" value="toggle">{% if r.hook.active %}disable{% else %}enable{% endif %}</button> <button name="action" value="delete" data-confirm="Delete this webhook?">delete</button></form> |
| 18 |
<details class="hook-edit"><summary class="small">edit</summary> |
| 19 |
<form class="card" method="post" action="{{ base }}/hooks"> |
| 20 |
<input type="hidden" name="_csrf" value="{{ csrf }}"><input type="hidden" name="id" value="{{ r.hook.id }}"><input type="hidden" name="action" value="update"> |
| 21 |
<label for="hu{{ r.hook.id }}">URL</label><input type="text" id="hu{{ r.hook.id }}" name="url" placeholder="{{ r.masked }}" autocomplete="off"> |
| 22 |
<p class="small mute">Leave empty to keep the current URL.</p> |
| 23 |
<label for="hs{{ r.hook.id }}">Secret</label><input type="text" id="hs{{ r.hook.id }}" name="secret" placeholder="unchanged" autocomplete="off"> |
| 24 |
<label for="he{{ r.hook.id }}">Events</label><input type="text" id="he{{ r.hook.id }}" name="events" value="{{ r.hook.events }}"> |
| 25 |
<label for="hf{{ r.hook.id }}">Format</label> |
| 26 |
<select id="hf{{ r.hook.id }}" name="format"> |
| 27 |
<option value="oxygenhub"{% if r.hook.format == "oxygenhub" %} selected{% endif %}>OxygenHub (signed JSON envelope)</option> |
| 28 |
<option value="discord"{% if r.hook.format == "discord" %} selected{% endif %}>Discord</option> |
| 29 |
<option value="slack"{% if r.hook.format == "slack" %} selected{% endif %}>Slack</option> |
| 30 |
</select> |
| 31 |
<div class="choice"><label><input type="checkbox" name="active" value="1"{% if r.hook.active %} checked{% endif %}> active</label></div> |
| 32 |
<button type="submit">SAVE</button> |
| 33 |
</form> |
| 34 |
</details> |
| 35 |
</li> |
| 36 |
{% endfor %} |
| 37 |
</ul>{% endif %} |
| 38 |
<form class="card" method="post" action="{{ base }}/hooks"> |
| 39 |
<input type="hidden" name="_csrf" value="{{ csrf }}"> |
| 40 |
<h3>Add a webhook</h3> |
| 41 |
<label for="hurl">URL</label><input type="text" id="hurl" name="url" placeholder="https://…" required autocomplete="off"> |
| 42 |
<label for="hformat">Format</label> |
| 43 |
<select id="hformat" name="format"> |
| 44 |
<option value="">From the URL (Discord and Slack are recognised)</option> |
| 45 |
<option value="oxygenhub">OxygenHub (signed JSON envelope)</option> |
| 46 |
<option value="discord">Discord</option> |
| 47 |
<option value="slack">Slack</option> |
| 48 |
</select> |
| 49 |
<label for="hsecret">Secret (signs each delivery)</label><input type="text" id="hsecret" name="secret" autocomplete="off"> |
| 50 |
<label for="hevents">Events (<code>*</code>, or a list such as <code>push,proposal,issue</code>)</label><input type="text" id="hevents" name="events" value="*"> |
| 51 |
<button type="submit">ADD WEBHOOK</button> |
| 52 |
</form> |
| 53 |
</section> |
| 54 |
{% endmacro %} |