-
-
Save philwolstenholme/fe31065b932474cbbc2e to your computer and use it in GitHub Desktop.
Adds an input to the Jira operations toolbar which contains a git command to create a new branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name StupidJira | |
// @namespace http://mikebell.io | |
// @version 0.1 | |
// @description Add branch details | |
// @match https://jira.ctidigital.com/browse/* | |
// @grant none | |
//allow pasting | |
// ==/UserScript== | |
(function() { | |
var inputWrapper = document.createElement("form"); | |
inputWrapper.className = 'toolbar-group aui'; | |
inputWrapper.style.width = '310px'; | |
var input = document.createElement("input"); | |
input.id = "stupidjira"; | |
input.className = "text"; | |
input.value = "git checkout -b "; | |
input.value += typereturn(); | |
input.value += '/'; | |
input.value += getTicketId(); | |
input.onclick = function () { | |
this.select(); | |
} | |
input.onmouseup = function () { | |
return false; | |
} | |
var container = document.querySelector(".ops-menus .toolbar-split"); | |
inputWrapper.appendChild(input); | |
container.appendChild(inputWrapper); | |
function typereturn() { | |
var type = document.getElementById("type-val").textContent.trim(); | |
if (type == 'Code Sub-task') { | |
return 'feature'; | |
} | |
else if (type == 'Story') { | |
return 'feature'; | |
} | |
else if (type == 'Task') { | |
return 'feature'; | |
} | |
return 'bugfix'; | |
} | |
function getTicketId() { | |
var metas = document.getElementsByTagName('meta'); | |
for (i=0; i<metas.length; i++) { | |
if (metas[i].getAttribute("name") == "ajs-issue-key") { | |
return metas[i].getAttribute("content"); | |
} | |
} | |
return ""; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment