how to hide default watchers field from issue view screen?

jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 18, 2017

Hey all,

 

I am using watcher plugin. So I created new created new field called "watcher"(Watcher type field) through this plugin. It works great providing features like adding watchers anytime and for some automations. 

 

We are planning to use this watcher field for browse permission. In order to avoid any confusion, I want to hide the default watchers field. Is there a way to hide this using velocity templates?

2 answers

1 vote
Renat Osmanov June 3, 2019

Login with Jira Administrator.

System menu --> General Configuration --> Edit Settings

In Option menu list find WATCHING and click button OFF. Also you can switch off Voting

jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2019

I tried that already. But it will also disable watcher plugin configuration. 

 

I mean it turns off entire watching feature. 

1 vote
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 19, 2017

I am not sure about editing the velocity template as a means to hide this information in Jira.  That approach might be possible to do as well. 

However I think I might have another way to hide this from view.   My approach was to try to use a custom javascript that would hide those page elements from being displayed when the browser renders the page.

In this case I added this javascript to a custom field description.   In this case, it might be best just to create a new custom field that only appears on the project(s) where you want to hide the watch field in Jira.   This way when Jira loads the page that contains this custom field, looking at this issue details view will still trigger this custom script to run and in turn hide these elements.   Otherwise, adding this to a description of a field that appears on all Jira issues for example, this would cause all these issues to hide these page elements from view.

In my testing I found that I could hide the default Watcher field on issue details view with the script of:

<script type="text/javascript">
    AJS.toInit(function(){
      AJS.$('#watching-toggle').hide();
      AJS.$('#view-watcher-list').hide();
      AJS.$('#peoplemodule > div.mod-content > ul:nth-child(2) > li > dl:nth-child(2) > dt').hide();
    });
</script>

It's possible that your #peoplemodule entry might be different.  I'm afraid that the watcher elements don't exactly have an explicit selector name/id, which makes it a bit more tricky to hide these with a script.  If you're Jira instance has more elements under this People section, say because you might be using another plugin to Jira, then then one of the nth-child attributes might be a different number for your Jira instance.

jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2017

I have put this in announcement banner and it worked. 

I am assuming this code will just hide the watcher from the user view and the field still exists on the screen. If someone tried to add watcher via rest api it will work?

Could you explain your code?

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

Yes, that is true.  This just hides this element from being displayed on the web page.  It does not disable any REST functionality with Jira.  So yes, a REST user could still use/see this watcher information.

The code is derived from this Confluence guide on hiding page elements:  How to hide elements in Confluence using CSS or JavaScript.

What I did was to click and select this part of the page itself, then right click and select the Inspect option in my browser.  I know Chrome and Firefox have this option to show you the html code of the page.  From there it is a matter of finding the selector tags in the code in order to hide those elements.

jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2017

This is great. Thanks for explaining and pointing to the kb article. I have tested this in my sandbox environment. It works both in field and announcement banner. For some reason it doesn't work in custom field in production but works in announcement banner. 

So I am assuming nth child element is correct but it is not rendering through the custom field? 

jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2017

I got it to work by adding it to description of custom field in field configuration of the specific project. Still would like to have it work globally.

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

I used a custom field to do this because I knew I could control exactly which screens in Jira this custom field would appear on.  That might be why that doesn't work in your environment.  If the screen you are using in Jira does not yet contain that custom field, then the script does actually get injected into the page display this way.

The announcement banner is another way to do this, but doing that makes sure this happens site wide.  Meaning every page in this Jira instance would have that little javascript running to hide those elements.

jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 28, 2017

It is working ok. But the drawback is after entering the value in the custom field and saving makes the default watchers field visible. 

 

Reloading the page will hide the default watchers again. Is there a way to not show the default watchers after saving the custom watcher field?

 

Also found another interesting thing. If the user doesn't have edit permission, I believe javascript is not executed. Hence both watcher fields are visible!

jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 12, 2019

Hello @Andy Heinzer 

I found that in JIRA 8, I can't really add this to field description and make it work. Would you know why?

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

Hi @jira guy 
I found out there is a documented bug for this in JRASERVER-69293.  So far it has not gotten much attention, but it looks like something has changed in the Jira 8 releases that is not executing such javascript until the field is edited.

Perhaps the script could be adapted to be used in the announcement banner instead.  That location does not appear to be affected by this change.

jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 12, 2019

Given the low priority of the bug. I don't think this will ever get fixed or looked.

I voted and did my part.

Suggest an answer

Log in or Sign up to answer