mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-16 12:57:32 +08:00
4dd28388a5
* Initial implementation to close multiple sessions * Sessions: bulk actions with components * Rename Disconnect sessions to Disconnect runtime * Select all and disabled when nothing is selected * Styled checkbox * Renames toggle events * Warning about not persisted notebooks * Adds disconnect runtime option for a single session * Edit sessions on right * Fix: typos and plural * Minor adjustments * Removes the loop for rendering the menu * Menus with fixed width * Minor adjustments * Pluralize as global helper * Bulk actions form on client side * Track bulk actions buttons state * Fix: home live tests * Doctests for pluralize * Fix: bulk actions buttons losing state on session update * Fix: format * Minor adjustment on toggle_edit * Review-based adjustments * Reset the Edit state after single-session actions * Minor adjustments * Fixes bulk action events * Submit the bulk action form directly * Tests for bulk actions * Indentation * Update lib/livebook_web/live/home_live/close_session_component.ex Co-authored-by: José Valim <jose.valim@gmail.com> Co-authored-by: José Valim <jose.valim@gmail.com>
38 lines
1.3 KiB
Elixir
38 lines
1.3 KiB
Elixir
defmodule LivebookWeb.HomeLive.CloseSessionComponent do
|
|
use LivebookWeb, :live_component
|
|
|
|
import LivebookWeb.HomeLive.SessionListComponent, only: [toggle_edit: 1]
|
|
|
|
@impl true
|
|
def render(assigns) do
|
|
~H"""
|
|
<div class="p-6 pb-4 flex flex-col space-y-8">
|
|
<h3 class="text-2xl font-semibold text-gray-800">
|
|
Close session
|
|
</h3>
|
|
<p class="text-gray-700">
|
|
Are you sure you want to close this section -
|
|
<span class="font-semibold">“<%= @session.notebook_name %>”</span>?
|
|
<br/>
|
|
<%= if @session.file,
|
|
do: "This won't delete any persisted files.",
|
|
else: "The notebook is not persisted and content may be lost." %>
|
|
</p>
|
|
<div class="mt-8 flex justify-end space-x-2">
|
|
<button class="button-base button-red" role="button"
|
|
phx-click={toggle_edit(:off) |> JS.push("close", target: @myself)}>
|
|
<.remix_icon icon="close-circle-line" class="align-middle mr-1" />
|
|
Close session
|
|
</button>
|
|
<%= live_patch "Cancel", to: @return_to, class: "button-base button-outlined-gray" %>
|
|
</div>
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
@impl true
|
|
def handle_event("close", %{}, socket) do
|
|
Livebook.Session.close(socket.assigns.session.pid)
|
|
{:noreply, push_patch(socket, to: socket.assigns.return_to, replace: true)}
|
|
end
|
|
end
|