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.
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.