in src/main/resources/buildServerResources/gh-webhook.js [185:257]
WH.doWebHookAction = function (action, element, id, popup, projectId) {
// Enforce popup for server if needed
var server = undefined;
var info = WH.info[id];
if (info) {
server = info['server'];
} else {
server = WH.getServerUrl(id);
}
if (server && WH.forcePopup[server]) {
popup = true
}
if (popup) {
var url = BS.ServerInfo.url + WH.WEBHOOKS_CONTROLLER_PATH + '?action=' + action.id + '&popup=true&id=' + id;
if (projectId !== undefined) {
url = url + "&projectId=" + projectId
}
var popupWin = BS.Util.popupWindow(url, 'webhook_' + action.id + '_' + id);
var interval = window.setInterval(function() {
try {
if (popupWin == null || popupWin.closed) {
window.clearInterval(interval);
$j("#installWebhookSubmit").attr("value", WH.INSTALL_BUTTON_TITLE);
WH.forcePopup[server] = false;
WH.doInstallForm($('installWebhookSubmit'));
}
} catch (e) {
}
}, 1000);
return;
}
var that = element;
action.doShowProgress(element);
var parameters = {
"action": action.id,
"id": id,
"popup": popup
};
if (projectId !== undefined) {
parameters["projectId"] = projectId
}
var data_holder = $j(element).parents("[data-connection-id]");
if (data_holder) {
var conn_server = data_holder.attr('data-connection-server');
if (isSameServer(server, conn_server)) {
parameters["connectionId"] = data_holder.attr('data-connection-id');
parameters["connectionProjectId"] = data_holder.attr('data-connection-project-id');
}
}
//noinspection JSUnusedGlobalSymbols
BS.ajaxRequest(window.base_uri + WH.WEBHOOKS_CONTROLLER_PATH, {
method: "post",
parameters: parameters,
onComplete: function (transport) {
var json = transport.responseJSON;
var action = WH.actions[json['action']] || action;
action.doHideProgress();
if (json['redirect']) {
BS.Log.info("Redirect response received");
action.doHandleRedirect(json, id, that)
} else {
WH.doHandle(json, action)
}
WH.refreshReports();
}
});
};