Mike Caron
Mike Caron

Reputation: 5784

How to render html content in postfuntion name of jira workflow add-on?

I'm building a JIRA add on that contains some workflow post-functions. I want to customize the description UI when attempting to select a post function for a transition from the available choices. I know this can be done, because the Jira Workflow Toolkit plugin does just this by placing some HTML content after the description.

enter image description here

In the atlassian-plugin.xml, the workflow function is listed with a name key and a description key, like so:

<workflow-function key="abcdefg" name="Abcdef G" i18n-name-key="abcdefg.name" class="jira.plugins.postFunctions.workflow.AbcdefGFactory">
  <description key="abcdefg.description">This is what Abcdef G does...</description>
  ...
</workflow>

There is a resource file also listed in the plugin xml that contains the previously mentioned keys,

abcdefg.name = Abcdef G
abcdefg.description = This is what Abcdef G does...

I have velocity templates for view and input, but those don't correspond to the view of selecting a post function for a transition. I can't seem to find a factory method that would over-ride that display either.

How can I tap into the rendering of that Name or Description field in the Add Post Function To Transition view?

Upvotes: 1

Views: 156

Answers (1)

Mike Caron
Mike Caron

Reputation: 5784

I found out that all I had to do was add a WebResource consisting of a javascript file with the right contexts. The javascript looks for my postfunction labels and adds the little bit.

In the atlassian-plugin.xml:

<webresource ...>
    <description>...</description>
    <resource name="..." type="download" location="js/doit.js"/>
    <context>atl.admin</context>
</webresource>

Then the javascript file looks something like this:

AJS.$( document ).ready(function() {
    annotateWorkflowPostFunctions();
});

function annotateWorkflowPostFunctions() {
    var labels = AJS.$("label[for*='mykey']");
    labels.each(function() {
        $( this ).append(
            '<span class="aui-lozenge aui-lozenge-error">By Mike</span>'
        );
    });
}

Not to bad altogether.

Upvotes: 1

Related Questions