How to hide system elements (voters)

Alik March 10, 2020

Hi all,

I want to hide only voters information from issues (my jira instance version 7.12) and I find out a lot of variants to perform that, but all of variants are not working. 

1. First method to inject ajax calls in jira. Problem in that, I haven't power script plugin in my instance. There are anyway to inject ajax calls with other methods or with script runner ?

AJS.$("#view-voter-list").parent().parent().hide();
AJS.$("#view-voters").hide();
AJS.$("#toggle-vote-issue").hide();

2. To use groovy build in script - Hide UI Element Built-In Script. I have groovy script plugin and tried to do that but something went wrong and voters already appear in issue view screen. Other elements like clone, duplicate and etc. are manageable via this script

voters.jpg

Please help to hide voters via script runner scripts or with other methods.

Thanks in advance

Regards,

Alik

1 answer

1 accepted

3 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 11, 2020

Hi Alik,

I understand that you want to be able to hide the votes on Jira issues in your Jira Server 7.12 version.  It is possible for you to do this, even without Scriptrunner.  Jira Server has an announcement banner, which will let you include HTML or scripts that can be used on all Jira pages.  This feature is not available in Jira Cloud.

In your case you could use this as a means to hide voters from the page for all users.  I have found though that the elements on the page have changed in Jira server over time.  For example, you can hide this watcher's field in 7.12.3 with a script such as:

<!-- Hides votes field Jira 7.12 -->
<script type="text/javascript">
AJS.toInit(function(){
AJS.$('#peoplemodule.module.toggle-wrap > div.mod-content > ul.item-details:not(#peopledetails) > li > dl:nth-child(1)').hide();
});
</script>

 

However I found that this script doesn't work as well for Jira 8.7.1 because the elements have changed a bit.  For example, the script in that version would have to be:

<!-- Hide votes field Jira 8.7.1 -->
<script type="text/javascript">
AJS.toInit(function(){
AJS.$('#peoplemodule.module.toggle-wrap > div.mod-content > div.item-details:not(#peopledetails) > dl:nth-child(1)').hide();
});
</script>

 

Please note that while customizations of this nature in the announcement banner can hide elements on the page, it does not restrict end users from being able to see this information in other locations, such as via the REST API.

As for the Scriptrunner aspects, well I have to admit, I am not well versed in using that particular function of that add-on.

 

But aside from the above approach of customization, have you considered adjusting the permission scheme of this project as a means to control this?  Just in case you did not know, Jira permission schemes can be customized to only permit allowed users to "View voters and watchers".  This is details in Managing project permissions.  The advantage of this approach is that you can restrict which projects in Jira would show watchers and voters to users or groups of users.  The limitation here is that this controls who views both voters and watchers.  So perhaps you do not want to restrict users from seeing watchers via permissions here, then this method might not be ideal.

Please let me know if you have any questions or concerns about either approach here.

Andy

Alik March 12, 2020

Hi @Andy Heinzer ,

Thanks for your answer, I will check. I need to hide the votes only in particular project and in this case this method will not work for me

Thanks for your time I really appreciate your answer

 

Regards,

Alik

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 12, 2020

Ah, in that case, there is still a means that this might work.  For example, you could add a custom field to Jira, and only have that custom field with a single context that makes that field appear in this single project (ie not a global custom field that would appear in all projects). 

You could then add a script such as the one above to the Description of that custom field.  This description will be included as long as that field appears on the screen, and in turn it might be one method that you could still use this screen, but keep it project specific only.

I didn't mention this way previously because it takes a few more steps to setup than using the announcement banner, and I didn't realize your use case here was project specific.  That said I think this could still be a viable alternative.

Let me know if you have any questions or concerns about this.

Andy

Srikanth Ganipisetty December 8, 2020

@Andy Heinzer 

Thanks for the solutions above. But, I didn't understand properly to the last solution that you provided, which is adding a custom field, and making script to show text above on the custom field as a description. But, how do I use it as alternative for hiding votes and vote button on issues? Can you please explain it briefly? 

Thanks!

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 8, 2020

Hi @Srikanth Ganipisetty 

Sure thing.  This gets confusing quickly because all versions of Jira Server starting with 8.7.0 and higher, that have not previously included any HTML tags in a field description will find that this won't work by default.  In that version we shipped JRASERVER-70859 which disabled this for new Jira sites or any site that never used it.

However any Jira System admin can turn this feature on again.  Please see Configuring Jira application optionsEnable HTML in custom field descriptions and list item values for details.  With that feature enabled, Jira will parse any HTML tags in a field description, when that field is expected to be displayed on the screen.  So this is another possible way to inject HTML onto the page that the browser will process as the page loads for the end user.

The announcement banner tends to be preferred as it appears on all pages.  However in some cases, sometimes you might not want the HTML/script to run on all pages.  So the field descriptions can be used to the same effect here.  There are steps on how to edit the custom field description you can find in Configuring a custom field: Editing a custom field.

I hope this helps.

Andy

Suggest an answer

Log in or Sign up to answer