fix: more cleanup of liveview
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -83,6 +83,17 @@ defmodule BDS.Desktop.ShellLive do
|
||||
{:noreply, reload_shell(socket, workbench)}
|
||||
end
|
||||
|
||||
def handle_event("close_tab", %{"type" => type, "id" => id}, socket) do
|
||||
type_atom = String.to_existing_atom(type)
|
||||
workbench = Workbench.close_tab(socket.assigns.workbench, type_atom, id)
|
||||
tab_meta = Map.delete(socket.assigns.tab_meta, {type_atom, id})
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:tab_meta, tab_meta)
|
||||
|> reload_shell(workbench)}
|
||||
end
|
||||
|
||||
def handle_event("toggle_offline_mode", _params, socket) do
|
||||
socket = assign(socket, :offline_mode, not socket.assigns.offline_mode)
|
||||
{:noreply, reload_shell(socket, socket.assigns.workbench)}
|
||||
|
||||
@@ -112,19 +112,36 @@
|
||||
<% else %>
|
||||
<div class="tab-bar-tabs">
|
||||
<%= for tab <- @workbench.tabs do %>
|
||||
<button
|
||||
<div
|
||||
class={["tab", if(@workbench.active_tab == {tab.type, tab.id}, do: "active"), if(tab.is_transient, do: "transient")]}
|
||||
data-tab-type={tab.type}
|
||||
data-tab-id={tab.id}
|
||||
type="button"
|
||||
phx-click="select_tab"
|
||||
phx-value-type={tab.type}
|
||||
phx-value-id={tab.id}
|
||||
>
|
||||
<span class="tab-icon"><%= raw(ShellData.activity_icon(tab_icon_id(tab))) %></span>
|
||||
<span class="tab-title"><%= tab_title(tab, @tab_meta) %></span>
|
||||
<span class="tab-close" aria-hidden="true">×</span>
|
||||
</button>
|
||||
<button
|
||||
class="tab-select"
|
||||
type="button"
|
||||
phx-click="select_tab"
|
||||
phx-value-type={tab.type}
|
||||
phx-value-id={tab.id}
|
||||
>
|
||||
<span class="tab-icon"><%= raw(ShellData.activity_icon(tab_icon_id(tab))) %></span>
|
||||
<span class="tab-title"><%= tab_title(tab, @tab_meta) %></span>
|
||||
</button>
|
||||
<button
|
||||
class="tab-close"
|
||||
data-testid="tab-close"
|
||||
data-tab-type={tab.type}
|
||||
data-tab-id={tab.id}
|
||||
type="button"
|
||||
phx-click="close_tab"
|
||||
phx-value-type={tab.type}
|
||||
phx-value-id={tab.id}
|
||||
aria-label={translated("Close tab")}
|
||||
title={translated("Close tab")}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user