Skip to content

Instantly share code, notes, and snippets.

@6220119
Last active February 14, 2017 07:28
Show Gist options
  • Save 6220119/8c08768b33e72af60e4b98ba9232bae5 to your computer and use it in GitHub Desktop.
Save 6220119/8c08768b33e72af60e4b98ba9232bae5 to your computer and use it in GitHub Desktop.
JIRA scripts (JIRA v1000.747.1)
(function () {
var assignee = $('#assignee-val > span').attr('rel');
if (assignee) {
$('#footer-comment-button').click();
$('#comment').val('[~' + assignee + '], This is an auto-generated comment, please add submitted change list number, Reviewed by, root cause analysis and solution if applicable');
$('#issue-comment-add-submit').enable().click();
} else {
alert('No assignee!');
}
})();
(function ($, window, newLabel) {
if (!$) {
alert('No JQuery!');
return;
}
var issueId = $("input[name=id]")[0];
if (issueId) {
issueId = issueId.value;
} else {
alert('Cannot find Issue ID! Please update the script!');
return;
}
var atl_token = $("input[name=atl_token]")[0];
if (atl_token) {
atl_token = atl_token.value;
} else {
alert('Cannot find ATL_TOKEN! Please update the script!');
return;
}
var existingLabels = [];
var labelsSelector = "#labels-" + issueId + "-value";
var elem = $(labelsSelector);
if (elem[0]) {
if (elem.prop('tagName').toUpperCase() === 'UL') {
$(labelsSelector + ' li a.lozenge[title]').each(function (index, e) {
existingLabels.push($(e).attr('title'));
});
// this may change in the future?
if (existingLabels.length === 0) {
alert('Cannot get any label, even though there are a list of them. Please update the script!');
return;
}
} else {
//NONE, no label, get SPAN elem
}
} else {
alert('Cannot find labels section! Please update the script!');
return;
}
var formData = new FormData();
existingLabels.map(function (label) {
formData.append('labels', label);
return label;
});
formData.append('labels', newLabel);
formData.append('inline',true);
formData.append('id', issueId);
formData.append('decorator', 'dialog');
formData.append('noLink', false);
formData.append('atl_token', atl_token);
$.ajax({
url: '/secure/EditLabels.jspa?atl_token=' + atl_token,
data: formData,
processData: false,
contentType: false,
type: 'POST',
success: function(data){
window.location.reload();
}
});
})($, this, '[AUTO]-Lacking-Details-Comment');
(function ($, window, labelToBeRemoved) {
if (!$) {
alert('No JQuery!');
return;
}
var issueId = $("input[name=id]")[0];
if (issueId) {
issueId = issueId.value;
} else {
alert('Cannot find Issue ID! Please update the script!');
return;
}
var atl_token = $("input[name=atl_token]")[0];
if (atl_token) {
atl_token = atl_token.value;
} else {
alert('Cannot find ATL_TOKEN! Please update the script!');
return;
}
var existingLabels = [];
var labelsSelector = "#labels-" + issueId + "-value";
var elem = $(labelsSelector);
if (elem[0]) {
if (elem.prop('tagName').toUpperCase() === 'UL') {
$(labelsSelector + ' li a.lozenge[title]').each(function (index, e) {
existingLabels.push($(e).attr('title'));
});
// this may change in the future?
if (existingLabels.length === 0) {
alert('Cannot get any label, even though there are a list of them. Please update the script!');
return;
}
} else {
//NONE, no label, get SPAN elem
}
} else {
alert('Cannot find labels section! Please update the script!');
return;
}
var formData = new FormData();
existingLabels.map(function (label) {
if (labelToBeRemoved !== label) {
formData.append('labels', label);
}
return label;
});
formData.append('inline',true);
formData.append('id', issueId);
formData.append('decorator', 'dialog');
formData.append('noLink', false);
formData.append('atl_token', atl_token);
$.ajax({
url: '/secure/EditLabels.jspa?atl_token=' + atl_token,
data: formData,
processData: false,
contentType: false,
type: 'POST',
success: function(data){
window.location.reload();
}
});
})($, this, '[AUTO]-Lacking-Details-Comment');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment