Disable JIRA 4.4 add version functionality

Vinutha Vasan February 16, 2012

Hi All,

I would like to know is there a way to disable only "Add version" function in 'Versions' tab and rest all functions (merge, release, edit, archive and delete) should still work.

Background: I wanted to customize add version function so I have written a new plug-in and I want all users to go through the new customized version creation flow and want to disable the jira standard flow.

Kindly let me know if anybody have an idea.

Thanks,

Vinutha

2 answers

1 accepted

1 vote
Answer accepted
Dieter
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.
February 17, 2012

Hi Vinutha,

I have a java script based solution but it's not optimal since the table object is something that is created dynamically after the DOM ready event and i do not know yet how to hook in there. So i remove the "Add version" row just 500 ms after the DOM has been loaded and if you have good eyes you can see it flickering ... ;)

Just put this script in the announcement banner:

<script>
function hideAddVersion(){
  AJS.$(".project-config-versions-add-fields").remove();
}
AJS.$(document).ready(function(){
  setTimeout('hideAddVersion()',500);
});  
</script>

Vinutha Vasan March 27, 2012

Hi Dieter,

I tried the above JS solution to hide add version row from version screen .

But the problem is ".project-config-versions-add-fields" id is used in component creation page also for creating a component. Ideally JIRA should have used 2 different id's for version and component creation but unfortunately not.:(

So above solution is hiding both the functions but I am interested in only removing version creation.

Is there any other way without changing the source code of project-config-plugin?

Thanks,

Vinutha

Dieter
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.
March 27, 2012
Hi Vinutha, thank's for that hint, i hadn't thought of that. One has to add a check if the version tab is visible. at the moment i don't have access to a Jira installation to figure this check out. But i will have look at that again tomorrow .. for sure somethin can be found
Vinutha Vasan March 29, 2012

Hi Dieter,

Did you get a chance to have a look? Kindly let me know if you figure out any solution.

Thanks,

Vinutha

Dieter
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.
March 29, 2012

Ok, here we go:

&lt;script&gt;

function hideAddVersion() {
   AJS.$(".project-config-versions-add-fields").remove()
}

(function($){

   function delayedHideAddVersion() {
      setTimeout('hideAddVersion()',500)
   }

   $(document).ready(function(){
      url = window.location.pathname;
      filename = url.substring(url.lastIndexOf('/')+1);
      if (filename == "versions") {
         console.log(window.location.href)
         delayedHideAddVersion();
      }
   });
})(AJS.$);

&lt;/script&gt;

Dieter
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.
April 12, 2012
Hi Vinutha, did that script help?
Vinutha Vasan April 15, 2012

Hi Dieter,

Yes. Your solution resolved my problem. Than you so much.

Thanks,

Vinutha

Vinutha Vasan April 19, 2012

Hi Dieter,

Above java script to hide 'Add version' function working fine in Mozilla or Chrome but facing problem in IE.

If I set this script in Announcement banner, JIRA dashboards are not loading in IE :(.

It is displaying only header and footer. No body content.

Any idea?

Thanks,

Vinutha

Vinutha Vasan April 19, 2012

Hi Dieter,

As per view source and error line number, It is throwing error @ line “url = window.location.pathname” in the script.

Webpage error details

Message: Object doesn't support this property or method
Line: 278
Char: 7
Code: 0
URI: http://jira-dev:8095/secure/Dashboard.jspa
<br< a="">>

Thanks

Vinutha

Dieter
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.
April 19, 2012
Hi Vinitha, just tried it with IE8 and that worked. Which is your version?
Vinutha Vasan April 21, 2012

Hi Dieter,

I am using IE8 only.

Dieter
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.
April 21, 2012
Maybe the timeoit of 500ms is not sufficient. Try to increase that to 5000 for test purposes
Vinutha Vasan April 22, 2012

Hi Dieter,

I tried increasing timeout to 5000 but still not working.

Could you please pass me your email id, so that I can send you the screen shots.

Jira instance I am running is jira4.4 and IE is 8.

Thanks,

Vinutha

Vinutha Vasan February 24, 2014

Hi Dieter,

I am planning to move the above javascript function from announcement banner and trying to load the javascript in a plugin as webresource module.

I tried as per the instructions available @ https://developer.atlassian.com/display/JIRADEV/Web+Resource+Plugin+Module

Below is the implementation detail,

1. web-resource enty in atlassian-plugin.xml

<web-resource key="hideVersionCreationForm" name="HideVersionCreationForm" >

<resource type="download" name="hideVersionCreationForm.js"

location="includes/js/hideVersionCreationForm.js" />

<context>atl.admin</context>

</web-resource>

2. hideVersionCreationForm.js file

function hideAddVersion() {

AJS.$(".project-config-versions-add-fields").remove()

}

(function($){

function delayedHideAddVersion() {

setTimeout('hideAddVersion()',500)

}

$(document).ready(function(){

var url = window.location.pathname;

filename = url.substring(url.lastIndexOf('/')+1);

if (filename == "versions") {

console.log(window.location.href)

delayedHideAddVersion();

}

});

})(AJS.$);

3. Calling requiredResource method

The reference to WebResourceManagercan is injected into your constructor and callingwebResourceManager.requireResource.. in the doDefault as shown below,

webResourceManager.requireResource("version.management.plugin:hideVersionCreationForm");

Please let me know if I am doing anything wronge here, I am not able to see the javascript working with this approch. But if I put the same js in announcment banner its working fine.

Thanks,

Vinutha

0 votes
Dieter
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.
February 17, 2012

just for my curiousity: How do your get your new plugin installed in onDemand? Isn't that restricted to some plugins? Or is it a Speak-Easy-Plugin?

Suggest an answer

Log in or Sign up to answer