Disable Project name editing

apuskarcik August 6, 2019

Hello,

I would like to prevent users from changing the project's Name, the same way they can't edit the project Key.

I noticed the project Key has 'disabled' in the HTML:

<input class="text" type="text" name="key" id="project-edit-key" value="JISJECP" maxlength="20" disabled="">

So, it is greyed out and can't be edited.

I would like to achieve the same for Name. I was thinking about using ScriptRunner to achieve it, the same way I used it to change the width of custom fields. However, the project name doesn't have any id:

<input class="text" maxlength="100" name="name" type="text" value="Project name (23248)"

Could someone give me hint on how to achieve it, please? 

If the above won't work, would it be possible to use ScriptRunner Script Fragments to 'hide' the Name field completely?

Thanks!

1 answer

1 accepted

2 votes
Answer accepted
Tanya Gordon
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 6, 2019

Hi,

First, the easiest way to do this is to disable the project administer permission. Users that don't have this permission can't reach the project details page and of course, can't change the project name. 

If this is not acceptable, I would try using the announcement banner to deliver the code snippet that will disable the project name for editing.

Regarding ScriptRunner Script Fragments, I don't think it's applicable for the project details screen, unfortunately.

Regards,
Tanya

apuskarcik August 7, 2019

Thank you, Tanya! I will try using the announcement banner.

apuskarcik August 12, 2019

Just to note here, in the end, I used the Script Fragments:

Hide what:

jira.webragments.view.project.operations:edit_project

Condition:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

if (groupManager.isUserInGroup(currentUser, "jira-admin")) {
true
} else {
false
}

 It hid Details, Re-index and Delete project, which is even better :)

M Vijay Kumar April 15, 2020

Any update on the above ? I want to make sure even project admin should not change the project name.

Fabio Manzoni May 17, 2021

Hi @apuskarcik 

I used your code and works very well to me.

I just change import com.atlassian.jira.ComponentManager to  import com.atlassian.jira.component.pico.ComponentManager

And invert the if condition to meet my condition and worked very well.

 

Thanks,

Fabio

Fabio Manzoni September 10, 2021

@apuskarcik 

I'm here again... 

Just a question, this code works for my, but I discovery another case.

Insight the project configuration the item details disappear, but going to cog icon and select projects in Jira menu its possible to edit the project name.

Have you same suggestion to don't allow users to edit project name in this part?

Thanks, 

Fabio

Suggest an answer

Log in or Sign up to answer