•  
     
    story #12187 configure workflow pre & post actions at target state level
Summary
tracker admin
configure workflow pre & post actions at target state level

I get a easier interface to configure the worklow and I reduce risks of errors
 

Overview

The goal of this story is to propose, by default, the configuration of workflow pre-conditions and post-actions at target state globally instead of having to define it for each transition.

For instance I would configure what happens when artifact status becomes "On going", regardless of previous state, rather than having to define what happens when artifact goes from "new" to "On going" + "todo" to "On going" + "review" to "On going", etc.

As pre-conditions and post actions tends to be the same for a given state it reduces the risk of having one specific transition that, un-expectedly behaves diffrently.

The "per transition" configuration would remain possible (at minimum for backward compatibility) but not shown by default.

See live mockup: https://s.codepen.io/enalean/debug/dace752a350bcecdad1003e505bc9992

Functional overview

Tracker administrator point of view

The worflow configuration matrix overall design is improved to be easier to read

By default, a click on a transition cell only allow/disallow the transition it self (eg. I allow change from "To do" to "On going") but I don't have a "[details]" link.

The transition configuration screen is accessible by a click on the target state "On going".

A tracker administrator can activate "Advanced mode" where each transition can be configured independently. It's the default mode for all existing trackers. When tracker admin switch from "Simple mode" to "Advanced mode", all configurations are done at transition level (no longer at state level) and switch will copy all configurations (pre-conditions, post-actions that were defined at state level into each defined transition).

On workflow in "Advanced mode", a tracker administrator can activate "Simple mode" (to only have 1 configuration). In this case the first configuration in the target column is selected and applied the whole state. As this operation can break something, a warning message is displayed to ensure tracker admin is sure he wants to continue.

End user point of view

Nothing change. On artifact creation and update, the pre-conditions and post-actions are applied as soon as the target state is reached (given the transition exists in the workflow).

Technical Overview

REST routes

  • Get workflow field
  • Get configuration mode (advanced or simple)
  • Get transition rule activation
  • Get all transitions of a tracker

GET /trackers/:id with response content:

{
    "workflow": {
        "field_id": 0,
        "is_used": false,
        "transitions": [],
...
    },
}

Info: this route already exists

  • Set new workflow field:

PATCH /trackers/:id with request content:

{ workflow: {
  set_transitions_rules: {
    field_id: 123
  }
}}

Warning: "400 Bad Request" if a field is already defined.
Info: transition rule is disabled by default.

  • Remove current workflow field:

PATCH /trackers/:id with request content:

{ workflow: {
  delete_transitions_rules: true
}}

Info: this will remove all associated transitions and rules.

  • Enable / disable transition rules:

PATCH /trackers/:id with request content:

{ workflow: {
  set_transitions_rules: {
    is_used: true
  }
}}
  • Switch between simple and advanced mode:

PATCH /trackers/:id with request content:

{ workflow: {
  set_transitions_rules: {
    is_advanced: true
  }
}}

Info: when switching from advanced mode to simple mode, transitions rules are updated to have same rules by target state.

  • Add new transition

POST /tracker_workflow_transitions with request content:

{
    "tracker_id": int,
    "from": int,
    "to": int
}

with response content:

{
    "id": int,
    "uri": string
}

Info: when simple mode, rules of target state is added to this transition

  • Remove a transition

DELETE /tracker_workflow_transitions/:id

  • [advanced mode] Get conditions of a transition

GET /tracker_workflow_transitions/:id with response content:

{
    "id": int,
    "uri": string,
    "comment_not_empty": bool,
    "fields_not_empty": [ field_id ],
    "allowed_ugroups": [ ugroup_id ]
}

Note: tracker_id, from and to are note present here

  • [advanced mode] Get all actions of a transition

GET /tracker_workflow_transitions/id/actions with response content:

[
    {
        "id",
        "type",
        "settings": {}
    },
    ...
]
  • Update rules of a transition

PUT /tracker_workflow_transitions/id/actions with request content:

[ 
    { 
        "type", 
        "settings": {}
    },
    ...
]

with response content:

{
    "id": int,
    "uri": string
}

Info: in simple mode, this will update all other transitions with same target state.

  • [simple mode] Get conditions of all transitions to a state

Use "[advanced mode] Get conditions of a transition" with first transition of the state

  • [simple mode] Get all actions of all transitions to a state

Use "[advanced mode] Get all actions of a transition" with first transition of the state

  • Additional routes to create
