chore: converted import editor to LiveComponent
This commit is contained in:
@@ -164,15 +164,7 @@ defmodule BDS.Desktop.ShellLive do
|
|||||||
|> assign(:sidebar_filters_by_view, %{})
|
|> assign(:sidebar_filters_by_view, %{})
|
||||||
|> assign(:sidebar_filter_panels, %{})
|
|> assign(:sidebar_filter_panels, %{})
|
||||||
|> assign(:chat_editor_request_refs, %{})
|
|> assign(:chat_editor_request_refs, %{})
|
||||||
|> assign(:import_editor_analysis_states, %{})
|
|> assign(:misc_editor_selected_pairs, %{})
|
||||||
|> assign(:import_editor_analysis_task_refs, %{})
|
|
||||||
|> assign(:import_editor_execution_states, %{})
|
|
||||||
|> assign(:import_editor_execution_task_refs, %{})
|
|
||||||
|> assign(:import_editor_sections, %{})
|
|
||||||
|> assign(:import_editor_taxonomy_edits, %{})
|
|
||||||
|> assign(:import_editor_model_selectors_open, %{})
|
|
||||||
|> assign(:import_editor_selected_models, %{})
|
|
||||||
|> assign(:misc_editor_selected_pairs, %{})
|
|
||||||
|> assign(:misc_editor_git_selected_files, %{})
|
|> assign(:misc_editor_git_selected_files, %{})
|
||||||
|> assign(:metadata_diff_active_tabs, %{})
|
|> assign(:metadata_diff_active_tabs, %{})
|
||||||
|> assign(:metadata_diff_field_filters, %{})
|
|> assign(:metadata_diff_field_filters, %{})
|
||||||
@@ -323,59 +315,6 @@ defmodule BDS.Desktop.ShellLive do
|
|||||||
{:noreply, apply_shell_command(socket, action)}
|
{:noreply, apply_shell_command(socket, action)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_event("change_import_editor_definition", %{"import_definition" => params}, socket) do
|
|
||||||
{:noreply, ImportEditor.change_definition(socket, params, &reload_shell/2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("select_import_uploads_folder", _params, socket) do
|
|
||||||
{:noreply,
|
|
||||||
ImportEditor.select_uploads_folder(socket, &reload_shell/2, &append_output_entry/5)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("select_import_wxr_file", _params, socket) do
|
|
||||||
{:noreply, ImportEditor.select_and_analyze(socket, &reload_shell/2, &append_output_entry/5)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("execute_import_editor", _params, socket) do
|
|
||||||
{:noreply, ImportEditor.execute_import(socket, &reload_shell/2, &append_output_entry/5)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("change_import_conflict_resolution", params, socket) do
|
|
||||||
{:noreply, ImportEditor.change_conflict_resolution(socket, params, &reload_shell/2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("start_import_taxonomy_edit", params, socket) do
|
|
||||||
{:noreply, ImportEditor.start_taxonomy_edit(socket, params, &reload_shell/2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("save_import_taxonomy_edit", params, socket) do
|
|
||||||
{:noreply, ImportEditor.save_taxonomy_edit(socket, params, &reload_shell/2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("cancel_import_taxonomy_edit", _params, socket) do
|
|
||||||
{:noreply, ImportEditor.cancel_taxonomy_edit(socket, &reload_shell/2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("clear_import_taxonomy_mapping", params, socket) do
|
|
||||||
{:noreply, ImportEditor.clear_taxonomy_mapping(socket, params, &reload_shell/2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("toggle_import_section", %{"section" => section}, socket) do
|
|
||||||
{:noreply, ImportEditor.toggle_section(socket, section, &reload_shell/2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("toggle_import_ai_model_selector", _params, socket) do
|
|
||||||
{:noreply, ImportEditor.toggle_model_selector(socket, &reload_shell/2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("select_import_ai_model", %{"model" => model_id}, socket) do
|
|
||||||
{:noreply, ImportEditor.select_ai_model(socket, model_id, &reload_shell/2)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("analyze_import_taxonomy_ai", _params, socket) do
|
|
||||||
{:noreply, ImportEditor.analyze_taxonomy_ai(socket, &reload_shell/2, &append_output_entry/5)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event("rerun_misc_editor", _params, socket) do
|
def handle_event("rerun_misc_editor", _params, socket) do
|
||||||
case MiscEditor.rerun(socket) do
|
case MiscEditor.rerun(socket) do
|
||||||
{:command, action} -> {:noreply, apply_shell_command(socket, action)}
|
{:command, action} -> {:noreply, apply_shell_command(socket, action)}
|
||||||
@@ -870,26 +809,6 @@ defmodule BDS.Desktop.ShellLive do
|
|||||||
Process.demonitor(ref, [:flush])
|
Process.demonitor(ref, [:flush])
|
||||||
|
|
||||||
cond do
|
cond do
|
||||||
Map.has_key?(socket.assigns.import_editor_analysis_task_refs, ref) ->
|
|
||||||
{:noreply,
|
|
||||||
ImportEditor.finish_analysis(
|
|
||||||
socket,
|
|
||||||
ref,
|
|
||||||
result,
|
|
||||||
&reload_shell/2,
|
|
||||||
&append_output_entry/5
|
|
||||||
)}
|
|
||||||
|
|
||||||
Map.has_key?(socket.assigns.import_editor_execution_task_refs, ref) ->
|
|
||||||
{:noreply,
|
|
||||||
ImportEditor.finish_execution(
|
|
||||||
socket,
|
|
||||||
ref,
|
|
||||||
result,
|
|
||||||
&reload_shell/2,
|
|
||||||
&append_output_entry/5
|
|
||||||
)}
|
|
||||||
|
|
||||||
Map.has_key?(socket.assigns.chat_editor_request_refs, ref) ->
|
Map.has_key?(socket.assigns.chat_editor_request_refs, ref) ->
|
||||||
{conversation_id, remaining_refs} = Map.pop(socket.assigns.chat_editor_request_refs, ref)
|
{conversation_id, remaining_refs} = Map.pop(socket.assigns.chat_editor_request_refs, ref)
|
||||||
|
|
||||||
@@ -909,26 +828,6 @@ defmodule BDS.Desktop.ShellLive do
|
|||||||
def handle_info({:DOWN, ref, :process, _pid, reason}, socket) when is_reference(ref) do
|
def handle_info({:DOWN, ref, :process, _pid, reason}, socket) when is_reference(ref) do
|
||||||
next_socket =
|
next_socket =
|
||||||
cond do
|
cond do
|
||||||
Map.has_key?(socket.assigns.import_editor_analysis_task_refs, ref) ->
|
|
||||||
ImportEditor.handle_task_down(
|
|
||||||
socket,
|
|
||||||
:analysis,
|
|
||||||
ref,
|
|
||||||
reason,
|
|
||||||
&reload_shell/2,
|
|
||||||
&append_output_entry/5
|
|
||||||
)
|
|
||||||
|
|
||||||
Map.has_key?(socket.assigns.import_editor_execution_task_refs, ref) ->
|
|
||||||
ImportEditor.handle_task_down(
|
|
||||||
socket,
|
|
||||||
:execution,
|
|
||||||
ref,
|
|
||||||
reason,
|
|
||||||
&reload_shell/2,
|
|
||||||
&append_output_entry/5
|
|
||||||
)
|
|
||||||
|
|
||||||
Map.has_key?(socket.assigns.chat_editor_request_refs, ref) ->
|
Map.has_key?(socket.assigns.chat_editor_request_refs, ref) ->
|
||||||
{conversation_id, remaining_refs} = Map.pop(socket.assigns.chat_editor_request_refs, ref)
|
{conversation_id, remaining_refs} = Map.pop(socket.assigns.chat_editor_request_refs, ref)
|
||||||
|
|
||||||
@@ -951,25 +850,21 @@ defmodule BDS.Desktop.ShellLive do
|
|||||||
{:noreply, next_socket}
|
{:noreply, next_socket}
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_info({:import_analysis_progress, definition_id, step, detail}, socket) do
|
def handle_info({:import_editor_output, title, message, level}, socket) do
|
||||||
{:noreply,
|
{:noreply, append_output_entry(socket, title, message, nil, level)}
|
||||||
ImportEditor.note_analysis_progress(socket, definition_id, step, detail, &reload_shell/2)}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_info(
|
def handle_info({:import_editor_tab_meta, definition_id, title, subtitle}, socket) do
|
||||||
{:import_execution_progress, definition_id, phase, current, total, detail},
|
tab_meta =
|
||||||
socket
|
Map.put(socket.assigns.tab_meta, {:import, definition_id}, %{
|
||||||
) do
|
title: title,
|
||||||
|
subtitle: subtitle || ""
|
||||||
|
})
|
||||||
|
|
||||||
{:noreply,
|
{:noreply,
|
||||||
ImportEditor.note_execution_progress(
|
socket
|
||||||
socket,
|
|> assign(:tab_meta, tab_meta)
|
||||||
definition_id,
|
|> reload_shell(socket.assigns.workbench)}
|
||||||
phase,
|
|
||||||
current,
|
|
||||||
total,
|
|
||||||
detail,
|
|
||||||
&reload_shell/2
|
|
||||||
)}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_info({:chat_tool_call, conversation_id, tool_call}, socket) do
|
def handle_info({:chat_tool_call, conversation_id, tool_call}, socket) do
|
||||||
@@ -1311,7 +1206,6 @@ defmodule BDS.Desktop.ShellLive do
|
|||||||
|> assign(:menu_groups, socket.assigns[:menu_groups] || TitlebarMenu.groups())
|
|> assign(:menu_groups, socket.assigns[:menu_groups] || TitlebarMenu.groups())
|
||||||
|> assign(:titlebar_menu_item_index, socket.assigns[:titlebar_menu_item_index])
|
|> assign(:titlebar_menu_item_index, socket.assigns[:titlebar_menu_item_index])
|
||||||
|> assign(:current_tab, current_tab(workbench))
|
|> assign(:current_tab, current_tab(workbench))
|
||||||
|> assign_import_editor()
|
|
||||||
|> assign_misc_editor()
|
|> assign_misc_editor()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1354,10 +1248,6 @@ defmodule BDS.Desktop.ShellLive do
|
|||||||
Enum.find(tabs, &(&1.type == type and &1.id == id))
|
Enum.find(tabs, &(&1.type == type and &1.id == id))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp assign_import_editor(socket) do
|
|
||||||
ImportEditor.assign_socket(socket)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp assign_misc_editor(socket) do
|
defp assign_misc_editor(socket) do
|
||||||
MiscEditor.assign_socket(socket)
|
MiscEditor.assign_socket(socket)
|
||||||
end
|
end
|
||||||
@@ -1769,7 +1659,6 @@ defmodule BDS.Desktop.ShellLive do
|
|||||||
socket
|
socket
|
||||||
|> assign(:shell_overlay, nil)
|
|> assign(:shell_overlay, nil)
|
||||||
|> assign(:tab_meta, Map.delete(socket.assigns.tab_meta, {:import, definition_id}))
|
|> assign(:tab_meta, Map.delete(socket.assigns.tab_meta, {:import, definition_id}))
|
||||||
|> clear_import_editor_state(definition_id)
|
|
||||||
|> reload_shell(workbench)
|
|> reload_shell(workbench)
|
||||||
|
|
||||||
{:error, reason} ->
|
{:error, reason} ->
|
||||||
@@ -1780,39 +1669,6 @@ defmodule BDS.Desktop.ShellLive do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp clear_import_editor_state(socket, definition_id) do
|
|
||||||
socket
|
|
||||||
|> assign(
|
|
||||||
:import_editor_analysis_states,
|
|
||||||
Map.delete(socket.assigns.import_editor_analysis_states, definition_id)
|
|
||||||
)
|
|
||||||
|> assign(
|
|
||||||
:import_editor_analysis_task_refs,
|
|
||||||
Map.delete(socket.assigns.import_editor_analysis_task_refs, definition_id)
|
|
||||||
)
|
|
||||||
|> assign(
|
|
||||||
:import_editor_execution_states,
|
|
||||||
Map.delete(socket.assigns.import_editor_execution_states, definition_id)
|
|
||||||
)
|
|
||||||
|> assign(
|
|
||||||
:import_editor_execution_task_refs,
|
|
||||||
Map.delete(socket.assigns.import_editor_execution_task_refs, definition_id)
|
|
||||||
)
|
|
||||||
|> assign(:import_editor_sections, Map.delete(socket.assigns.import_editor_sections, definition_id))
|
|
||||||
|> assign(
|
|
||||||
:import_editor_taxonomy_edits,
|
|
||||||
Map.delete(socket.assigns.import_editor_taxonomy_edits, definition_id)
|
|
||||||
)
|
|
||||||
|> assign(
|
|
||||||
:import_editor_model_selectors_open,
|
|
||||||
Map.delete(socket.assigns.import_editor_model_selectors_open, definition_id)
|
|
||||||
)
|
|
||||||
|> assign(
|
|
||||||
:import_editor_selected_models,
|
|
||||||
Map.delete(socket.assigns.import_editor_selected_models, definition_id)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp sidebar_delete_target(socket, route, id, fallback_title) do
|
defp sidebar_delete_target(socket, route, id, fallback_title) do
|
||||||
active_project_id = socket.assigns.projects.active_project_id
|
active_project_id = socket.assigns.projects.active_project_id
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -418,8 +418,8 @@
|
|||||||
<% @current_tab.type == :chat -> %>
|
<% @current_tab.type == :chat -> %>
|
||||||
<.live_component module={ChatEditor} id={"chat-editor-#{@current_tab.id}"} current_tab={@current_tab} offline_mode={@offline_mode} project_id={@projects.active_project_id} />
|
<.live_component module={ChatEditor} id={"chat-editor-#{@current_tab.id}"} current_tab={@current_tab} offline_mode={@offline_mode} project_id={@projects.active_project_id} />
|
||||||
|
|
||||||
<% @current_tab.type == :import and @import_editor -> %>
|
<% @current_tab.type == :import -> %>
|
||||||
<ImportEditor.import_editor import_editor={@import_editor} />
|
<.live_component module={ImportEditor} id={"import-editor-#{@current_tab.id}"} current_tab={@current_tab} offline_mode={@offline_mode} project_id={@projects.active_project_id} />
|
||||||
|
|
||||||
<% @current_tab.type in [:site_validation, :metadata_diff, :translation_validation, :find_duplicates, :git_diff] and @misc_editor -> %>
|
<% @current_tab.type in [:site_validation, :metadata_diff, :translation_validation, :find_duplicates, :git_diff] and @misc_editor -> %>
|
||||||
<MiscEditor.misc_editor misc_editor={@misc_editor} />
|
<MiscEditor.misc_editor misc_editor={@misc_editor} />
|
||||||
|
|||||||
@@ -70,11 +70,9 @@ defmodule BDS.Desktop.ImportShellLiveTest do
|
|||||||
refute html =~ "Desktop workbench content routed through the Elixir shell."
|
refute html =~ "Desktop workbench content routed through the Elixir shell."
|
||||||
|
|
||||||
_html =
|
_html =
|
||||||
render_change(view, "change_import_conflict_resolution", %{
|
view
|
||||||
"item_type" => "post",
|
|> element("form:has(input[value='conflict-me'])")
|
||||||
"item_name" => "conflict-me",
|
|> render_change(%{"resolution" => "overwrite"})
|
||||||
"resolution" => "overwrite"
|
|
||||||
})
|
|
||||||
|
|
||||||
updated_definition = ImportDefinitions.get_definition(definition.id)
|
updated_definition = ImportDefinitions.get_definition(definition.id)
|
||||||
updated_report = ImportDefinitions.decode_analysis_result(updated_definition)
|
updated_report = ImportDefinitions.decode_analysis_result(updated_definition)
|
||||||
|
|||||||
9
test/bds/desktop/shell_live/chat_editor_test.exs
Normal file
9
test/bds/desktop/shell_live/chat_editor_test.exs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
defmodule BDS.Desktop.ShellLive.ChatEditorTest do
|
||||||
|
use ExUnit.Case, async: false
|
||||||
|
|
||||||
|
test "ChatEditor exports LiveComponent callbacks" do
|
||||||
|
assert function_exported?(BDS.Desktop.ShellLive.ChatEditor, :update, 2)
|
||||||
|
assert function_exported?(BDS.Desktop.ShellLive.ChatEditor, :handle_event, 3)
|
||||||
|
assert function_exported?(BDS.Desktop.ShellLive.ChatEditor, :render, 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
11
test/bds/desktop/shell_live/import_editor_test.exs
Normal file
11
test/bds/desktop/shell_live/import_editor_test.exs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
defmodule BDS.Desktop.ShellLive.ImportEditorTest do
|
||||||
|
use ExUnit.Case, async: false
|
||||||
|
|
||||||
|
test "ImportEditor exports LiveComponent callbacks" do
|
||||||
|
module = BDS.Desktop.ShellLive.ImportEditor
|
||||||
|
assert Code.ensure_loaded?(module)
|
||||||
|
assert function_exported?(module, :update, 2)
|
||||||
|
assert function_exported?(module, :handle_event, 3)
|
||||||
|
assert function_exported?(module, :render, 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user