mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-14 11:55:12 +08:00
feb0ac214e
* Fix error on back after closing session Clicking the browsers back button after closing a session resulted in an error since it was trying to close an already closed notebook * Overwrite back history on section delete
35 lines
1.2 KiB
Elixir
35 lines
1.2 KiB
Elixir
defmodule LivebookWeb.HomeLive.CloseSessionComponent do
|
|
use LivebookWeb, :live_component
|
|
|
|
@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 all content will be lost." %>
|
|
</p>
|
|
<div class="mt-8 flex justify-end space-x-2">
|
|
<button class="button-base button-red" phx-click="close" phx-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
|