LightningWeb.WorkflowLive.Helpers (Lightning v2.14.14-pre2)
View SourceHelper functions for the Workflow LiveViews.
Summary
Functions
Builds a URL with query parameters based on parameter definitions.
Creates chat-related parameters
Creates code view parameters
Builds a URL to the collaborative editor with converted query parameters.
Creates orthogonal parameters (excludes mode and selection)
Creates a parameter definition with common defaults.
Creates parameters excluding mode and selection
Creates a parameter that pulls from query_params
Determines whether to show the collaborative editor toggle (beaker icon).
Creates standard URL parameters (all common params)
Creates URL parameters ignoring v (all common params except version tag)
Creates parameters with custom overrides
Determines if a workflow is enabled based on its triggers. Accepts either a Workflow struct or an Ecto.Changeset.
Creates workflow input run parameters
Generates a tooltip describing the workflow's state. Accepts either a Workflow struct or an Ecto.Changeset.
Functions
Builds a URL with query parameters based on parameter definitions.
Parameters
assigns- The assigns from the LiveViewparams- List of parameter definitions. Each definition is a keyword list with::name- The parameter name in the URL (required):value- The value or a function that receives (assigns, params) (required):when- Condition as boolean or function that receives (assigns, params) (default: true):transform- Optional transformation function applied to the value
Creates chat-related parameters
Creates code view parameters
Builds a URL to the collaborative editor with converted query parameters.
This function uses a data-driven approach with the @param_mappings configuration
to convert classical editor parameters to collaborative editor equivalents.
Conversion Rules
a(followed run) →runs(selected step) →job/trigger/edge(context-aware based on selection)m=expand→panel=editorm=workflow_input→panel=runm=settings→panel=settings- Preserves:
v,method,w-chat,j-chat,code - Skips:
panel(collaborative-only)
Parameters
assigns- Socket assigns containing:query_params- Current URL query parametersselected_job- Currently selected job (optional, for context)selected_trigger- Currently selected trigger (optional, for context)selected_edge- Currently selected edge (optional, for context)project- Project struct withidworkflow- Workflow struct withid(if not new workflow)live_action- Current LiveView action (:newor:edit)
Returns
A complete URL string for the collaborative editor
Examples
iex> collaborative_editor_url(%{
...> query_params: %{"a" => "run-123", "s" => "job-abc", "m" => "expand"},
...> selected_job: %{id: "job-abc"},
...> project: %{id: "proj-1"},
...> workflow: %{id: "wf-1"},
...> live_action: :edit
...> })
"/projects/proj-1/w/wf-1/collaborate?run=run-123&job=job-abc&panel=editor"
Creates orthogonal parameters (excludes mode and selection)
Creates a parameter definition with common defaults.
Creates parameters excluding mode and selection
Creates a parameter that pulls from query_params
@spec run_workflow( Ecto.Changeset.t(Lightning.Workflows.Workflow.t()) | Lightning.Workflows.Workflow.t(), map(), selected_job: map(), created_by: map(), project: map() ) :: {:ok, %{ workorder: Lightning.WorkOrder.t(), workflow: Lightning.Workflows.Workflow.t(), message: Lightning.Extensions.UsageLimiting.message() }} | {:error, Ecto.Changeset.t(Lightning.Workflows.Workflow.t())} | {:error, Ecto.Changeset.t(Lightning.WorkOrders.Manual.t())} | {:error, Lightning.Extensions.UsageLimiting.message()} | {:error, :workflow_deleted}
@spec save_workflow( Ecto.Changeset.t(), struct() ) :: {:ok, Lightning.Workflows.Workflow.t()} | {:error, Ecto.Changeset.t() | Lightning.Extensions.UsageLimiting.message() | :workflow_deleted}
Determines whether to show the collaborative editor toggle (beaker icon).
Returns true only if:
- User has experimental features enabled
- Currently viewing the latest version (not a snapshot)
Creates standard URL parameters (all common params)
Creates URL parameters ignoring v (all common params except version tag)
Creates parameters with custom overrides
Determines if a workflow is enabled based on its triggers. Accepts either a Workflow struct or an Ecto.Changeset.
Creates workflow input run parameters
Generates a tooltip describing the workflow's state. Accepts either a Workflow struct or an Ecto.Changeset.