Available Workflow Actions Customfield

Name JIRA Available Worklflow Actions Customfield
Version 0.2
Product Versions JIRA 3.5+
Author(s) Philip Herbst
Homepage Available Workflow Actions Customfield
Price FREE!
License  
JavaDocs  
IssueTracking  
Download JAR jira-available-workflow-actions-0.2.jar
Download Source  

Description/Features

A Customfield showing available workflow actions from the Issue navigator

Updated to work with Jira 3.5. Now supports redirect to Issue Navigator from transition view and i18n transition names. Developed with Eclipse and Maven.

Installation

Usage

Examples

Todo

Version History

Version Author Notes
0.1 Philip Herbst Initial release
0.2 Philip Herbst Excel View Improvement

Screenshots

Source

public class AvailableWorkflowActionField extends CalculatedCFType {
	private static final Category log = Category
			.getInstance(AvailableWorkflowActionField.class);

	private final JiraAuthenticationContext authenticationContext;

	private final IssueManager issueManager;

	public AvailableWorkflowActionField(IssueManager issueManager,
			JiraAuthenticationContext authenticationContext) {
		this.authenticationContext = authenticationContext;
		this.issueManager = issueManager;
	}

	private final Map loadAvailableActions(Issue issue) {
		Map availableActions = availableActions = new ListOrderedMap();

		try {
			Workflow wf = ManagerFactory.getWorkflowManager().makeWorkflow(
					getRemoteUser() == null ? null : getRemoteUser().getName());
			WorkflowDescriptor wd = null;

			GenericValue origianlIssueGV = issueManager.getIssue(issue.getId());

			wd = ManagerFactory.getWorkflowManager().getWorkflow(
					origianlIssueGV).getDescriptor();

			HashMap inputs = new HashMap();
			inputs.put("pkey", issue.getProject().getString("key"));
			inputs.put("issue", issue);
			inputs.put("originalissueobject", getIssueObject(origianlIssueGV));

			int actionIds[] = wf.getAvailableActions(origianlIssueGV.getLong(
					"workflowId").longValue(), inputs);
			for (int i = 0; i < actionIds.length; i  ) {
				int actionId = actionIds[i];

				availableActions
						.put(getUrl(issue, actionId, wd),
								getWorkflowTransitionDisplayName(wd
										.getAction(actionId)));
			}
		} catch (Exception e) {
			log.error(e);
		}

		return availableActions;
	}

	public String getWorkflowTransitionDisplayName(ActionDescriptor descriptor) {
		Map metadata = descriptor.getMetaAttributes();
		JiraWebActionSupport actionSupport = new JiraWebActionSupport();
		if (metadata.containsKey("jira.i18n.title")) {
			String key = (String) metadata.get("jira.i18n.title");
			String value = actionSupport.getText(key);
			if (value != null && !"".equals(value.trim())
					&& !value.trim().equals(key.trim()))
				return value;
		}
		return descriptor.getName();
	}

	public Map getVelocityParameters(Issue issue) {
		Map map = new HashMap();
		Map availableWorklowAction = null;
		availableWorklowAction = loadAvailableActions(issue);
		map.put("availableWorkflow", availableWorklowAction);
		return map;
	}

	public MutableIssue getIssueObject(GenericValue issueGV) {
		IssueFactory issueFactory = (IssueFactory) ComponentManager
				.getComponentInstanceOfType(IssueFactory.class);
		return issueFactory.getIssue(issueGV);
	}

	public Object getValueFromIssue(CustomField field, Issue issue) {
		return null;
	}

	public String getStringFromSingularObject(Object arg0) {
		return null;
	}

	public Object getSingularObjectFromString(String arg0)
			throws FieldValidationException {
		return null;
	}

	private User getRemoteUser() {
		return authenticationContext.getUser();
	}

	private String getUrl(Issue issue, int action, WorkflowDescriptor wd)
			throws Exception {
		String view = wd.getAction(action).getView();
		String baseUrl;
		StringBuffer urlParams = new StringBuffer();

		if (TextUtils.stringSet(view)) {
			baseUrl = "CommentAssignIssue!default.jspa?";
		} else {
			baseUrl = "WorkflowUIDispatcher.jspa?";
		}

		urlParams.append("&").append("id").append("=").append(issue.getId());
		urlParams.append("&").append("action").append("=").append(action);
		urlParams.append("&").append("returnUrl").append("=").append(
				"IssueNavigator.jspa");

		baseUrl  = urlParams.substring(1);
		return baseUrl;
	}
}

Velocity Template for column view

<table>
#foreach ($workflowAction in $availableWorkflow.entrySet())
<tr>
  <td valign=top>
    <span class="nowrap">
      <a href="${workflowAction.key}">${workflowAction.value}</a>

  </td>
</tr>
#end
</table>

Labels

