mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-17 00:46:14 +08:00
Close runtime modal once connecting succeeds (#2736)
This commit is contained in:
parent
0118ae8ebd
commit
b9306ce5da
4 changed files with 16 additions and 1 deletions
|
@ -1053,6 +1053,10 @@ defmodule LivebookWeb.SessionLive do
|
|||
{:noreply, put_flash(socket, kind, message)}
|
||||
end
|
||||
|
||||
def handle_info({:push_patch, to}, socket) do
|
||||
{:noreply, push_patch(socket, to: to)}
|
||||
end
|
||||
|
||||
def handle_info({:starred_notebooks_updated, starred_notebooks}, socket) do
|
||||
{:noreply, assign(socket, starred_files: starred_files(starred_notebooks))}
|
||||
end
|
||||
|
|
|
@ -60,6 +60,7 @@ defmodule LivebookWeb.SessionLive.Render do
|
|||
module={LivebookWeb.SessionLive.RuntimeComponent}
|
||||
id="runtime-settings"
|
||||
session={@session}
|
||||
return_to={@self_path}
|
||||
runtime={@data_view.runtime}
|
||||
runtime_status={@data_view.runtime_status}
|
||||
runtime_connect_info={@data_view.runtime_connect_info}
|
||||
|
|
|
@ -14,6 +14,12 @@ defmodule LivebookWeb.SessionLive.RuntimeComponent do
|
|||
end
|
||||
|
||||
def update(assigns, socket) do
|
||||
with %{runtime_status: :connecting} <- socket.assigns,
|
||||
%{runtime_status: :connected} <- assigns,
|
||||
true <- socket.assigns.type == runtime_type(assigns.runtime) do
|
||||
send(self(), {:push_patch, socket.assigns.return_to})
|
||||
end
|
||||
|
||||
socket =
|
||||
socket
|
||||
|> assign(assigns)
|
||||
|
|
|
@ -913,8 +913,12 @@ defmodule LivebookWeb.SessionLiveTest do
|
|||
assert_receive {:operation, {:set_runtime, _pid, %Runtime.Standalone{}}}
|
||||
assert_receive {:operation, {:runtime_connected, _pid, %Runtime.Standalone{} = runtime}}
|
||||
|
||||
assert_patch(view, "/sessions/#{session.id}")
|
||||
assert render(view) =~ Atom.to_string(runtime.node)
|
||||
|
||||
{:ok, view, _} = live(conn, ~p"/sessions/#{session.id}/settings/runtime")
|
||||
|
||||
page = render(view)
|
||||
assert page =~ Atom.to_string(runtime.node)
|
||||
assert page =~ "Reconnect"
|
||||
assert page =~ "Disconnect"
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue