NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Jira get issue transitions // @description Adds a button to get the list of transitions available for the current issue // @namespace https://openuserjs.org/users/floodmeadows // @copyright 2021, floodmeadows (https://openuserjs.org/users/floodmeadows) // @license MIT // @version 0.1 // @include https://jira.*.uk/browse/* // @updateURL https://openuserjs.org/meta/floodmeadows/Jira_get_issue_transitions.meta.js // @downloadURL https://openuserjs.org/install/floodmeadows/Jira_get_issue_transitions.user.js // @grant none // ==/UserScript== /* jshint esversion: 6 */ //--- Jira instance / project info ---// const currentUrl = new URL(document.URL); const jiraBaseUrl = currentUrl.protocol + '//' + currentUrl.host; const issueKey = document.getElementById("key-val").childNodes[0].nodeValue; const getIssueTransitionsUrl = `${jiraBaseUrl}/rest/api/latest/issue/${issueKey}/transitions`; (function() { 'use strict'; addLinkGetIssueTransitions(); })(); function addLinkGetIssueTransitions() { const newElement = document.createElement("a"); newElement.setAttribute("href","#"); newElement.setAttribute("class","aui-button toolbar-trigger issueaction-workflow-transition"); newElement.addEventListener("click", getIssueTransitions); const text = document.createTextNode("Get transitions"); newElement.appendChild(text); const target = document.getElementById('opsbar-transitions_more'); target.parentNode.appendChild(newElement); } function getIssueTransitions() { var headers = new Headers(); headers.append("Content-Type", "application/json"); var requestOptions = { method: 'GET', headers: headers }; fetch(getIssueTransitionsUrl, requestOptions) .then(response => console.log(response.json())) .catch(error => console.log('error', error)); }