0

Jira allows to add web fragments on different locations.

I'd like to write a plugin that adds another bulk operation but can neither find a location (if this done via a web fragement at all) nor a hint in the Jira Plugin Module Types how to add such an operation. From existing plugins (e.g. exporter) I got the impression that there must be a way.

Any help appreciated. Thanks.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Chris
  • 480
  • 1
  • 5
  • 11
  • There's nothing wrong about you question but unless some jira support is among us on SO I think it'd be better to ask their support which I think is very good. – t3chb0t Jan 09 '15 at 14:58
  • Well, I hope that I'm not the only one and some more experienced developers are here :-) – Chris Jan 09 '15 at 20:51
  • I read a question about this on answers.atlassian.com a few days ago – mdoar Jan 09 '15 at 22:57
  • Thanks, here's what I found: [Any doc/guideline to create a new BulkOperation in JIRA ?](https://answers.atlassian.com/questions/208792/answers/11970910) and [Bulk operations on Issues in JIRA](https://answers.atlassian.com/questions/18948), though maybe not that straight forward. – Chris Jan 10 '15 at 20:29

1 Answers1

0

It is possible to do it, here is what I did:

I extended AbstractBulkOperation class and used approach with EventListener to add this operation in afterPropertiesSet like this:

ComponentAccessor.getBulkOperationManager().addBulkOperation(MyOperationClass.NAME_KEY, MyOperationClass.class);

You need to implement canPerform, perform (the actual operation), getOperationName, getCannotPerformMessageKey, getNameKey, getDescriptionKey

I extended AbstractBulkOperationDetailsAction, but BulkEditBeanSessionHelper couldn't be autowired so I introduced protected constructor and got it there:

protected MyActionClass()
{
super(null, ComponentManager.getComponentInstanceOfType(BulkEditBeanSessionHelper.class));

genericBulkWatchOperation = ComponentAccessor.getBulkOperationManager().getOperation(NAME_KEY);
}

You need to implement getOperationDetailsActionName, doDetails,doDetailsValidation, doPerform methods in this class.

I created Webwork element in atlassian-plugin.xml, something like this:

<webwork1 key="key" name="name" class="java.lang.Object">
<actions>
<action name="path to action class" alias="Action">
<command name="details" alias="ActionDetails">
<view name="success">/secure/views/bulkedit/bulkchooseoperation.jsp</view>
<view name="input">/secure/views/bulkedit/bulkActiondetails.jsp</view>
<view name="error">/secure/views/bulkedit/bulkchooseoperation.jsp</view>
</command>
<command name="detailsValidation" alias="ActionDetailsValidation">
<view name="input">/secure/views/bulkedit/bulkActionconfirmation.jsp</view>
<view name="error">/secure/views/bulkedit/bulkActionconfirmation.jsp</view>
</command>
<command name="perform" alias="ActionPerform">
<view name="error">/secure/views/bulkedit/bulkActionerror.jsp</view>
</command>
</action>
</actions>
</webwork1>

JSP files cannot be embedded in plugin, I deployed them to /secure/views/bulkedit

To wrap it up - you need 3 classes (Operation, Action and EventListener), webwork definition in atlassian-plugin.xml and Event Listener definition also in atlassian-plugin.xml. Then you need JSP files. You can take existing ones and use them as an example. Basically I took WatchIssue operation files and did it analogically.

I strongly suggest to take a look at JIRA code to see how they do it.

Robert
  • 3,276
  • 1
  • 17
  • 26