The comment visibility default selection can be configured?

The comment visibility can be selected when someone creates a new comment. However, the default selection is "All Users". Can it be changed to a specific group/project-role? Maybe on a project basis?

Thank you.

8 answers

1 accepted

You can change default comment visibility doing the next steps:

1.- Go to Administration->Issues->User Interface->Announcement Banner
2.- Put the next script:

<script language="JavaScript">
<!--
jQuery.noConflict();
var defaultRoleName = "role:10001";
var customRoleSelected = false;

function changeCommentLevel()
{
if (customRoleSelected) return;

var commentLevelSelect = jQuery('.security-level select#commentLevel option[value=\'' + defaultRoleName + '\']');
if (commentLevelSelect)
{ var labelText = commentLevelSelect.first().text(); jQuery("select#commentLevel").val(defaultRoleName); jQuery("#commentLevel-multi-select a.drop span.icon").removeClass("icon-unlocked").addClass("icon-locked"); var htmlEscapedLabel = AJS.$("<div/>").text(labelText).html(); jQuery(".security-level span.current-level").html(AJS.format(AJS.params.securityLevelViewableRestrictedTo, htmlEscapedLabel)); }

}

jQuery('#comment').live('focus', changeCommentLevel);
jQuery('#commentLevel-suggestions').live('click', function()
{ customRoleSelected = true; }

);
//-->
</script>

<style>
.alertHeader
{display:none;}

</style>

CAUTION: 'role:10001' must be match with the role that you want to put default. In my case is 10001.

Hope this helps.

Best regards,

Daniel

It works even when you have two different groups of users that need to have different defaults?

For example:

  • A group "customers" with default "All users".
  • jira-developers and jira-administrator and jira-users with default jira-users

BTW, thank you for your answer.

I think you're confusing terms.

One concept is a role of project. A Role contain user or group of user. For example in my JIRA configuration I have 2 role: Developers and Clients. 'Developers' contain the group of users of my configuration that are developers of my company and the same by role 'Clients'.

In my JIRA, I put default comment visibility to 'Developers' so ever comment I put in Issue can only view to developers. With this I prevent information leaks that I don't wnat to be seen by my clients.

Do you understand me?

Thanks Daniel!

This works for me!

Hi Daniel,

Could this be modified to hide a specific Project Role from showing in the Comment permissions drop down?

I'm trying to hide a specific Project Role from showing in the drop down for comments. Editing the global.vm seems to be the way to go, but I don't understand how to single out that Project Role from showing.

This is the code that controls the drop-down options:

#if ($isRolePresent)
<optgroup label="$i18n.getText('common.words.project.roles')">
#foreach ($level in $roleLevels)
<option value="role:${level.id}" #if($level.id && $selected == "role:${level.id.toString()}")selected="selected"#end>$textutils.htmlEncode($level.name)</option>
#end
</optgroup>
#end

I'm hoping to modify this to hide on specific group, something like this:

#if ($isRolePresent && !ProjectRole == "Name of Project Role To be Hidden")
<optgroup label="$i18n.getText('common.words.project.roles')">
#foreach ($level in $roleLevels)
<option value="role:${level.id}" #if($level.id && $selected == "role:${level.id.toString()}")selected="selected"#end>$textutils.htmlEncode($level.name)</option>
#end
</optgroup>
#end

But of course that logic doesn't work. Any suggestions?

Works like a charm, thanks Daniel!

Hi all,

This is almost what I am looking for! I just want to throw out this additional use-case and see if there are any solutions for it:

What if I want to have 2 different Comment buttons? One for regular comments visible to "All Users" and one for internal comments viewable to a specific project group only?

I have taken the script above and tweaked it to my best knowledge but I get a weird behavior that JIRA remembers the last used security level. It has to do with refreshing page in some way. Please take a look at this post for details: https://answers.atlassian.com/questions/221408/separate-button-for-internal-comment-in-jira

Does anyone have a clue why this is the case and in that case is there a way of working around this?

Looking forwards to your replies!

// Svante

Hi, can someone explain to me how I make this work? I've placed the code in the banner field: /secure/admin/EditAnnouncementBanner.jspa without effect.

Thanks.

Jan

JIRA 5.2

Hi Daniel, Does this works for JIRA 6.x?

This doesn't work for Jira 6.3.14

This is not available yet but the request seems to have gathered many votes: https://jira.atlassian.com/browse/JRA-9091

The answer provided by Daniel is great, but using "jQuery.noConflict();" in the beggining of the code can break the Classic Agile boards with an infinite spinning wheel. To fix this, you can use the code Daniel provided and just remove this line.

Thanks Pietro,

I was having a strange behaviour where auto-complete wasn't working anymore in the issue navigator JQL filters and removing jQuery.noConflict() fixed it

 

Ok, thank you Danielle. I upvoted that issue.

In the meantime, I've found what could be a temporary workaround: the behaviours plugin. However, I haven't managed to make it work yet (w/ JIRA 5.0).

I think it's better my solution that to implement behaviours plugin...


If you upgrade JIRA, you will need to check the compatibility of the plugin with JIRA. However with my solution will not be necessary.

Hi, I realise you have found your answer but for others looking for an answer where they don't have to edit files or want a project level default then I have a paid plugin in the marketplace called comment security default (https://marketplace.atlassian.com/plugins/com.redmoon.jira.comment-security-default). This allows you to set a default globally or per project. You can also assign behaviour in case the permission is no longer available (you can force the user to choose a new permission). The default can be set for adding a comment, adding an attachment, logging work, linking issues and editing issues.

Thanks

Paul

Very nice! Thank you Paul, I'm glad there is a cleaner way to do it.

Thanks, Manuel

I agree. Thanks for mentioning this. I find it better as not all of my teams will want the same default. I also like the color visual to support it as well. I just tested it and I will be requesting a purchase of it.

In my tests if the inital code, the edit comment doe snot waork (the visible always change to Developers).

I made some changes and it worked

<script language="JavaScript">
<!--

jQuery.noConflict( );
var defaultRoleName = "role:10001";
var roleSelected = false;

function changeCommentLevel( )
{
	if ( roleSelected )
	{
		return;
	}//if

	if ( jQuery( '#comment' ).val() != "" )
	{
		// edition;
		roleSelected = true;
		return;
	}

	var commentLevelSelect = jQuery( '.security-level select#commentLevel option[value=\'' + defaultRoleName + '\']' );
	if ( commentLevelSelect )
	{
		var labelText = commentLevelSelect.first( ).text( );
		jQuery( "select#commentLevel" ).val( defaultRoleName );
		jQuery( "#commentLevel-multi-select a.drop span.icon" ).removeClass( "icon-unlocked" ).addClass( "icon-locked" );
		var htmlEscapedLabel = AJS.$( "<div/>" ).text( labelText ).html( );
		jQuery( ".security-level span.current-level" ).html( AJS.format( AJS.params.securityLevelViewableRestrictedTo, htmlEscapedLabel ) );
		roleSelected = true;
	}

}


jQuery( '#comment' ).live( 'focus', changeCommentLevel );
//-->
</script>
 
<style>
.alertHeader
{display:none;}
 
</style>

Daniel, I assume that this is only possible in Hosted version of Jira, and not OnDemand (as onDemand correctly encodes anything entered in the Banner field). Are you aware of a way to do this or anything close in the OnDemand version?

If such a way exists then I think Atlassian would treat it as a security problem.

I agree that this would be a security issue if this approach were to be allowed - just checking to see if there are any other workarounds that might be possible using existing capabilities (without injecting javascript into pages via the banner)

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

254 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you