Skip to content
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

Add possibility to skip finished page #999

Merged
merged 2 commits into from
Nov 15, 2024
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
29 changes: 19 additions & 10 deletions core/systems/assignment/crew_work_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,17 @@ defmodule Systems.Assignment.CrewWorkView do
defp handle_complete_task(%{assigns: %{selected_item: {_, task}}} = socket) do
{:ok, %{crew_task: updated_task}} = Crew.Public.complete_task(task)

socket
|> hide_modal(:tool_ref_view)
|> update_task(updated_task)
|> handle_finished_state()
|> select_next_item()
if embedded?(socket) and singleton?(socket) do
# Keep tool_ref view open and prevent finished view from being shown
# FIXME: This is a temporary solution to allow embeds to work https://github.com/eyra/mono/issues/997
socket
else
socket
|> update_task(updated_task)
|> hide_modal(:tool_ref_view)
|> handle_finished_state()
|> select_next_item()
end
end

defp update_task(%{assigns: %{work_items: work_items}} = socket, updated_task) do
Expand Down Expand Up @@ -596,11 +602,6 @@ defmodule Systems.Assignment.CrewWorkView do
socket |> assign(selected_item_id: selected_item_id)
end

defp handle_finished_state(%{assigns: %{panel_info: %{embedded?: true}}} = socket) do
# Dont show finished view when embedded in external panel UI
socket
end

defp handle_finished_state(%{assigns: %{retry?: true}} = socket), do: socket

defp handle_finished_state(%{assigns: %{work_items: work_items}} = socket) do
Expand Down Expand Up @@ -645,6 +646,14 @@ defmodule Systems.Assignment.CrewWorkView do
|> Concept.ToolModel.launcher()
end

defp embedded?(%{assigns: %{panel_info: %{embedded?: embedded?}}}) do
embedded?
end

defp singleton?(%{assigns: %{work_items: work_items}}) do
length(work_items) == 1
end

@impl true
@spec render(any()) :: Phoenix.LiveView.Rendered.t()
def render(assigns) do
Expand Down
4 changes: 4 additions & 0 deletions core/systems/assignment/external_panel_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ defmodule Systems.Assignment.ExternalPanelController do
String.length(id) <= @id_max_lenght and Regex.match?(@id_valid_regex, id)
end

# FIXME: This is a temporary solution to allow embeds to work https://github.com/eyra/mono/issues/997
defp has_no_access?(_, %{"embed" => "true"}), do: false

defp has_no_access?(%{external_panel: external_panel}, params) do
external_panel = Atom.to_string(external_panel)
external_panel != get_panel(params)
Expand Down Expand Up @@ -117,5 +120,6 @@ defmodule Systems.Assignment.ExternalPanelController do
defp get_participant(_), do: nil

defp embedded?(%{"entry" => "liss"}), do: true
defp embedded?(%{"embed" => "true"}), do: true
defp embedded?(_), do: false
end
Loading