OPTIONS /tracker_workflow_transitions
OPTIONS /tracker_workflow_transitions/:id

Frontend

Matrix + modale are made with vue/vuex

Warning: transition from "New artifact" -> XXX some pre-conditions cannot apply (comment not empty). Be carful to handle that properly

On "Simple" mode

The new "simple" mode is actually wrapped around the existing structure and data model where each transition owns pre-conditions and transations. This way there is no modification of workflow checking on the platform, the database layout is not changed, etc. This saves a lot of pain.

However, the backend must ensure the consistency, hence modification of one transition will be propagated to sibling transactions transparently.

When a pre-condition or post-action is applied on 1 transition, the backend force apply on all transitions by truncating existing values and re-creating.

Example, given the following configuration

|from/to    |        "on going"          |
|-----------|--------------------------- |
|"new"      |  [                         |
|           |   {1, int, {0}},           |
|           |   {2, jenkins, {"url1"}},  |
|           |   {3, jenkins, {"url2"}}   |
|           |  ]                         |
|--------------------------------------- |
|"on going" |           X                |
|--------------------------------------- |
|"done"     | [                          |
|           |   {10, int, {0}},          |
|           |   {11, jenkins, {"url1"}}, |
|           |   {12, jenkins, {"url2"}}  |
|           | ]                          |
|--------------------------------------- |

When there is a PATCH/PUT on /tracker_workflow_transitions/id/actions to set {2, jenkins, {"url10"}}

This applies to both "new" -> "on going" and "done" -> "on going" transitions and the second one is truncated, hence ids change:

|from/to    |        "on going"          |
|-----------|--------------------------- |
|"new"      |  [                         |
|           |   {1, int, {0}},           |
|           |   {2, jenkins, {"url10"}}, |
|           |   {3, jenkins, {"url2"}}   |
|           |  ]                         |
|--------------------------------------- |
|"on going" |           X                |
|--------------------------------------- |
|"done"     | [                          |
|           |   {15, int, {0}},          |
|           |   {16, jenkins, {"url10"}},|
|           |   {17, jenkins, {"url2"}}  |
|           | ]                          |
|--------------------------------------- |

Adding a new field value in Simple mode

When a new field value is added, there is no impact on the transitions themselves. Let say your workflow looks like the following matrix with pre-conditions and post-actions set on Done (materialized with the []).

     | Todo | [Done] |
-----|------|--------|
Todo |      |   x    |
-----|------|--------|
Done |      |        |
-----|------|--------|

When "Archived" state is added, the matrix looks like this

     | Todo | [Done] | Archived |
-----|------|--------|----------|
Todo |      |   x    |          |
-----|------|--------|----------|
Done |      |        |          |
-----|------|--------|----------|
Arch |      |        |          |
-----|------|--------|----------|

No transition is modified by the addition of this value. However if the transition Arch -> Done is added, the configuration made on [Done] must be applied on Arch -> Done transition.

     | Todo | [Done] | Archived |
-----|------|--------|----------|
Todo |      |   x    |          |
-----|------|--------|----------|
Done |      |        |          |
-----|------|--------|----------|
Arch |      |   x    |          |
-----|------|--------|----------|

Development

The new interface is developed in a new route alongside the existing one. The switch will be done when the new interface will be complete.

In order to not block people with unforeseen use cases and/or work around issues, the switch to the new interface will be progressive. First, there will be a feature flag configuration value to allow users access to the new interface for specific trackers. The old interface will be accessible again after unsetting the configuration value.
Once project admins have added new post actions to their workflow, they will not be able to see, edit or delete them in the old interface. If they want to go back to the old interface, they will first need to clear (delete) their workflow or remove the new post actions with the new interface.

Story split

  1. Introduce new page (the existing page is left untouched and is still used by default, one should know the new page URL to get access)
    1. New end-point for WF admin
    2. The breadcrumbs
    3. The 2 tab list (2 levels of menu for workflow admin)
    4. Ability to choose the field on which WF applies (REST PATCH)
    5. Ability to enable/disable the WF (REST PATCH)

        For 4 & 5 see the live mockup here https://s.codepen.io/enalean/debug/5c3599ce2bd94287bb30112569c2d85b#

  1. Read only matrix
    1. Display the matrix with CSS helps on big tables
    2. Display the transitions
  2. Transitions
    1. click to activate & desactivate transition
    2. REST route to save that
  3. Modale
    1. Introduce modale to edit transitions. Only pre-conditions can be set
  4. Modale full
    1. Modale can be used to configura post-actions
    2. Introduce a configuration value "feature flag" to allow specific trackers to switch to the new UI. Once set, the "Transitions" button links to the new UI.
  5. Finalise with "Simple" mode
    1. Introduce UI to switch from Simple to Advanced mode
    2. Update REST routes to take into account propagation is "Advanced" mode
    3. Deprecate old UI
