Skip to content

Commit

Permalink
#997 Fixed hiding tool-ref modal view
Browse files Browse the repository at this point in the history
  • Loading branch information
mellelieuwes committed Nov 15, 2024
1 parent 1454041 commit 1ca5ff8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
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
2 changes: 1 addition & 1 deletion core/systems/assignment/external_panel_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ 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
# 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
Expand Down

0 comments on commit 1ca5ff8

Please sign in to comment.