Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Workflow] Explain how to style a workflow dump #11907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
242 changes: 242 additions & 0 deletions workflow/dumping-workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,247 @@ files and ``PlantUmlDumper`` to create the PlantUML files::
$ php dump-graph.php | dot -Tsvg -o graph.svg
$ php dump-graph.php | java -jar plantuml.jar -p > graph.png

Styling
-------

You can use `metadata` with the following keys to style the workflow:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pleas double backticks around metadata

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done while merging. Thanks.


* for places:
* `bg_color`: a color
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the others

* `description`: a string that describe the state
* for transitions:
* `label`: a string that replace the name of the transition
* `color`: a color
* `arrow_color`: a color

Colors can be:

* a color name from `PlantUML's color list`_
* HEX value `#AABBCC`
* short HEX value `#ABC`

You can use `\n` to insert a line return.

Below is the configuration for the pull request state machine with styling added.

.. configuration-block::

.. code-block:: yaml

# config/packages/workflow.yaml
framework:
workflows:
pull_request:
type: 'state_machine'
supports:
- App\Entity\PullRequest
initial_place: start
places:
start: ~
coding: ~
test: ~
review:
metadata:
description: Human review
merged: ~
closed:
metadata:
bg_color: DeepSkyBlue
transitions:
submit:
from: start
to: test
update:
from: [coding, test, review]
to: test
metadata:
arrow_color: Turquoise
wait_for_review:
from: test
to: review
metadata:
color: Orange
request_change:
from: review
to: coding
accept:
from: review
to: merged
metadata:
label: Accept PR
reject:
from: review
to: closed
reopen:
from: closed
to: review

.. code-block:: xml

<!-- config/packages/workflow.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
>

<framework:config>
<framework:workflow name="pull_request" type="state_machine">
<framework:marking-store type="single_state"/>

<framework:support>App\Entity\PullRequest</framework:support>

<framework:place>start</framework:place>
<framework:place>coding</framework:place>
<framework:place>test</framework:place>
<framework:place name="review">
<framework:metadata>
<framework:description>Human review</framework:description>
</framework:metadata>
</framework:place>
<framework:place>merged</framework:place>
<framework:place name="closed">
<framework:metadata>
<framework:bg_color>DeepSkyBlue</framework:bg_color>
</framework:metadata>
</framework:place>
</framework:place>

<framework:transition name="submit">
<framework:from>start</framework:from>

<framework:to>test</framework:to>
</framework:transition>

<framework:transition name="update">
<framework:from>coding</framework:from>
<framework:from>test</framework:from>
<framework:from>review</framework:from>

<framework:to>test</framework:to>

<framework:metadata>
<framework:arrow_color>Turquoise</framework:arrow_color>
</framework:metadata>
</framework:transition>

<framework:transition name="wait_for_review">
<framework:from>test</framework:from>

<framework:to>review</framework:to>

<framework:metadata>
<framework:color>Orange</framework:color>
</framework:metadata>
</framework:transition>

<framework:transition name="request_change">
<framework:from>review</framework:from>

<framework:to>coding</framework:to>
</framework:transition>

<framework:transition name="accept">
<framework:from>review</framework:from>

<framework:to>merged</framework:to>

<framework:metadata>
<framework:label>Accept PR</framework:label>
</framework:metadata>
</framework:transition>

<framework:transition name="reject">
<framework:from>review</framework:from>

<framework:to>closed</framework:to>
</framework:transition>

<framework:transition name="reopen">
<framework:from>closed</framework:from>

<framework:to>review</framework:to>
</framework:transition>

</framework:workflow>

</framework:config>
</container>

.. code-block:: php

// config/packages/workflow.php
$container->loadFromExtension('framework', [
// ...
'workflows' => [
'pull_request' => [
'type' => 'state_machine',
'supports' => ['App\Entity\PullRequest'],
'places' => [
'start',
'coding',
'test',
'review' => [
'metadata' => [
'description' => 'Human review',
],
],
'merged',
'closed' => [
'metadata' => [
'bg_color' => 'DeepSkyBlue',
],
],
],
'transitions' => [
'submit'=> [
'from' => 'start',
'to' => 'test',
],
'update'=> [
'from' => ['coding', 'test', 'review'],
'to' => 'test',
'metadata' => [
'arrow_color' => 'Turquoise',
],
],
'wait_for_review'=> [
'from' => 'test',
'to' => 'review',
'metadata' => [
'color' => 'Orange',
],
],
'request_change'=> [
'from' => 'review',
'to' => 'coding',
],
'accept'=> [
'from' => 'review',
'to' => 'merged',
'metadata' => [
'label' => 'Accept PR',
],
],
'reject'=> [
'from' => 'review',
'to' => 'closed',
],
'reopen'=> [
'from' => 'start',
'to' => 'review',
],
],
],
],
]);

The PlantUML image will look like this:

.. image:: /_images/components/workflow/pull_request_puml_styled.png

.. _`Graphviz`: http://www.graphviz.org
.. _`PlantUML`: http://plantuml.com/
.. _`PlantUML's color list`: http://plantuml.com/en/color