plugin plugin Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jul 26, 2005

    Chanan J Braunstein says:

    what Jira Support Toolbar?

    what Jira Support Toolbar?

    1. Jul 26, 2005

      Philip Herbst says:

      included in JIRA Toolkit http://confluence.atlassian.com/display/JIRAEXT/JIRA+To...
  2. Apr 04, 2006

    Bettina Zucker says:

    Hello Philip, it's a pity there is no search templates for this custom field ty...

    Hello Philip,

    it's a pity there is no search templates for this custom field type.
    Otherwise one could search all issues for which some action is available and then execute it by bulk transition.
    The field seems not to be orderable either, so bulk transition by page instead of by search result set is not an option either.
    This was my personal use case.  How do you use this field?

    Cheers

    Bettina 

  3. Aug 15, 2006

    Dawn Hunter says:

    Philip, I think you are a genius. Thank you for sharing your tricks with us.

    Philip, I think you are a genius. Thank you for sharing your tricks with us.

  4. Oct 03, 2006

    Eyal Kaduri says:

    Philip hi, this is a great plug-in, however it causes a problem when exporting...

    Philip hi,

    this is a great plug-in,

    however it causes a problem when exporting to Excel - as each Action has a separate row in the excel, ( per Action ) - hence causing multiple rows to address one issue ( they are merged )

    I've attached an image in which the problem can be seen, as well as show another custom field in which this issue seem to be addressed.

     Any Ideas?

    Thanks

    Eyal

    1. Oct 03, 2006

      Philip Herbst says:

      Hi Eyal, I've updated the plugin so the field doesnt span over multiple rows in...

      Hi Eyal,

      I've updated the plugin so the field doesnt span over multiple rows in excel view.Just drop jira-available-workflow-actions-0.2.jar into WEB-INF/lib and delete the old jar.(available-workflow-action-field-0.1.jar).


      Cheers,

      Philip

      1. Oct 03, 2006

        Neal Applebaum says:

        Eyal & Philip, in case you'd prefer this solution, I've customized my Excel ...

        Eyal & Philip, in case you'd prefer this solution, I've customized my Excel output to skip over the Edit/Comment field (from the JIRA Toolkit) as well as my "Action" custom field from this plugin. So those fields are never even exported to Excel. Here's my code modification:

        atlassian-jira/secure/views/navigator/navigator-excel-current.jsp
        
        Add this code to replace line 7:
        
                         java.util.Collections,
                         java.util.Iterator,
                         com.atlassian.jira.issue.fields.layout.column.ColumnLayoutItem,
                         com.atlassian.jira.issue.fields.NavigableField"%>,
        
        Add this code between lines (circa line 92)
        layoutBean = issueNavigator.getTableLayoutFactory().getStandardExcelLayout(issueNavigator.getSearchRequest(), issueNavigator.getRemoteUser());
        and 
        colCount = layoutBean.getColumns().size();
        
                // Code to remove a column from the exported list
                // Code to remove a column from the exported list
                for (Iterator iterator = layoutBean.getColumns().iterator(); iterator.hasNext();)
                {
                    ColumnLayoutItem columnLayoutItem = (ColumnLayoutItem) iterator.next();
                    if (columnLayoutItem.getNavigableField() != null)
                    {
                        NavigableField navigableField = columnLayoutItem.getNavigableField();
                        if ("customfield_10020".equals(navigableField.getId()))
                        {
                            iterator.remove();
                        }
        		if ("customfield_10180".equals(navigableField.getId()))
        		{
        		    iterator.remove();
                        }
                    }
        
                }
        
        (need to set customfield_nnnnn to eventual values of Tools and Action column custom IDs - mine are 10020 and 10180)
        

        I'll attach my .jsp file to this page if you like.

        1. Oct 03, 2006

          Neal Applebaum says:

          The code originally came from http://jira.atlassian.com/browse/JRA-7871&nbsp...

          The code originally came from http://jira.atlassian.com/browse/JRA-7871&nbsp;and is also linked on the Toolkit page.

  5. Oct 04, 2006

    Eyal Kaduri says:

    Fantastic fast Response Thank you both Eyal Kaduri

    Fantastic fast Response

    Thank you both

    Eyal Kaduri

  6. Nov 16, 2006

    Kevin Kuenstler says:

    Hi,  I installed this plug-in, but do not see the option to add this colum...

    Hi,

     I installed this plug-in, but do not see the option to add this column when configuring my issue navigator. Can anyone enlighten me? Am I missing something?

     Kevin

    1. Nov 16, 2006

      Neal Applebaum says:

      Yes - what you're missing is you first have to create a custom field (mine is ca...

      Yes - what you're missing is you first have to create a custom field (mine is called "Action") of type "Workflow Action Field". Then you can add it to the issue navigator.

    2. Nov 16, 2006

      Philip Herbst says:

      Hi, I'm pretty sure Neal is on the right track here. I surely have to update th...

      Hi,

      I'm pretty sure Neal is on the right track here. I surely have to update the documentation and provide proper installation instructions.

      Phil

  7. Apr 21, 2008

    asukataozi says:

    Hi,Philip  Are you on line?I find that this plugin is very helpful for me,...

    Hi,Philip

     Are you on line?I find that this plugin is very helpful for me,but my JIRA is 3.11,it seemed not support my JIRA version? Can you help me?

    1. Jun 26

      zcraven says:

      I'm using this on Jira 3.11 - keep trying, it works!

      I'm using this on Jira 3.11 - keep trying, it works!