Skip to content

Instantly share code, notes, and snippets.

@jechlin
Created May 7, 2012 19:04
Show Gist options
  • Select an option

  • Save jechlin/2629735 to your computer and use it in GitHub Desktop.

Select an option

Save jechlin/2629735 to your computer and use it in GitHub Desktop.
prevent non admins editing the dashboard
(function($){
$(function(){
$.get(AJS.params.baseURL + "/rest/auth/1/session", function (data) {
userName = data.name;
// check groups
$.get(AJS.params.baseURL + "/rest/api/2.0.alpha1/user", {username: userName, expand: "groups"}, function (data) {
var groups = data.groups;
var groupItems = jQuery.map(groups.items, function (val, j) {return val.name});
// modify group(s) allowed to edit dashboard in the line below
if (jQuery.inArray("jira-administrators", groupItems) < 0) {
$("#dash-options").hide();
$('ul#dashboard_link_manage').hide();
}
});
});
});
})(AJS.$);
@OlivierAlbertini

Copy link
Copy Markdown

you need to change to this /rest/api/2/user for checking groups.

@Madd33n

Madd33n commented Mar 4, 2021

Copy link
Copy Markdown

HEy @jechlin @OlivierAlbertini - thanks for that awesome script.
It works fine exept for one constellation. There is still the "Create New Dashboards" button in the manage dashboards view.
Did you found a solution to prevent this button too? Or any other solution that "not admins" can create new dashboards?
Image 1031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment