easy_flow 0.49.1 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/builds/easy_flow/canvas.js +1 -3
- data/app/controllers/easy_flow/manage/canvas_controller.rb +11 -2
- data/app/javascript/easy_flow/canvas/Canvas.jsx +2 -4
- data/app/javascript/easy_flow/canvas/Inspector.jsx +2 -1
- data/app/javascript/easy_flow/canvas/Joint.jsx +8 -6
- data/app/javascript/easy_flow/canvas/LeftToRight.jsx +105 -33
- data/app/javascript/easy_flow/canvas/RunView.jsx +1 -1
- data/app/javascript/easy_flow/canvas/StepCard.jsx +1 -4
- data/app/javascript/easy_flow/canvas/StepRows.jsx +56 -0
- data/app/javascript/easy_flow/canvas/graph.js +223 -0
- data/app/models/easy_flow/all_or_any.rb +2 -0
- data/app/models/easy_flow/canvas.rb +15 -3
- data/app/models/easy_flow/compare.rb +9 -0
- data/app/models/easy_flow/compare_two_values.rb +13 -0
- data/app/models/easy_flow/condition.rb +1 -0
- data/app/models/easy_flow/count.rb +8 -0
- data/app/models/easy_flow/data_step.rb +1 -0
- data/app/models/easy_flow/flow_step.rb +6 -0
- data/app/models/easy_flow/play_flows.rb +1 -0
- data/app/models/easy_flow/settings.rb +46 -6
- data/app/models/easy_flow/steps/checklist.rb +1 -0
- data/app/models/easy_flow/steps/file_upload.rb +1 -0
- data/app/models/easy_flow/steps/fill_in_the_blank.rb +1 -0
- data/app/models/easy_flow/steps/multiple_select.rb +1 -0
- data/app/models/easy_flow/steps/question.rb +5 -0
- data/app/models/easy_flow/switch.rb +2 -0
- data/app/models/easy_flow/wait.rb +8 -0
- data/lib/easy_flow/host.rb +12 -0
- data/lib/easy_flow/version.rb +1 -1
- data/the_local/agents/easy_flow-develop.md +3 -3
- data/the_local/agents/easy_flow-info.md +6 -4
- data/the_local/agents/easy_flow-install.md +3 -2
- metadata +3 -2
- data/app/javascript/easy_flow/canvas/reading.js +0 -52
|
@@ -83,7 +83,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
83
83
|
4. Ask the developer which hosts' admins should be able to add the type. A registered type is in a host's palette, the step types an admin can add on that host's canvas, only when the host names no list of offered step types or its list includes the type's id. A type that declares `ends_here` is in every host's palette, and a type that declares `begins_here` is in none. When a host that names a list should offer the new type, add the type's id to that host's list through `easy_flow-install`. Leaving a type off a host's list only keeps admins from adding it there, and a step of that type already in one of the host's flows is still drawn and run, and still opens with all its settings and can be saved.
|
|
84
84
|
5. Use these words to declare the type. Each is called once at class level (or inside the `EasyFlow.step` block):
|
|
85
85
|
- `step_name "<label>"` — the name admins see on the canvas. Defaults to the id.
|
|
86
|
-
- `setting :name, type:, label:, explanation:, options:, required:, optional:, limit:, check:, from:, outputs_of:, kept_on:, attribute:` — a field the admin fills in on the canvas. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, `:select`, `:multi_select`, `:radio_cards`, `:previous_step`, `:from_step`, `:list`, `:flow`, or boot raises `EasyFlow::UnknownFieldType`. A `:select`, `:multi_select` or `:radio_cards` must pass `options:`, or boot raises the same error. A `:radio_cards` setting is drawn in the step's settings as one keystone radio card per option, side by side with each card taking an equal share of the row, and one card per row when the panel is too narrow; its `options:` are hashes `{ value:, label:, hint: }`, as a fixed array or a lambda that works them out from the app's records (`options: -> { Release.aliases.map { |release| { value: release.alias, label: "#{release.alias} → #{release.version}", hint: release.stats_line } } }`), the chosen card's `value` is stored in `node.config`, and a saved value that is not one of the options' values is refused. `options:` is either an array of strings, or a lambda taking no arguments that returns one; the lambda is called each time the canvas is opened and each time an admin saves the step's settings, so the options follow the app's data without a restart (`options: -> { Region.order(:name).pluck(:code) }`). A saved setting whose value is no longer among the options is refused the next time the admin saves that step. When the options come from the app's records, ask the developer which records, which column is stored as the value, and whether the list must differ by account or host, since the lambda is passed nothing and the same list is offered everywhere the type is used. A `:list` must take a block of `setting` calls describing one entry. `:previous_step` lets the admin pick an earlier step, and is required unless declared with `optional: true`. Ask the developer whether a step of the type may be left without that earlier step, and when it may, declare `optional: true` and handle a blank value in the type's code. `outputs_of: :<setting>` offers the outputs of the step chosen in that setting, and `from: :<setting>` offers the values of the output chosen in that setting; either one makes the type `:from_step`. A required setting left blank shows a warning on the step's card that the step `needs a value for <label>`, and saving the flow as a new version and publishing it are refused until the admin fills it in. An `outputs_of:` setting left blank is flagged and refused the same way once the setting it reads names a step, whether or not it is declared `required:`. Inside a `:list` entry, a blank required setting, or a blank `outputs_of:` setting whose step is picked, shows `needs a value for <label> in <list label> entry <n>` for the entry at position `n` counting from 1. `optional:` has no effect inside a `:list` entry, where a `:previous_step` is required only when declared `required: true`. `:flow` lets the admin pick one of the flows the admin's list shows on the same host, offered by title, and is stored in `node.config` as that flow's id as a string. A `:flow` setting is not checked on save against the flows offered, so code that reads it looks the flow up through the host and handles a blank or unknown id. `limit:` is the most values a `:multi_select` takes. `check:` is a lambda given the value that returns an error message, or `nil` when the value is acceptable. `label:` defaults to the name humanized. `explanation:` is an optional sentence shown under the setting in the step's settings, inside a `:list` entry as well, and a setting with none shows nothing there. A host can replace it with its own through `setting_explanations`, set through `easy_flow-install`. `kept_on:` and `attribute:` keep the setting's value on one of the app's own records instead of in the flow; see "Keep a setting on one of the app's records".
|
|
86
|
+
- `setting :name, type:, label:, explanation:, options:, required:, optional:, limit:, check:, from:, outputs_of:, kept_on:, attribute:` — a field the admin fills in on the canvas. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, `:select`, `:multi_select`, `:radio_cards`, `:previous_step`, `:from_step`, `:list`, `:flow`, or boot raises `EasyFlow::UnknownFieldType`. A `:select`, `:multi_select` or `:radio_cards` must pass `options:`, or boot raises the same error. A `:radio_cards` setting is drawn in the step's settings as one keystone radio card per option, side by side with each card taking an equal share of the row, and one card per row when the panel is too narrow; its `options:` are hashes `{ value:, label:, hint: }`, as a fixed array or a lambda that works them out from the app's records (`options: -> { Release.aliases.map { |release| { value: release.alias, label: "#{release.alias} → #{release.version}", hint: release.stats_line } } }`), the chosen card's `value` is stored in `node.config`, and a saved value that is not one of the options' values is refused. A `:radio_cards` lambda that takes one argument is given the step's settings as a hash and works out the cards from them, such as `options: ->(config) { Agent.find_by(name: config["agent"])&.aliases.to_a.map { |release| { value: release.alias, label: "#{release.alias} → #{release.version}", hint: release.stats_line } } }`, so an alias the chosen agent does not have gets no card. The canvas works the cards out again each time the admin saves the step, so they change as soon as the other setting is saved, without reloading the page. When a save leaves the chosen card no longer among them, the choice is cleared instead of refused, and the settings panel shows a notice such as "Cleared Alias because candidate is not offered for the step's other settings." When the lambda raises, the canvas still opens and the setting shows no cards, and the error is written to the app's log. When it raises while the admin saves the step, the error is written to the log and the save is refused, and the settings panel says the setting "could not be worked out, so the change was not saved." The palette offers no cards for such a setting, since it has no step's settings to work them out from. `options:` is either an array of strings, or a lambda taking no arguments that returns one; the lambda is called each time the canvas is opened and each time an admin saves the step's settings, so the options follow the app's data without a restart (`options: -> { Region.order(:name).pluck(:code) }`). A saved setting whose value is no longer among the options is refused the next time the admin saves that step. When the options come from the app's records, ask the developer which records, which column is stored as the value, and whether the list must differ by account or host, since the lambda is passed nothing and the same list is offered everywhere the type is used. A `:list` must take a block of `setting` calls describing one entry. `:previous_step` lets the admin pick an earlier step, and is required unless declared with `optional: true`. Ask the developer whether a step of the type may be left without that earlier step, and when it may, declare `optional: true` and handle a blank value in the type's code. `outputs_of: :<setting>` offers the outputs of the step chosen in that setting, and `from: :<setting>` offers the values of the output chosen in that setting; either one makes the type `:from_step`. A required setting left blank shows a warning on the step's card that the step `needs a value for <label>`, and saving the flow as a new version and publishing it are refused until the admin fills it in. An `outputs_of:` setting left blank is flagged and refused the same way once the setting it reads names a step, whether or not it is declared `required:`. Inside a `:list` entry, a blank required setting, or a blank `outputs_of:` setting whose step is picked, shows `needs a value for <label> in <list label> entry <n>` for the entry at position `n` counting from 1. `optional:` has no effect inside a `:list` entry, where a `:previous_step` is required only when declared `required: true`. `:flow` lets the admin pick one of the flows the admin's list shows on the same host, offered by title, and is stored in `node.config` as that flow's id as a string. A `:flow` setting is not checked on save against the flows offered, so code that reads it looks the flow up through the host and handles a blank or unknown id. `limit:` is the most values a `:multi_select` takes. `check:` is a lambda given the value that returns an error message, or `nil` when the value is acceptable. `label:` defaults to the name humanized. `explanation:` is an optional sentence shown under the setting in the step's settings, inside a `:list` entry as well, and a setting with none shows nothing there. A host can replace it with its own through `setting_explanations`, set through `easy_flow-install`. `kept_on:` and `attribute:` keep the setting's value on one of the app's own records instead of in the flow; see "Keep a setting on one of the app's records".
|
|
87
87
|
- `output :name, type:, label:, values:, from:` — a value the step records. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, or boot raises `EasyFlow::UnknownOutputType`. `values:` is an array or a lambda taking the node, listing the values the output can take; the canvas offers these as the connections leaving the step, so a type that routes must declare them. `from: :<setting>` takes the values from the step chosen in that setting. A Condition step requires the admin to pick one of the earlier step's outputs, so a type whose answer admins should test with a Condition declares at least one `output`, with `values:` so the Condition offers answers to pick.
|
|
88
88
|
- `outputs_named_by :<list setting>` — adds one output for each entry an admin enters in that `:list` setting, named by the entry's `name`, so the setting's entry block must declare `setting :name, type: :string`. Ask the developer whether the admin or the type decides the names of the values the step records. Do not pick.
|
|
89
89
|
- The named outputs follow any outputs the type declares with `output`, in the order the admin entered them. An entry with a blank `name` adds none.
|
|
@@ -105,7 +105,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
105
105
|
|
|
106
106
|
Here `CheckResult.for` is the app's own lookup.
|
|
107
107
|
- `names_by :setting` or `names_by { |node| ... }` — what the step is called on the canvas, from a setting or computed.
|
|
108
|
-
- `summarizes_by { |node| ... }` — the one line the step's card shows under its name on the canvas, worked out from the step's settings, such as `summarizes_by { |node| "role: #{node.config['role']} · #{node.config['hours']}h" }`. Return a short phrase, or `nil` or `""` to show no line. Without it the card shows no summary, and a step with problems shows its error count in the summary's place. The block is called every time the canvas is drawn, so it must not be slow and must not change anything, and like `names_by` its `node.config` holds no kept setting. Ask the developer what an admin should read about a step of this type without opening it.
|
|
108
|
+
- `summarizes_by { |node| ... }` — the one line the step's card shows under its name on the canvas, worked out from the step's settings, such as `summarizes_by { |node| "role: #{node.config['role']} · #{node.config['hours']}h" }`. Return a short phrase, or `nil` or `""` to show no line. Without it the card shows no summary, and a step with problems shows its error count in the summary's place. easy_flow's own step types already give a summary, such as "tests.result is not passed" on a Condition step or "waits 5 minutes" on a Wait step, and a host replaces any type's summary, its own or easy_flow's, through the host's `summaries`, set through `easy_flow-install`. The block is called every time the canvas is drawn, so it must not be slow and must not change anything, and like `names_by` its `node.config` holds no kept setting. Ask the developer what an admin should read about a step of this type without opening it.
|
|
109
109
|
- `shows_values(heading = nil, columns: false) { |node| ... }` — a read-only section of the step settings panel, shown under the step's editable settings. The block returns a hash of labels to values, such as `shows_values("Inputs") { |node| { "brief" => "load_brief.out.brief" } }`, and each value is shown as text in a monospace font. Without `columns:` each label sits beside its value with the labels in one column. With `columns: true` the pairs sit two to a row, each label above its value, such as `shows_values(columns: true) { |node| { "Timeout" => "90s", "Retry" => "3" } }`. Declare it several times for several sections, which are shown in the order declared. Nothing in a section can be edited from the panel.
|
|
110
110
|
- `shows_code(heading = nil) { |node| ... }` — a read-only section of the step settings panel holding code blocks. The block returns a hash of summary lines to code, such as `shows_code("Schemas") { |node| { "input_schema" => node.config["input_schema"].to_s } }`. Each block is closed until its summary line is clicked, and a line wider than the panel scrolls sideways inside its block.
|
|
111
111
|
- `links_to { |node| ... }` — buttons at the foot of the step settings panel, side by side above Delete step. The block returns a list of hashes each with a `label` and an `address`, such as `links_to { |node| [ { label: "Open agent", address: "/agents/#{node.config['agent']}" } ] }`. Each address is used as written.
|
|
@@ -580,7 +580,7 @@ Use this when a visitor's run should stop until a set time has passed, such as a
|
|
|
580
580
|
- `address` — optional. A card with one is a link to it, and a card without one is not a link.
|
|
581
581
|
- `selected` — the id of one step whose card is ringed in the accent colour, such as the step whose details the page shows.
|
|
582
582
|
- Any other keyword is passed to the wrapping element, such as `class:`.
|
|
583
|
-
3. The view lays the steps out left to right whatever the host's `canvas_direction`, as compact cards in
|
|
583
|
+
3. The view lays the steps out left to right whatever the host's `canvas_direction`, as the same graph a left-to-right canvas draws: compact cards in columns by stage, every connection drawn as a line labelled with the answer it is taken on, and a group step's box holding its steps as their own small graph. A flow wider than its box scrolls sideways inside it. On a screen narrower than 640 pixels each step sits on a row of its own with its connections listed under it. The Start and End steps are left out. It has no buttons and nothing on it changes the flow.
|
|
584
584
|
4. Ask the developer what each step's status line says and where each card links. Do not pick.
|
|
585
585
|
|
|
586
586
|
### Read a run and its answers
|
|
@@ -55,7 +55,7 @@ easy_flow declares no commands of its own for this local. Its surface is split b
|
|
|
55
55
|
- **Display** — what a step type hands the visitor's page to draw a step, such as its question text and its answers. A step type may build its display from the step alone, or from the step and the visitor's stored run, so the same step can show something different to each visitor. There is no stored run in an admin's preview or in a flow that carries its answers in the page, and the display is then built without one. A host can draw a single-choice, multiple-select or fill-in-the-blank step with an answer already chosen by passing it as `chosen`, and the step is drawn blank when none is passed.
|
|
56
56
|
- **Answer check** — a rule a step type may carry that looks at a visitor's answer and, when the answer is not acceptable, returns the message the visitor sees. A step type with no such rule accepts every answer.
|
|
57
57
|
- **Setting** — one field an admin fills in when configuring a step on the canvas. A step type may give a setting a one-sentence explanation, which shows under it in the step's settings. It is text, a whole number, a decimal, a yes or no, a pick from a list, a pick from a few choices drawn as radio cards side by side with a hint under each, several picks from a list, an earlier step, an earlier step's output, another flow of the same host, or a list of entries that each hold their own fields. A setting can be required, limited to a number of picks, or checked by a rule the step type supplies.
|
|
58
|
-
- **Options** — the values a pick-from-a-list setting offers, and for a radio card setting each value's label and hint. They are either a fixed list written into the step type, or a lookup the app provides that is read each time the canvas or a save asks for them, so they can come from the app's own data. A saved value that is not among the options is refused.
|
|
58
|
+
- **Options** — the values a pick-from-a-list setting offers, and for a radio card setting each value's label and hint. They are either a fixed list written into the step type, or a lookup the app provides that is read each time the canvas or a save asks for them, so they can come from the app's own data. A radio card setting's lookup may also be given the step's other settings, so its cards follow another setting, such as an agent's own aliases following the agent chosen. Its cards change as soon as the admin saves that other setting, without reloading the page. A saved value that is not among the options is refused, except that a radio card choice the step's other settings no longer offer is cleared on save, and the settings panel says it was cleared.
|
|
59
59
|
- **Kept setting** — a setting whose value lives on one of the app's own records rather than in the flow. The step type says how to find that record from the step's other settings and which of its attributes holds the value. The canvas shows the value read from the record, and saving the step's settings writes it straight to the record, so the flow's document and its versions never hold it and undo or publishing does not change it. When no record is found, nothing is written. When the record refuses a value, the save is refused with the record's own error and none of the step's kept settings are written.
|
|
60
60
|
- **Output** — a value a step records into the run, with a type and a label. Later steps read outputs, and a setting that points at an earlier step offers that step's known values on the canvas. A step type may also take further outputs from a list setting, one for each entry the admin gives a name, labelled with that name written as a phrase, such as "First reading" for `first_reading`. An entry left without a name adds no output. Those outputs are offered wherever the step's declared outputs are, such as when a Condition, Compare, Compare two values, All of or Any of or Count step picks which output to read.
|
|
61
61
|
- **Chosen output** — which of an earlier step's outputs a step reads. Every built-in step that names an earlier step and then reads one of its outputs asks the admin to pick that output, as does a step type of the app's own whose output setting points at a step setting. Once the earlier step is named, a step with no output picked is reported as missing that setting, and the same holds for each comparison in an All of or Any of list, for its first step and for its second step. A step that names no earlier step, such as a Compare two values step with its second step left empty, is not asked for that step's output.
|
|
@@ -102,16 +102,18 @@ easy_flow declares no commands of its own for this local. Its surface is split b
|
|
|
102
102
|
- **Offered step types** — the list of step types a host names for its admins to add. A host that names no list offers every registered step type. The list only narrows the palette.
|
|
103
103
|
- **Allowed answers** — a rule a host may carry that looks at a step and the answers given so far in a run and names the answer values that step allows. When it names nothing for a step, the step offers every answer. When it names several, a question or checklist offers only those. When it names exactly one, the step records that answer without being shown, and when it names none, the step is passed over and records a blank answer. This holds in a stored run, a run moved on outside a visitor's request, a flow that carries its answers in the page, and an admin's preview. Going back skips the steps the host filled in and returns to the last step the visitor was shown.
|
|
104
104
|
- **Always-visible insert buttons** — a setting a host may turn on, `always_show_insert_buttons`, that shows each connection's button for inserting a step on its canvas without the pointer over the connection, with the connection's label moved to the right of the line. It is off by default, and with it off the button shows only with the pointer over the connection.
|
|
105
|
-
- **Step card** — the box that draws one step on the canvas. It shows the step's name, the one-line summary the step's type works out from its settings under the name when the type declares one, and the step's type code under those, or above the name on a left-to-right canvas. A step with problems is bordered in red and its card counts them under the name, such as "1 error" or "2 errors", in place of the summary, and the sentence for each problem is in the Validation tab of the drawer under the canvas rather than on the card.
|
|
105
|
+
- **Step card** — the box that draws one step on the canvas. It shows the step's name, the one-line summary the step's type works out from its settings under the name when the type declares one or the host replaces it, and the step's type code under those, or above the name on a left-to-right canvas. A step with problems is bordered in red and its card counts them under the name, such as "1 error" or "2 errors", in place of the summary, and the sentence for each problem is in the Validation tab of the drawer under the canvas rather than on the card.
|
|
106
106
|
- **Hidden step type codes** — a setting a host may turn on, `hide_step_type_codes`, that hides step type code names on its canvas. The add menu lists each step type by its name alone, and a step's box shows its step type's name in place of the code name, with a step that has no name of its own headed by its step type's name. It is off by default, and with it off the add menu and step boxes show the code names. The settings panel shows a step's id and code name either way.
|
|
107
|
-
- **Canvas direction** — a setting a host may set, `canvas_direction`, to `:left_to_right` to lay its canvas out left to right in place of top to bottom. Steps sit as compact cards in
|
|
107
|
+
- **Canvas direction** — a setting a host may set, `canvas_direction`, to `:left_to_right` to lay its canvas out left to right in place of top to bottom. Steps sit as compact cards in columns by stage, every connection is drawn as a line labelled with the answer it is taken on, a loop back runs above the steps, a group step's box holds its steps as their own small graph, a flow wider than the canvas scrolls sideways, and a phone-width screen shows one step per row with its connections listed under it. Top to bottom is the default.
|
|
108
108
|
- **Step list** — a list beside the editing canvas, on screens 640 pixels and wider, of every step type the host offers, with a search field that keeps only the types whose name holds what was typed. A host may set `step_groups`, a hash of headings each with the step types listed under it, in the host's order, and the types it puts in no group are listed above the first heading. Clicking a type adds the step unconnected, as the add menu does, and dragging a type onto a connection inserts the step on that connection. On a phone the list is hidden and the add menu is the way to add steps.
|
|
109
|
-
- **Run view** — a read-only view of one flow version that an app draws on its own page with `easy_flow_run_view`, showing each step as a compact card with its type code, name, the version and status line the app supplies, and an edge coloured by the state the app supplies, done, paused, pending or failed. A paused step's edge is thicker, the step the app names as selected is ringed, a card the app gives an address is a link to it, and steps sit
|
|
109
|
+
- **Run view** — a read-only view of one flow version that an app draws on its own page with `easy_flow_run_view`, showing each step as a compact card with its type code, name, the version and status line the app supplies, and an edge coloured by the state the app supplies, done, paused, pending or failed. A paused step's edge is thicker, the step the app names as selected is ringed, a card the app gives an address is a link to it, and steps sit in the same graph a left-to-right canvas draws, with every connection drawn as a line, a group step's box holding its steps, and one card per row with its connections listed on a phone. It has no editing controls.
|
|
110
110
|
- **Publish note** — a setting a host may set, `publish_note`, whose sentence is shown directly under the Publish button in its flow panel. With none set, the panel shows no note.
|
|
111
111
|
- **Back link** — a setting a host may set, `back_link`, holding a label and an address, or a callable that takes the flow being shown and returns them, that shows a link with that label and address at the start of the editor's top bar in place of `All flows`. With a callable, each flow's canvas shows the back link worked out for that flow. With none set, the bar shows `All flows`.
|
|
112
112
|
- **Top bar** — the bar across the top of the canvas and of the definition text page. From left to right it shows the back link, the flow's name, the draft's status, such as `draft from v14 · unsaved 2 changes` or `new draft · unsaved 0 changes` for a flow with no version yet, and a Canvas / Text switch between the canvas and the definition text. On the canvas its buttons are `This flow`, `Try it`, the host's editor buttons, `Save draft` and a `Publish` button naming the version it will create, such as `Publish v15`. `Save draft` creates a version as the panel's Create version does, and both open the flow panel with the result. The status and the Publish label follow each change made on the canvas. The definition text page's bar shows `Try it` and the host's editor buttons, and the page keeps its own Save button. On a screen narrower than 640 pixels the back link, name, status and switch wrap onto more lines, and the buttons are reached from an actions menu in the bar.
|
|
113
113
|
- **Editor buttons** — a setting a host may set, `editor_buttons`, holding a list of buttons each with a label and an address, or a callable that takes the flow being shown and returns that list, whose buttons the top bar shows before `Save draft`, such as Run tests and Dry-run. The app decides what each address does. With none set, the bar shows no extra buttons.
|
|
114
114
|
- **On publish** — a setting a host may set, `on_publish`, holding a callable that takes a flow. easy_flow calls it each time a new version of one of that host's flows goes live, from the canvas's Publish button or from the app calling publish. Publishing a version that is already live does not call it. With none set, nothing is called.
|
|
115
|
+
- **Built-in summaries** — the summary line easy_flow's own step types give their cards. A Question, Checklist or Multiple select step shows how many answers it offers, such as "3 answers", and a Fill in the blank step how many answers it accepts. A File upload step shows the file types it accepts. A Condition, Compare or Compare two values step shows the comparison it makes, such as "tests.result is not passed". An All of or Any of step shows which must hold and how many comparisons it has, such as "all of 2 comparisons". A Count step shows what it counts, a Switch step the step it branches on, and a Read data or Write data step the values it reports. A Wait step shows how long it waits, such as "waits 5 minutes" or "waits until 09:00". A Flow step shows how many steps the version it runs holds, and a Play flows step how many flows it offers. Start and End steps show none.
|
|
116
|
+
- **Host summaries** — a setting a host may set, `summaries`, giving its own summary block for any step type, including easy_flow's own. Its line shows on the card in place of the step type's own, and a block that returns nothing shows no line. A block that raises is drawn without a summary, the error is written to the log, and the flow still opens.
|
|
115
117
|
- **Host setting explanations** — a setting a host may set, `setting_explanations`, giving its own explanation for one setting of one step type, including a setting inside a list. It shows in place of the step type's own. A setting it gives none for shows the step type's own, and with none set nothing changes.
|
|
116
118
|
- **Flow panel** — the panel the top bar's `This flow`, `Save draft` and `Publish` buttons open on the canvas, on every host. It shows Create version and Publish, the message saying what the last of them did or why it was refused, and the list of changes since the last version. Several saves to the same step in a row show as one line in the changes list, named by the step's latest name. A save, a move and any other change each keep their own line, and the history of versions still lists every change a version captured.
|
|
117
119
|
- **Drawer** — the panel under the editing canvas, on every host, with a row of tabs. Its first tab is Validation, followed by the number of problems the flow has when it has any. Validation lists one row per check: an `error` row for each problem with the step's id and a sentence naming the step by its name, or by its step type's name when it has none, and saying what to do to clear it, then an `ok` row for each check that found nothing. Clicking a row that names a step selects that step and opens its settings. A host may set `drawer_tabs` to add its own tabs after Validation, each with a label, an optional count such as `12/12` and its own content. On a phone the drawer shows only its tabs until one is tapped, an open drawer covers the canvas, and tapping the open tab again closes it.
|
|
@@ -60,7 +60,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
60
60
|
- `offers` — the step types this host's admins can add from the canvas palette, as a list of step type names. With none set, every registered step type is offered. The engine's own names are `question`, `checklist`, `multiple_select`, `fill_in_the_blank`, `file_upload`, `condition`, `switch`, `compare`, `compare_two_values`, `all_or_any`, `count`, `wait`, `flow_step` and `play_flows`, `file_upload` being the File upload step, which needs the file store from step 10, `compare_two_values` being the Compare two values step, which compares the outputs of two earlier steps, `all_or_any` being the All of or Any of step, which decides whether all or any of several such comparisons hold, `count` being the Count step, which counts how often an earlier step was answered, `wait` being the Wait step, which holds a run until a time counted from an earlier answer or until a date, `flow_step` being the Flow step, which names one of the same host's flows, and `play_flows` being the Play flows step, which lists several of the same host's flows for a visitor to play in the order they choose. A step type the app declares is named by the id it was declared with, or after its class when it is a step class, so `Steps::Notify` is `notify`. The End step is offered whether it is listed or not, and the Start step is never offered. Ask the developer which step types each host should offer.
|
|
61
61
|
- `always_show_insert_buttons` — set to `true` to show each connection's button for inserting a step on this host's canvas without the pointer over the connection. A connection's label then sits to the right of the line so the button does not cover it. With none set, the button shows only with the pointer over the connection.
|
|
62
62
|
- `hide_step_type_codes` — set to `true` to hide step type code names on this host's canvas. The add menu then lists each step type by its name alone, and a step's box shows its step type's name in place of the code name. With none set, the add menu and step boxes show the code names. The settings panel shows a step's id and code name either way.
|
|
63
|
-
- `canvas_direction` — set to `:left_to_right` to lay this host's canvas out left to right. Steps then sit as compact cards in
|
|
63
|
+
- `canvas_direction` — set to `:left_to_right` to lay this host's canvas out left to right. Steps then sit as compact cards in columns by stage, each step to the right of every step that leads into it apart from connections that loop back. Every connection is drawn as a line, labelled with the answer it is taken on, and branches fan out into separate rows and join again at the step they share. A connection that loops back runs above the steps and one that skips columns runs below them, so no line crosses a card. A group step's box holds its steps as their own small graph, entered from the step before it and left for the step after it. A flow wider than the canvas scrolls sideways inside it. An admin inserts or removes a connection with the buttons on its line, and drops a step or a step type onto the line to put it there. On a screen narrower than 640 pixels, each step sits on a row of its own with its connections listed under it. With none set, or with `:top_to_bottom`, the canvas is laid out top to bottom as before.
|
|
64
64
|
- `step_groups` — a hash of the headings this host's canvas step list shows, each with the step types listed under it by name, such as `{ "Agents" => [ :question, :checklist ], "Control" => [ :switch, :wait ] }`. Headings appear in the order given. Offered step types the hash leaves out are listed above the first heading, and a type the host does not offer is not listed. With none set, the list shows every offered step type under no heading. Ask the developer how each host's step types should be grouped.
|
|
65
65
|
- `marks_ends` — set to `true` to have this host's admins mark each End step as success or failure. The End step's settings then show a Mark with those two choices, and publishing one of this host's flows with an End left unmarked is refused, the refusal shown on that End's card. With none set, End steps show no mark and publish as they do. Ask the developer whether this host's runs need to say if they ended well.
|
|
66
66
|
- `publish_note` — a sentence shown directly under the Publish button in this host's flow panel. It is shown as plain text. With none set, the panel shows no note.
|
|
@@ -68,6 +68,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
68
68
|
- `editor_buttons` — a list of hashes each with a `label` and an `address`, such as `[ { label: "Run tests", address: "/admin/flow_tests" }, { label: "Dry-run", address: "/admin/dry_runs" } ]`, shown as buttons in this host's editor top bar before `Save draft`, on the canvas and on the definition text page. On a phone they are reached from the bar's actions menu. It may instead be a callable that takes the flow being shown and returns that list, such as `->(flow) { [ { label: "Run tests", address: "/admin/flow_tests/#{flow.slug}" } ] }`, so each flow's buttons lead to pages of its own. A hash missing either key raises `ArgumentError` when the canvas is opened. Each address is used as written, so it comes from the app's own configuration and never from a request. The app decides what each address does. With none set, the bar shows no extra buttons. Ask the developer which buttons each host's editor needs.
|
|
69
69
|
- `drawer_tabs` — a list of hashes each with a `label`, an optional `count` and its `content` as HTML, such as `[ { label: "Fixtures", count: "12/12", content: "<p>12 of 12 fixtures pass.</p>" }, { label: "Dry-run", content: "<p>No dry-run yet.</p>" } ]`, shown as tabs after Validation in the drawer under this host's canvas. The count is written after the label, and a tab with no count shows only its label. It may instead be a callable that takes the flow being edited and returns that list, such as `->(flow) { [ { label: "Fixtures", count: FixtureRun.score(flow), content: ApplicationController.render(partial: "flows/fixtures", locals: { flow: flow }) } ] }`. The content is put on the page as given, so it is built by the app and any value from a record in it is escaped. The list is worked out each time the canvas is drawn, so a slow lookup slows the canvas. A hash missing `label` or `content` raises `ArgumentError` when the canvas is opened. With none set, the drawer shows only Validation. Ask the developer which tabs each host's drawer needs and what each shows.
|
|
70
70
|
- `on_publish` — a callable that takes a flow, such as `->(flow) { RecountJob.perform_later(flow.id) }`, that easy_flow calls each time a new version of one of this host's flows goes live, whether an admin pressed Publish on the canvas or the app called `publish` on the flow. It runs inside the publish request, so slow work belongs in a job it starts. Publishing a version that is already live does not call it. With none set, nothing is called. Ask the developer what the app must do when a flow goes live.
|
|
71
|
+
- `summaries` — this host's own summary lines for step cards, as a hash of step type name to a block given the step, such as `{ condition: ->(node) { "#{node.config['step']} must be #{node.config['answer']}" } }`. It replaces the summary of any step type, easy_flow's own included, so a host can word the cards of Condition, Wait and the other built-in types its own way without changing the gem. A block that returns `nil` or `""` shows no line. The block is called each time the canvas is drawn, so it must not be slow and must not change anything. When it raises, the step is drawn without a summary, the error is written to the app's log, and the flow still opens. With none set, every step shows its type's own summary. Ask the developer which step types' cards should read differently from easy_flow's own summaries.
|
|
71
72
|
- `setting_explanations` — this host's own explanations for step type settings, as a hash of step type name to setting name to a sentence, such as `{ multiple_select: { category: "The round this question counts toward.", "answers.weight" => "Points this answer adds to the score." } }`. A setting inside a list is named by the list and the setting joined with a dot, and a list setting's own explanation is named by the list alone. The sentence is shown as plain text under the setting in the step's settings, in place of the step type's own. A setting with none, or with a blank one, shows the step type's own, if it has one. A step type or setting name that matches nothing is ignored. A value that is not text, such as a nested hash, raises `ArgumentError` when the host is declared. With none set, every setting shows the step type's own explanation.
|
|
72
73
|
|
|
73
74
|
Each method named here must exist on the base controller. Ask the developer to point at it or write it. Do not invent its logic.
|
|
@@ -166,7 +167,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
166
167
|
- A step type of the app's own that holds other steps, such as a "for each" step, is drawn on the canvas as a dashed box with a header line at the top and the steps it holds inside. It needs no migration and no setting in the initializer beyond being listed in a host's `offers` when that host sets `offers`. Flows with no such step load and run as before.
|
|
167
168
|
- After adding a step type that holds other steps to a flow, check that its header line shows the step type's code followed by each filled-in setting, or the type's name and the settings' labels on a host with `hide_step_type_codes` set, and that clicking the header opens the step's settings.
|
|
168
169
|
- After adding a step type that holds other steps to a flow, check that dragging another step onto its box puts the step inside the box, that dragging it onto the canvas outside the box takes it out, and that both leave the step's connections as they were.
|
|
169
|
-
- After setting `canvas_direction` to `:left_to_right` on a host, check that its canvas shows the steps in
|
|
170
|
+
- After setting `canvas_direction` to `:left_to_right` on a host, check that its canvas shows the steps in columns with every connection drawn as a labelled line, that a flow wider than the canvas scrolls sideways inside it, and that a phone-width screen shows one step per row with its connections listed under it.
|
|
170
171
|
- A page of the app that calls `easy_flow_run_view` needs the `keystone_ui/react` and `easy_flow/canvas` scripts in its head, the same two the canvas page loads. The helper needs no setting in the initializer, and it is available in every view of the app. After adding one, check that the page shows each step's card with the state and status line the app supplied, and that a phone-width screen shows one card per row.
|
|
171
172
|
- After setting `step_groups` on a host, check that its canvas shows the step list beside the canvas with each step type under its heading, that typing in its search field narrows the list, that clicking a type adds an unconnected step, that dragging a type onto a connection inserts it there, and that a phone-width screen shows no step list.
|
|
172
173
|
- After setting `editor_buttons` on a host, check that its canvas's top bar shows each button between `Try it` and `Save draft` with the label given, that each opens its address, and that on a phone-width screen the buttons are listed in the bar's actions menu.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: easy_flow
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.51.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylercschneider
|
|
@@ -118,15 +118,16 @@ files:
|
|
|
118
118
|
- app/javascript/easy_flow/canvas/RunView.jsx
|
|
119
119
|
- app/javascript/easy_flow/canvas/StepCard.jsx
|
|
120
120
|
- app/javascript/easy_flow/canvas/StepList.jsx
|
|
121
|
+
- app/javascript/easy_flow/canvas/StepRows.jsx
|
|
121
122
|
- app/javascript/easy_flow/canvas/Toolbar.jsx
|
|
122
123
|
- app/javascript/easy_flow/canvas/TypePicker.jsx
|
|
123
124
|
- app/javascript/easy_flow/canvas/changes.js
|
|
124
125
|
- app/javascript/easy_flow/canvas/choices.js
|
|
125
126
|
- app/javascript/easy_flow/canvas/flow.js
|
|
126
127
|
- app/javascript/easy_flow/canvas/flowSender.js
|
|
128
|
+
- app/javascript/easy_flow/canvas/graph.js
|
|
127
129
|
- app/javascript/easy_flow/canvas/group.js
|
|
128
130
|
- app/javascript/easy_flow/canvas/ids.js
|
|
129
|
-
- app/javascript/easy_flow/canvas/reading.js
|
|
130
131
|
- app/javascript/easy_flow/canvas/rows.js
|
|
131
132
|
- app/javascript/easy_flow/canvas/styles.js
|
|
132
133
|
- app/javascript/easy_flow/canvas/topBar.js
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const byPlace = (a, b) => a.row - b.row || a.column - b.column
|
|
2
|
-
|
|
3
|
-
const holdersOf = (nodes) => new Map(nodes.flatMap((group) => (group.holds || []).map((id) => [ id, group.id ])))
|
|
4
|
-
|
|
5
|
-
export const readingOrder = (nodes) => {
|
|
6
|
-
const placed = [ ...nodes ].sort(byPlace)
|
|
7
|
-
const holders = holdersOf(nodes)
|
|
8
|
-
const held = new Map(nodes.filter((node) => node.holds).map((group) => [ group.id, [] ]))
|
|
9
|
-
placed.filter((node) => holders.has(node.id)).forEach((node) => held.get(holders.get(node.id)).push(node))
|
|
10
|
-
|
|
11
|
-
return placed.filter((node) => !holders.has(node.id)).flatMap((node) => [ node, ...(held.get(node.id) || []) ])
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const blocksOf = (nodes) => {
|
|
15
|
-
const holders = holdersOf(nodes)
|
|
16
|
-
const ordered = readingOrder(nodes)
|
|
17
|
-
const blocks = []
|
|
18
|
-
const boxes = new Map()
|
|
19
|
-
|
|
20
|
-
ordered.filter((node) => !holders.has(node.id)).forEach((node) => {
|
|
21
|
-
const last = blocks[blocks.length - 1]
|
|
22
|
-
if (node.holds) boxes.set(node.id, blocks[blocks.push({ group: node, steps: [] }) - 1])
|
|
23
|
-
else if (last && !last.group) last.steps.push(node)
|
|
24
|
-
else blocks.push({ steps: [ node ] })
|
|
25
|
-
})
|
|
26
|
-
ordered.filter((node) => holders.has(node.id)).forEach((node) => boxes.get(holders.get(node.id))?.steps.push(node))
|
|
27
|
-
|
|
28
|
-
return blocks
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const nameOf = (step) => (step?.placeholder ? "nowhere yet" : step?.label)
|
|
32
|
-
|
|
33
|
-
const joins = new WeakMap()
|
|
34
|
-
|
|
35
|
-
const joinsOf = (edges) => {
|
|
36
|
-
if (!joins.has(edges)) joins.set(edges, new Map([ ...edges ].reverse().map((edge) => [ `${edge.source}\n${edge.target}`, edge ])))
|
|
37
|
-
return joins.get(edges)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const joining = (edges, before, after) => joinsOf(edges).get(`${before.id}\n${after.id}`)
|
|
41
|
-
|
|
42
|
-
export const branchLinesOf = (steps, edges, nodes) => {
|
|
43
|
-
const ordered = readingOrder(steps)
|
|
44
|
-
const next = new Map(ordered.map((step, at) => [ step.id, ordered[at + 1]?.id ]))
|
|
45
|
-
const names = new Map(nodes.map((node) => [ node.id, nameOf(node) ]))
|
|
46
|
-
const lines = Object.fromEntries(steps.map((step) => [ step.id, [] ]))
|
|
47
|
-
|
|
48
|
-
edges.filter((edge) => lines[edge.source] && (edge.label || edge.target !== next.get(edge.source)))
|
|
49
|
-
.forEach((edge) => lines[edge.source].push([ edge.label, "→", names.get(edge.target) ].filter(Boolean).join(" ")))
|
|
50
|
-
|
|
51
|
-
return lines
|
|
52
|
-
}
|