ScriptRunner Web Fragments to change UI to disable cloning in 1 project?

Hi,

Does anyone know if it is possible to use the new Web Fragments feature of ScriptRunner to alter the UI to prevent issue cloning in just 1 project? And if so, how?

Thanks in advance

Conor

3 answers

1 accepted

This widget could not be displayed.

Hi Conor,

Our latest release includes a built-in script to allow you to conditionally hide UI elements (like the Clone button):

https://scriptrunner.adaptavist.com/4.1.3.16/jira/fragments/HideUIElement.html (for JIRA 6.3/6.4)

https://scriptrunner.adaptavist.com/4.3.5/jira/fragments/HideUIElement.html (for JIRA 7.x)

I hope you like it.

regards, Mark.

Thank you Mark! This is exactly what i needed.

I've implemented this for 1 of our projects and it works great!!

Super support as always from you guys smile

Hi Mark McCormack

I'm having some difficulty in finding how to get to go to Admin → Script Fragments

 

can you help me find it?

Sure thing: please try the Jira Admin (cog) --> Add-ons then find the ScriptRunner section and finally choose Script Fragments.

Alternatively you could try using "." (or even "g+g" or press g twice) and then type "Script Fragments".

I hope that helps.

This widget could not be displayed.

Hi,

The following script should hide "Clone" menu item for one project only. Tested in JIRA 7 and works fine.

  1. Select ScriptRunner "Script Fragments -> Install web resource". Provide details [screenshot attached]:hide-clone.png

    You can also check ScriptRunner web resources from here: https://scriptrunner.adaptavist.com/latest/jira/fragments/WebResource.html

  2. The javascript file "hide-jra.js" contains the following code:

    (function ($) {
    
        $(function () {
            /**
             * Binding is required for link such as
             * http://localhost:8080/jira/projects/JRA/issues/JRA-4?filter=allopenissues
             */
            JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(event, $context, reason) {
                if (reason === JIRA.CONTENT_ADDED_REASON.pageLoad || reason === JIRA.CONTENT_ADDED_REASON.panelRefreshed ) {
                    hideCloneMenuItem();
                }
            });
    
            //calling function for link such as: http://localhost:8080/jira/browse/JRA-5
            hideCloneMenuItem();
        });
    
    
        /**
         * Hide the clone menu
         */
        function hideCloneMenuItem() {
            var projectKey = "JRA";
            var issue = JIRA.Issue.getIssueKey();
            if (typeof (issue) !== "undefined") {
                var currentProject = issue.substr(0, issue.indexOf('-'));
                if (currentProject == projectKey) {
                    $("a#clone-issue").hide();
                }
            }
        }
    }) (AJS.$);

     

    I have used project key "JRA" for this example. 

Hi Ashraful,

I have the following based on your answer above -

  • created the script resource dir,
  • added the js script to it (updated the project key)
  • updated the setenv.sh args to pick up new directory
  • restarted JIRA
  • and added the web resource.

Unfortunately this does nothing (other than not throw an error, which at least confirms it's picking up my resource directory).

I'm running JIRA 6.4.7 (our org. is not able/ready to upgrade to JIRA 7 just yet)

Any ideas?

Kind regards

Conor

 

 

 

Hi - the script has been updated and it works fine in JIRA 6.4.7. I have removed "AJS.toInit" from 2nd line. After uploading the script you may need to restart the JIRA instance.

This widget could not be displayed.

Hi

Not sure if you already implemented this.

1. Click on Hide system or plugin UI element 

2. type com.atlassian.jira.plugin.system.issueoperations:clone-issue in what to hide (Module key)

3. Put this condition !(jiraHelper.project?.key == "Project_Key") 

Save

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

492 views 3 18
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