Benjamin Dauton (bdauton_enalean)
Status
Empty
Done
Development
  • [ ] Does it involves User Interface? 
  • [ ] Are there any mockups?
  • [ ] Are permissions checked?
  • [ ] Does it need Javascript development?
  • [ ] Does it need a forge upgrade bucket?
  • [ ] Does it need to execute things in system events?
  • [ ] Does it impact project creation (templates)?
  • [ ] Is it exploratory?
Empty
Details
#12187
Manuel Vacelet (vaceletm)
2019-02-27 16:30
2018-08-27 16:10
4075

References
Referencing story #12187

Git commit

tuleap/tuleap/stable

Have workflow endpoint 6337932c83
Dynamic path for workflow in URL verification instance f57ddac01b
Do not preg_match every request 5983e77508
Have the base layout df94454bd9
Have a minimal vue empty state 02722358cb
Fetch tracker on page loading fb2b35d16f
Store tracker and show first configuration b2a1971f6e
Display the action buttons section a9086d9ffe
Fix TrackersResource styling 8072ef57d0
Fix tracker store actions styling f8e0bc2881
Introduce PATCH tracker/:id to set up the field transitions are based on 00234d3334
Action button first configuration c2e8079884
Migrate QueryParameterParserTest to PHPUnit a4e5a8acd4
Extract I18NRestException from TrackersResource 0e4e638102
Add missing tests on QueryParameterParser acd0c49567
Fix PhpDoc in TrackerResources->patchWorkflow() 1fcdf57311
Fix Workflow_Dao styling 013f36ecfa
Display the matrix 6ec818bc91
Fix WorkflowFactory styling a77073fada
Fix styling in _switch.scss 9dc7298edb
Have a change field modal ecc51877b3
Fix workflow transition deletion when workflow does not exist 2d92b70187
js error when the selected field has no value inside ac6ce03976
Return transition id on GET trackers/{id} 080a905b26
Enable/Disable transition rules (Backend) 29790651eb
Move all PATCH tracker permission checks in TrackerPermissionsChecker af2feea0ae
Alertbox confirmation on deleting workflow 6dc864cf89
Fix scss styling b8ea5ca8e4
Enable/Disable transition rules (Frontend) 871c427fef
Refactor TransitionsMatrixSection 5cfd25ee2c
Enable transition backend *advanced configuration* f6f5caa8e3
Enable transition frontend *advanced configuration* 1af15c5aa5
Fix Workflow_TransitionDao styling 3f79fc8da1
Fix SCSS partial names 3f3b0d921e
Refactor POST tracker_workflow_transitions 80f636c938
Disable transition backend *advanced configuration* 6c5439ebe1
Refactor actions 68af89f622
Disable transition frontend *advanced configuration* 59cc4be395
Fix matrix disabling opacity de93791ba1
Add missing tests and fix some edge cases 58532fa17c
Empty Workflow configuration modal 7252a66949
Factorize localVue creation e139c47b1e
GET /tracker_workflow_transitions/{ id } ead05f49ec
Empty state for the right part of the modal 603e7008db
Use factories to create data model in front tests 43d3f2078d
Display the transition pre conditions 56db474aeb
Fix conventions f402051d76
Fix PHPDoc in Transition_PostAction_Field classes fdbb55a911
Run new front spec automatically cfbe029c75
Fix front factories engine 3078548c4b
Refactor Transition->getWorkflow() 3c10192c68
Ease Vuex store creation for specs 355d77aacd
Fix exception handler file name a22db74522
Save the transition conditions in modal 1d3efadd08
Prevent "Save configuration" width to change a31d77b8a5
Add "All users", "Registered users" and "Authenticated users" to the ugroups list 8ff423e7d9
Improve factory engine with the ability to add attributes with traits 0119e14328
create GET /tracker_workflow_transitions/:id/actions 2a12cd42dd
Fix BaseTrackerWorkflowTransitions component name ab94574d9d
Fix UGroupManagerTest according coding conventions b77a7e7e52
Use natural sort for fields selectboxes c391e74a03
Show rules enforcement warning only if workflow field is configured 78539786a0
Fix for / id usage in forms 93e908198c
Return the internal identifier in GET post actions 659507fbe5
Reduce technical debt on ProjectResource->getUserGroups() 47519ffa0b
Show a warning when no workflow field can be selected 5734b2c8f0
Display "launch a CI job" cb96ee9923
Feature flag to show the new workflow transitions administration 09371ebba9
Create PostActionUpdate service for CIBuild action 64691b57fc
Improve PostActionCollection 13ff3180b0
Fix CIBuildRepository->findAllIdsByTransition() 954d3f5597
Fix Transition_PostAction_CIBuildDao->deletePostActionByTransitionIfIdNotIn() ec0cf9109c
PUT /tracker_workflow_transitions/id/actions 582ee7d846
Edit "Launch a CI job" action 6ee02859d6
Make PostActionUpdate transactional f1a4a5b0cf
Refactor PostActionsUpdater 6db07bad1e
Ease implementaion of new post action types updates 84c63a1c26
Rename private methods to match actual returned types 8b06a96841
Fix post action addition 2b5db61c92
Remove dead code fad7b8844f
Validate more strictly Post Action data 0b6ce8d039
Remove unused property b31a827d66
Update GET .../actions with more readable date value format 5eb0e0b9f8
Update PUT .../actions to handle "set date field" post actions 021c7d0e0c
Display "Change value of a field" action in web UI 1ac0a5d282
Fix "set date value" Json parser test 285b7f97a5
Remove front test filtering ac4f39ee3c
Update PUT .../actions to handle "set int field" and "set float field" post actions 497e54e419
Create a new action in UI 54ec14f307
Hide error feedback in modal when closing the modal a771299821
Delete action using the trash bin in the UI 8fbc13213f
Refactor PostActionSection Vue component 283062aa39
Edit field and value of "set field value" actions 1ff73d3711
Set default value for transition ugroups 94f585599a
Switch action type f902935882
Validate Date Fields Post actions bcdecdda16
Disable REST route and direct URL with feature flag 89e6816cb3
Fix namespaces 318fc2fca0
Fix argument name d6289ef4ad
Extract Duplicate Field ids validator 58b2a904f1
Send only minimal Json to backend 3b374d9db7
Display "Choose a field" and "Value" in same line e56312160f
Replace generic VueX mutation by multiple specific mutations 68baed062b
Validate Set int value post actions 82efe99907
Manipulate object in repositories a2b148cf53
Validate Set float value post actions 10dea62a12
Refactoring: Fix tests and group post action components together 5c1dbb4a91
Rename workflow folder into Workflow 480ed243ea
UI should prevent people from choosing the same field twice in post actions 1d7a50fed3
New TLP skeleton implementation c46eb1230a
Refactoring: use named export syntax for all Vuex modules 99b47b559c
Change spinnners 732a960d9f
Feedback on transition update 43d301e3b2
Authorized user groups selectbox no longer shows value 02671a6f59
Add "from state" and "to state" in the modal title 9fec904847
At least one user group must be choosen in pre condition 5421e959de
Polish workflow modal fdba193d53
Do not query multiple time the status field id in REST tests 2636bd3be6
Do not query multiple time the transitions in REST tests 5ee0cd15dc
Enhance REST tests for post actions 45367f8afe
Use TransactionExecutor in TransitionUpdater 2f6a8a09f6
REST API should silenty ignore "comment not empty" pre-condition on "New" transitions 7c82987645
Introduce simple mode in database f7f3dcce79
Show workflow simple mode 7ad05bc3cb
Replicate pre-conditions in simple mode 610c99bf64
Refactoring: extract dedicated object to handle POST b01427a96d
Refactoring: extract PUT post-actions in a dedicated object 2d5ab09b40
Post actions are propagated to all sibling transitions 4a59cb785a
Rename TransitionUpdater to ConditionsUpdater 6f032768ba
POST tracker_workflow_transitions/:id must replicate pre-conditions d7795315ad
Match Post Action namespace with their directory e228f9abb6
POST tracker_workflow_transitions/:id must replicate post-actions 823d0fbc44
I can edit post actions with Firefox 60dc4d77cc
The new worklow UI is the default one 4b546438ea
Handle simple mode in UI fc2bc25648
PATCH trackers/:id to switch to advanced mode 679881440a
Do not block REST routes if a workflow is switched back to old UI 7664f1594f
Introducing the ModeUpdater object 2c0600f649
Remove nested SQL transactions 1fd808c319
REST Tests for Simple mode Workflow d478052464
Switch workflow to advanced mode on the UI 5d3dde26ce
PATCH trackers/:id to switch to simple mode c414f9f800
Add REST tests for the switch to advanced b34760d8f6
Add REST tests for the switch to simple 3df95e8221
Switch workflow to simple mode on the UI 9f1baad0df
Cleanup comment not empty from "New artifact" b14f6145fa
Change Field modal should show a spinner before closing 22a1bf0045
Simple mode is the new default bf79dd22ad
Little tweaks after design check 5fac82dccd
Confirm deletion of transitions with a popover in Advanced mode ff3c498e2a
Enhance modal message when switching from simple to advanced a21e965a18
Confirm transition deletion for simple mode 0b4c856497
Change popover message for simple mode 8b44565000
Referenced by story #12187

