Skip to content

Commit

Permalink
Add links to the WebHook Templates.
Browse files Browse the repository at this point in the history
Adds links from Project Config tab, WebHooks edit page, WebHook info bar
and WebHooks Admin Screen
  • Loading branch information
netwolfuk committed Jan 13, 2018
1 parent f1dbf37 commit d724984
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import jetbrains.buildServer.web.openapi.PositionConstraint;
import webhook.teamcity.history.WebHookHistoryRepository;
import webhook.teamcity.payload.WebHookTemplateManager;

public class WebHookAdminPage extends AdminPage {
public static final String TC_WEB_HOOK_REST_API_ADMIN_ID = "tcWebHooks";
private final WebHookHistoryRepository myWebHookHistoryRepository;
private final WebHookTemplateManager myWebHookTemplateManager;

public WebHookAdminPage(@NotNull PagePlaces pagePlaces,
@NotNull PluginDescriptor descriptor,
@NotNull WebHookHistoryRepository webHookHistoryRepository
@NotNull WebHookHistoryRepository webHookHistoryRepository,
@NotNull WebHookTemplateManager webHookTemplateManager
) {
super(pagePlaces);
this.myWebHookHistoryRepository = webHookHistoryRepository;
this.myWebHookTemplateManager = webHookTemplateManager;
setPluginName(TC_WEB_HOOK_REST_API_ADMIN_ID);
setIncludeUrl(descriptor.getPluginResourcesPath("WebHook/adminTab.jsp"));
addCssFile(descriptor.getPluginResourcesPath("WebHook/css/styles.css"));
Expand All @@ -46,6 +50,7 @@ public String getGroup() {

@Override
public void fillModel(Map<String, Object> model, HttpServletRequest request) {
model.put("webHookTemplatesCount", myWebHookTemplateManager.getRegisteredTemplates().size());
model.put("errorCount", myWebHookHistoryRepository.getErroredCount());
model.put("okCount", myWebHookHistoryRepository.getOkCount());
model.put("skippedCount", myWebHookHistoryRepository.getDisabledCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
<%@ taglib prefix="afn" uri="/WEB-INF/functions/authz" %>
<%@ include file="/include-internal.jsp" %>

<bs:refreshable containerId="healthReportContainer" pageUrl="${pageUrl}">

<div class="repoList">
<h2 class="noBorder">WebHooks</h2>
<div>
<h2>WebHook Templates</h2>
<p>There are ${webHookTemplatesCount} WebHook Templates installed in this TeamCity server.<p>
<p><a href="../webhooks/templates.html">WebHook Templates</a> are a way of packaging up a set of payloads together. The template can then be re-used by any number of webhooks.</p>
<p>Please see the <a href="https://github.com/tcplugins/tcWebHooks/wiki/WebHook-Templates-:-An-Introduction">WebHook Templates wiki pages</a> for more information.</p>

<h2>WebHook Execution History</h2>
<p>The most recent 10,000 webhook executions are stored in memory in TeamCity. These are cleared on restart.</p><p>Since the last TeamCity restart, there have been:</p>
<div class="stats-table-wrapper">
<div class="webhookCounts">
Expand All @@ -32,7 +34,6 @@
</a></div>
</div>
</div>
<hr>
<p>
<h2 class="noBorder">Recent WebHook Errors</h2>
The following table shows the 20 most recent webhook errors.
Expand All @@ -50,7 +51,6 @@

</table>

</div>
</bs:refreshable>
</div>


Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,11 @@
.addClass('webHookRow')
.appendTo('#webHookTable > tbody');
jQueryWebhook("#viewRow_" + webhook.uniqueKey + " > td.webHookRowItemUrl").html(htmlEscape(webhook.url)).click(function(){BS.EditWebHookDialog.showDialog(webhook.uniqueKey, '#hookPane');});
jQueryWebhook("#viewRow_" + webhook.uniqueKey + " > td.webHookRowItemFormat").html(webhook.payloadFormatForWeb).click(function(){BS.EditWebHookDialog.showDialog(webhook.uniqueKey,'#hookPane');});
if (webhook.payloadTemplate === 'none') {
jQueryWebhook("#viewRow_" + webhook.uniqueKey + " > td.webHookRowItemFormat").html(webhook.payloadFormatForWeb);
} else {
jQueryWebhook("#viewRow_" + webhook.uniqueKey + " > td.webHookRowItemFormat").html("<a href='template.html?" + webhook.payloadTemplate +"'>" + webhook.payloadFormatForWeb + "</a>");
}
jQueryWebhook("#viewRow_" + webhook.uniqueKey + " > td.webHookRowItemEvents").html(webhook.enabledEventsListForWeb).click(function(){BS.EditWebHookDialog.showDialog(webhook.uniqueKey,'#hookPane');});
jQueryWebhook("#viewRow_" + webhook.uniqueKey + " > td.webHookRowItemBuilds").html(webhook.enabledBuildsListForWeb).click(function(){BS.EditWebHookDialog.showDialog(webhook.uniqueKey, '#buildPane');});
jQueryWebhook("#viewRow_" + webhook.uniqueKey + " > td.webHookRowItemEdit > a").click(function(){BS.EditWebHookDialog.showDialog(webhook.uniqueKey,'#hookPane');});
Expand Down Expand Up @@ -618,6 +622,11 @@
<ul>${moreInfoText}</ul>
</c:when>
</c:choose>

<h2>WebHook Templates</h2>
<p><a href="templates.html">WebHook Templates</a> are a way of packaging up a set of payloads together. The template can then be re-used by any number of webhooks.</p>


<h2>Testing Endpoint</h2>
<p>It is possible to test webhooks by posting them back to the tcWebHooks plugin inside TeamCity. See <a href="endpoint-viewer.html"/>here for details</a>.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@

<tr id="viewRow_${hook.uniqueKey}" class="webHookRow">
<td class="name highlight" onclick="BS.EditWebHookDialog.showDialog('${hook.uniqueKey}','#hookPane');"><c:out value="${hook.url}" /></td>
<td class="value highlight" style="width:15%;" onclick="BS.EditWebHookDialog.showDialog('${hook.uniqueKey}','#hookPane');"><c:out value="${hook.payloadFormatForWeb}" /></td>

<c:choose>
<c:when test="${hook.payloadTemplate == 'none'}">
<td class="value highlight" style="width:15%;"><c:out value="${hook.payloadFormatForWeb}" /></td>
</c:when>
<c:otherwise>
<td class="value highlight" style="width:15%;"><a href="template.html?template=<c:out value="${hook.payloadTemplate}"/>"><c:out value="${hook.payloadFormatForWeb}" /></a></td>
</c:otherwise>
</c:choose>


<td class="value highlight" style="width:15%;" onclick="BS.EditWebHookDialog.showDialog('${hook.uniqueKey}','#hookPane');"><c:out value="${hook.enabledEventsListForWeb}" /></td>
<td class="value highlight" style="width:15%;" onclick="BS.EditWebHookDialog.showDialog('${hook.uniqueKey}','#buildPane');"><c:out value="${hook.enabledBuildsListForWeb}" /></td>
<td class="edit highlight"><a onclick="BS.EditWebHookDialog.showDialog('${hook.uniqueKey}','#hookPane');" href="javascript://">edit</a></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@
<c:forEach items="${projectBean.webHookList}" var="hook">
<tr>
<td><c:out value="${hook.url}" /></td>
<td><c:out value="${hook.payloadFormatForWeb}"/></td>
<c:choose>
<c:when test="${hook.payloadTemplate == 'none'}">
<td><c:out value="${hook.payloadFormatForWeb}"/></td>
</c:when>
<c:otherwise>
<td><a href="../webhooks/template.html?template=<c:out value="${hook.payloadTemplate}"/>"><c:out value="${hook.payloadFormatForWeb}"/></a></td>
</c:otherwise>
</c:choose>
<td><c:out value="${hook.enabledEventsListForWeb}"/></td>
<td><c:out value="${hook.enabledBuildsListForWeb}"/></td>
</tr>
Expand Down

0 comments on commit d724984

Please sign in to comment.