Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#11855 closed enhancement (fixed)

Workflow macro could use name/label attribute in place of action names

Reported by: Ryan J Ollos Owned by:
Priority: normal Milestone: 1.0.3
Component: ticket system Version:
Severity: normal Keywords: workflow
Cc: Branch:
Release Notes:

Use name or label attribute from [ticket-workflow] when rendering actions in the workflow graph output by the Workflow macro.

API Changes:

Description

It could be nice to use the action name/label (#11828) attribute in place of the action name when rendering the workflow graph. The tags/trac-1.0.2/contrib/workflow/opensource-workflow.ini demonstrates that the action names are often not visually appealing and don't represent what the user sees:

The following patch should work well on the trunk after #11828:

  • trac/ticket/default_workflow.py

    diff --git a/trac/ticket/default_workflow.py b/trac/ticket/default_workflow.py
    index 2310f2f..e6d3ee7 100644
    a b class WorkflowMacro(WikiMacroBase):  
    533533            [state for action in actions.itervalues()
    534534                   for state in action['oldstates']] +
    535535            [action['newstate'] for action in actions.itervalues()]))
     536        action_labels = [attrs['label']
     537                         for name, attrs in actions.items()]
    536538        action_names = actions.keys()
    537539        edges = []
    538540        for name, action in actions.items():
    class WorkflowMacro(WikiMacroBase):  
    545547        args = args or {}
    546548        width = args.get('width', 800)
    547549        height = args.get('height', 600)
    548         graph = {'nodes': states, 'actions': action_names, 'edges': edges,
     550        graph = {'nodes': states, 'actions': action_labels, 'edges': edges,
    549551                 'width': width, 'height': height}
    550552        graph_id = '%012x' % id(graph)
    551553        req = formatter.req

On 1.0-stable the patch differs slightly:

  • trac/ticket/default_workflow.py

    diff --git a/trac/ticket/default_workflow.py b/trac/ticket/default_workflow.py
    index 8cb0643..e705ab4 100644
    a b class WorkflowMacro(WikiMacroBase):  
    496496            [state for action in actions.itervalues()
    497497                   for state in action['oldstates']] +
    498498            [action['newstate'] for action in actions.itervalues()]))
     499        action_labels = [attrs.get('name', name)
     500                         for name, attrs in actions.items()]
    499501        action_names = actions.keys()
    500502        edges = []
    501503        for name, action in actions.items():
    class WorkflowMacro(WikiMacroBase):  
    508510        args = args or {}
    509511        width = args.get('width', 800)
    510512        height = args.get('height', 600)
    511         graph = {'nodes': states, 'actions': action_names, 'edges': edges,
     513        graph = {'nodes': states, 'actions': action_labels, 'edges': edges,
    512514                 'width': width, 'height': height}
    513515        graph_id = '%012x' % id(graph)
    514516        req = formatter.req

Attachments (0)

Change History (5)

comment:1 by Ryan J Ollos, 5 years ago

Milestone: next-stable-1.0.x1.0.3
Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

Committed to 1.0-stable in [13507]. Merged to trunk in [13508:13509].

Last edited 5 years ago by Ryan J Ollos (previous) (diff)

comment:2 by Jun Omae, 5 years ago

I have a question about the changes. Do actions.keys(), actions.values() and actions.items() always iterate its entries in the same order?

comment:3 by Ryan J Ollos, 5 years ago

I would be surprised if all three methods do not always iterate in the order that the dictionary items are stored in memory, but I do not have a reference to prove that is the case.

Even prior to the changes the code has assumed that keys and items are iterating the entries in the same order: tags/trac-1.0.2/trac/ticket/default_workflow.py@:481,483,485#L465.

comment:4 by Peter Suter, 5 years ago

From Python docs:

If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond.

Is this not sufficient?

in reply to:  4 comment:5 by Jun Omae, 5 years ago

From Python docs:

If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond.

Is this not sufficient?

Thanks for the information. I understand the changes have no issues. Sorry for the noise.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.