Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ and this project adheres to

### Fixed

- Fix `collaborative_editor_url/2` incorrectly mapping trigger/edge selections
to `job` param when switching from legacy to collaborative editor
[#4375](https://github.com/OpenFn/lightning/issues/4375)
- Consider manual runs for "next cron run input" via the
`last_run_final_dataclip` function
[#4584](https://github.com/OpenFn/lightning/issues/4584)
Expand Down
6 changes: 5 additions & 1 deletion lib/lightning_web/live/workflow_live/edit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,11 @@ defmodule LightningWeb.WorkflowLive.Edit do
})

collaborative_url =
Helpers.collaborative_editor_url(params, socket.assigns.live_action)
Helpers.collaborative_editor_url(
params,
socket.assigns.live_action,
socket.assigns
)

{:noreply, push_navigate(socket, to: collaborative_url)}
end
Expand Down
4 changes: 2 additions & 2 deletions lib/lightning_web/live/workflow_live/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,12 @@ defmodule LightningWeb.WorkflowLive.Helpers do
"/projects/proj-1/w/wf-1?custom=value&job=job-123&v=42"

"""
def collaborative_editor_url(params, live_action) do
def collaborative_editor_url(params, live_action, assigns \\ %{}) do
collaborative_params =
params
|> Map.drop(["id", "project_id"])
|> Enum.reduce(%{}, fn {key, value}, acc ->
convert_param(key, value, acc, params)
convert_param(key, value, acc, assigns)
end)

base_url = collaborative_base_url(params, live_action)
Expand Down
39 changes: 39 additions & 0 deletions test/lightning_web/live/workflow_live/helpers_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,45 @@ defmodule LightningWeb.WorkflowLive.HelpersTest do
assert result == "/projects/proj-1/w/wf-1?job=unknown-id"
end

test "maps 's' to 'trigger' when assigns identify it as a trigger" do
params = %{
"s" => "trigger-xyz",
"project_id" => "proj-1",
"id" => "wf-1"
}

assigns = %{selected_trigger: %{id: "trigger-xyz"}}

result = Helpers.collaborative_editor_url(params, :edit, assigns)
assert result == "/projects/proj-1/w/wf-1?trigger=trigger-xyz"
end

test "maps 's' to 'edge' when assigns identify it as an edge" do
params = %{
"s" => "edge-123",
"project_id" => "proj-1",
"id" => "wf-1"
}

assigns = %{selected_edge: %{id: "edge-123"}}

result = Helpers.collaborative_editor_url(params, :edit, assigns)
assert result == "/projects/proj-1/w/wf-1?edge=edge-123"
end

test "maps 's' to 'job' when assigns identify it as a job" do
params = %{
"s" => "job-abc",
"project_id" => "proj-1",
"id" => "wf-1"
}

assigns = %{selected_job: %{id: "job-abc"}}

result = Helpers.collaborative_editor_url(params, :edit, assigns)
assert result == "/projects/proj-1/w/wf-1?job=job-abc"
end

test "converts 'm=expand' to 'panel=editor'" do
params = %{
"m" => "expand",
Expand Down