Other

gerrit #13099
gerrit #13106
gerrit #13109
gerrit #13102
gerrit #13108
gerrit #13113
gerrit #13139
gerrit #13118
gerrit #13155
gerrit #13151
gerrit #13124
gerrit #13163
gerrit #13200
gerrit #13199
gerrit #13209
gerrit #13219
gerrit #13221
gerrit #13162
gerrit #13222
gerrit #13225
gerrit #13150
gerrit #13258
gerrit #13266
gerrit #13275
gerrit #13153
gerrit #13273
gerrit #13263
gerrit #13295
gerrit #13282
gerrit #13336
gerrit #13231
gerrit #13296
gerrit #13427
gerrit #13433
gerrit #13428
gerrit #13261
gerrit #13448
gerrit #13463
gerrit #13464
gerrit #13470
gerrit #13442
gerrit #13496
gerrit #13482
gerrit #13499
gerrit #13522
gerrit #13557
gerrit #13565
gerrit #13584
gerrit #13573
gerrit #13571
gerrit #13574
gerrit #13583
gerrit #13587
gerrit #13550
gerrit #13610
gerrit #13604
gerrit #13620
gerrit #13588
gerrit #13624
gerrit #13625
gerrit #13619
gerrit #13621
gerrit #13645
gerrit #13647
gerrit #13649
gerrit #13607
gerrit #13640
gerrit #13702
gerrit #13727
gerrit #13737
gerrit #13742
gerrit #13745
gerrit #13743
gerrit #13756
gerrit #13772
gerrit #13773
gerrit #13779
gerrit #13776
gerrit #13780
gerrit #13768
gerrit #13791
gerrit #13790
gerrit #13775
gerrit #13785
gerrit #13808
gerrit #13810
gerrit #13802
gerrit #13811
gerrit #13822
gerrit #13814
gerrit #13839
gerrit #13829
gerrit #13848
gerrit #13853
gerrit #13858
gerrit #13865
gerrit #13868
gerrit #13878
gerrit #13863
gerrit #13877
gerrit #13850
gerrit #13867
gerrit #13874
gerrit #13869
gerrit #13927
gerrit #13930
gerrit #13929
gerrit #13935
gerrit #13934
gerrit #13943
gerrit #13936
gerrit #13944
gerrit #13948
gerrit #13954
gerrit #13956
gerrit #13961
gerrit #13958
gerrit #13962
gerrit #13966
gerrit #13974
gerrit #13983
gerrit #13991
gerrit #13993
gerrit #14000
gerrit #14010
gerrit #14021
gerrit #14031
gerrit #14039
gerrit #14040
gerrit #14056
gerrit #14057
gerrit #14070
gerrit #14078
gerrit #14075
gerrit #14093
gerrit #14090
gerrit #14100
gerrit #14094
gerrit #14087
gerrit #14109
gerrit #14107
gerrit #14110
gerrit #14114
gerrit #14115
gerrit #14121
gerrit #14120
gerrit #14126
gerrit #14130
gerrit #14162
gerrit #14136
gerrit #14187
gerrit #14196

Follow-ups

User avatar
Joris MASSON (jmasson)2019-01-07 10:49
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
Joris MASSON (jmasson)2018-12-21 11:47
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
gerrit #13336 integrated into Tuleap 10.8.99.37

  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
Thi Mai (thimai)2018-12-04 10:03
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar

Added live mock-up


  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • So that
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
  • CC list set to Benjamin Dauton (bdauton_enalean)