Show/Hide Queues based on user group

Ricard_Gonzalez September 7, 2017

I try to hide queues using script fragments in jira service desk, but I have a problem with continuous refresh jira service desk queues list page because I can hide some queue but as the page refreshes continuously, the script's function goes into an infinite loop. I want to know if someone know alternative solution to hide queues based on user permission.

Now, my script is :

(function ($) {
var elementFound = false;
var userName = JIRA.Users.LoggedInUser.userName();
var queuesId = [];
//Call endpoint to get queues to hide
$.ajax({
url: AJS.contextPath() + "/rest/scriptrunner/latest/custom/getQueuesToHide?username=" +
userName,
type: "GET",
beforeSend: function (request) {
request.setRequestHeader("X-Atlassian-token", "no-check");
}
}).fail(function (XMLHttpRequest, textStatus, errorThrown) {
console.log("failed... look at server logs for why");
}).done(function (data) {
if(data) {
queuesId = data;
}
});
$(document).bind("DOMSubtreeModified", function(evt) {
if (elementFound)
return;
//Waiting changes in Left Grid of Queue List
if ($("#pinnednav-opts-sd-queues-nav").length > 0) {
console.log("Entramos en QUEUE grid");
var queueListObserver = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (!mutation.addedNodes) return;
var element;
for (var i in queuesId) {
element = AJS.$("[data-item-id='" + queuesId[i] + "']");
element.remove();
}

})
});

elementFound = true;

var targetQueueList;

if ($("#pinnednav-opts-sd-queues-nav").length > 0)
targetQueueList = document.getElementById("pinnednav-opts-sd-queues-nav");

queueListObserver.observe(targetQueueList, {
childList: true
, subtree: true
, attributes: false
, characterData: false
});
}
//Waiting changes in table of queue issues list
if ($("#issuetable").length > 0 ) {

var tableObserver = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (!mutation.addedNodes) {
return;
}
var element;
for (var i in queuesId) {
element = AJS.$("[data-item-id='" + queuesId[i] + "']");
element.remove();
}
})
});

var tableTarget;

if ($("#issuetable").length > 0)
tableTarget = document.getElementById("issuetable");

tableObserver.observe(tableTarget, {
childList: true
, subtree: true
, attributes: false
, characterData: false
});
}
});

})(AJS.$);

Thank's!

Ricard

 

1 answer

1 vote
Jiraconfluence Solutionmgm sIT April 24, 2019

Hello.

 

We solved that with the issue security.

The issues are mainly created via Email.

When an email comes in, we check the sender's mail address and set the Security Level automatically.

In that way the users see severall queues but they only see issues in their own queue.

 

BR

Suggest an answer

Log in or Sign up to answer