...
Part 1 - Create a SIL Webhook
At the very top of the script, define the kind of link type you would like to hide.
Code Block string [] issueLinkTypeName = {"Relates"};
Next add a basic webhook. For detailed information on SIL Webhooks, see this documentation on Webhooks configuration.
Code Block WebhookPayload httpRequestPayload = getWebhookPayload(); string httpMethod = httpRequestPayload.httpMethod; string httpPayload = httpRequestPayload.payload; WebhookParam[] httpQueryParams = httpRequestPayload.queryParams; // string firstQueryParamName = httpQueryParams[0].name; string issueKey = httpQueryParams[0].values[0];
Next, structure your basic JSON response by adding link data to those links you want to hide. The idea here is to return alternating values of the issue id (link.id)and link id (link.issue.id). For more details on available variables, see this documentation on predefined structure types for JIssueLink.
Code Block string [] result; JIssueLink [] links = getIssueLinksDetail(issueKey); for (JIssueLink link in links) { if (arrayElementExists(issueLinkTypeName, link.name)) { result += link.id; result += link.issue.id; } } result = replace(result, "|", ","); string json = "{\"linkData\":"; json += "["; json += result; json += "]}"; runnerLog(json);
Lastly, append the json data to the response and respond.
Code Block appendToWebhookResponse(json); return true, 200;
Part 2 - Configuring the JavaScript
Use Live Fields to call the JavaScript file using lfExecuteJS().
Code Block lfExecuteJS("hideLinks.js");
In “hideLinks.js”, use the attr() jQuery function to get the issue context for the page.
Code Block var issueKey = AJS.$("meta[name='ajs-issue-key']").attr("content");
Next, add the ajax call. The following script calls the webhook we created and then uses the data (issue and link ids) to hide the desired links using the hide() function.
Code Block AJS.$.ajax({ url: "http://<BASE_URL>/rest/keplerrominfo/refapp/latest/webhooks/hideLinks/run?key=" + issueKey }).then(function(data) { var linkData = data.linkData; for ( var i = 0, l = linkData.length; i < l; i=i+2 ) { AJS.$("#internal-" + linkData[ i + 1 ] + "_" + linkData[ i ]).hide(); // console.log(linkData[ i ]); // console.log(linkData[ i + 1 ]); // console.log("#internal-" + linkData[ i + 1 ] + "_" + linkData[ i ]); // console.log("-----------------------"); } });
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...