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

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.

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.

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

71 views 0 5
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