ECOD-GitLab2Jira

Links back to Jira

Mint 2024.01.31.. Lásd a legutóbbi verzió

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         ECOD-GitLab2Jira
// @namespace    http://tampermonkey.net/
// @version      1.0.4
// @description  Links back to Jira
// @author       [email protected]
// @match        https://gitlab.ecodesigncloud.com/ecodesign*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    function hookTheMonkeyForGitLab() {
	function goToGitLabUrl(node){
		let baseUrl = 'https://jira.fsc.atos-services.net/browse/';
		let ecodRegex = /\becod[ -_]?\d+\b/i;
		let result = ecodRegex.test(node.innerHTML);
		if(result){
			let matches = ecodRegex.exec(node.innerHTML);
			return baseUrl + matches[0];
		}
		return false;
		//window.open(baseUrl + result, '_blank');
	}

	var linkGitLab = document.createElement('span');
	linkGitLab.setAttribute("style" ,"cursor:pointer;");
	linkGitLab.innerHTML = `<a href='#' class='gl-button btn btn-md btn-default gl-display-none gl-md-display-block js-issuable-edit'
								   target='_blank'
								   style='background-color: #5707a6;'
								   id='linkgit'
								   name='linkgit'>Go to JIRA</a>`;

	let node= document.querySelector('h1[data-testid="title-content"]')
	if(!node) node = document.querySelector('h3[class="commit-title"]')
	if(node) {
		let url = goToGitLabUrl(node);
		if(url){
			let divContainer = document.createElement('div');
			linkGitLab.firstChild.href = url;
			divContainer.appendChild(linkGitLab);
			divContainer.setAttribute("style", "margin-top:10px; display: inline-block");

			node.appendChild(divContainer);
		}
	}
}
    hookTheMonkeyForGitLab()
})();