If you have ScriptRunner, use the Script Fragment's "Hide system or plugin UI element."
Under "Hide what," choose:
com.riadalabs.jira.plugins.insight:rlabs_insight_topmenu
You might also want to hide the assets icon on Kanban boards:
com.riadalabs.jira.plugins.insight:rlabs-project-jira-section
Then under condition, you can specify that only certain people can see the banner:
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if (ComponentAccessor.groupManager.isUserInGroup(currentUser, "administrators") || ComponentAccessor.groupManager.isUserInGroup(currentUser, "system-administrators"))
return true
else
return false
This code worked for me - I used it to block access to the menu item "assets" and creating a jsm project to only those in a specific group (jsm-access) - might work for others so including it here. I left debugging in, but commented out. But shows you can grab via rest in JS and use it conditionally to set display=none as required.
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
fetch('/rest/api/2/myself?expand=groups', {
headers: {
'Accept': 'application/json'
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
/*
// Debug: List user groups in the banner
var groupNames = data.groups.items.map(group => group.name).join(', ');
var banner = document.getElementById('announcement-banner');
if (banner) {
banner.innerHTML += '<p>User Groups: ' + groupNames + '</p>';
}
*/
// Check if the user is not in 'jsm-user'
if (!data.groups.items.some(group => group.name === 'jsm-user')) {
// Debug message for not being in the target group
var banner = document.getElementById('announcement-banner');
if (banner) {
banner.innerHTML += '<p>User is not in the target group. Hiding elements.</p>';
}
// Use MutationObserver to hide the elements when they become available
var observer = new MutationObserver(function(mutations, obs) {
var elementsToHideIds = ['project-template-group-service_desk', 'rlabs_insight_topmenu_link','project_type_service_desk','service_desk-project-type'];
elementsToHideIds.forEach(function(id) {
var elementToHide = document.getElementById(id);
if (elementToHide) {
elementToHide.style.display = 'none';
}
});
// Optional: Stop observing if both elements are found and hidden
// if (elementsToHideIds.every(id => !document.getElementById(id))) {
// obs.disconnect();
// }
});
observer.observe(document.body, {
childList: true,
subtree: true
});
} else {
// Debug message for being in the target group
var banner = document.getElementById('announcement-banner');
if (banner) {
banner.innerHTML += '<p>User is in the target group.</p>';
}
}
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
});
});
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Jira User ,
There isn't a straight forward way. It's either through coding or possibly add-ons.
Here's some posting of similar ask:
https://community.developer.atlassian.com/t/hiding-native-menus-and-menu-items-via-code/13918
Thanks,
Ben
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.