mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-11-11 14:42:39 +08:00
Pass only the Livebook PID to child LiveViews (#2081)
This commit is contained in:
parent
319ce562cb
commit
82909f7f35
6 changed files with 25 additions and 7 deletions
|
|
@ -554,7 +554,7 @@ defmodule LivebookWeb.SessionLive do
|
||||||
<%= live_render(@socket, LivebookWeb.SessionLive.PackageSearchLive,
|
<%= live_render(@socket, LivebookWeb.SessionLive.PackageSearchLive,
|
||||||
id: "package-search",
|
id: "package-search",
|
||||||
session: %{
|
session: %{
|
||||||
"session" => @session,
|
"session_pid" => @session.pid,
|
||||||
"runtime" => @data_view.runtime,
|
"runtime" => @data_view.runtime,
|
||||||
"return_to" => @self_path
|
"return_to" => @self_path
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,13 @@ defmodule LivebookWeb.SessionLive.AttachedLive do
|
||||||
alias Livebook.{Session, Runtime}
|
alias Livebook.{Session, Runtime}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(_params, %{"session" => session, "current_runtime" => current_runtime}, socket) do
|
def mount(
|
||||||
|
_params,
|
||||||
|
%{"session_pid" => session_pid, "current_runtime" => current_runtime},
|
||||||
|
socket
|
||||||
|
) do
|
||||||
|
session = Session.get_by_pid(session_pid)
|
||||||
|
|
||||||
unless Livebook.Config.runtime_enabled?(Livebook.Runtime.Attached) do
|
unless Livebook.Config.runtime_enabled?(Livebook.Runtime.Attached) do
|
||||||
raise "runtime module not allowed"
|
raise "runtime module not allowed"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,13 @@ defmodule LivebookWeb.SessionLive.ElixirStandaloneLive do
|
||||||
alias Livebook.{Session, Runtime}
|
alias Livebook.{Session, Runtime}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(_params, %{"session" => session, "current_runtime" => current_runtime}, socket) do
|
def mount(
|
||||||
|
_params,
|
||||||
|
%{"session_pid" => session_pid, "current_runtime" => current_runtime},
|
||||||
|
socket
|
||||||
|
) do
|
||||||
|
session = Session.get_by_pid(session_pid)
|
||||||
|
|
||||||
unless Livebook.Config.runtime_enabled?(Livebook.Runtime.ElixirStandalone) do
|
unless Livebook.Config.runtime_enabled?(Livebook.Runtime.ElixirStandalone) do
|
||||||
raise "runtime module not allowed"
|
raise "runtime module not allowed"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,13 @@ defmodule LivebookWeb.SessionLive.EmbeddedLive do
|
||||||
alias Livebook.{Session, Runtime}
|
alias Livebook.{Session, Runtime}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(_params, %{"session" => session, "current_runtime" => current_runtime}, socket) do
|
def mount(
|
||||||
|
_params,
|
||||||
|
%{"session_pid" => session_pid, "current_runtime" => current_runtime},
|
||||||
|
socket
|
||||||
|
) do
|
||||||
|
session = Session.get_by_pid(session_pid)
|
||||||
|
|
||||||
unless Livebook.Config.runtime_enabled?(Livebook.Runtime.Embedded) do
|
unless Livebook.Config.runtime_enabled?(Livebook.Runtime.Embedded) do
|
||||||
raise "runtime module not allowed"
|
raise "runtime module not allowed"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,12 @@ defmodule LivebookWeb.SessionLive.PackageSearchLive do
|
||||||
@impl true
|
@impl true
|
||||||
def mount(
|
def mount(
|
||||||
_params,
|
_params,
|
||||||
%{"session" => session, "runtime" => runtime, "return_to" => return_to},
|
%{"session_pid" => session_pid, "runtime" => runtime, "return_to" => return_to},
|
||||||
socket
|
socket
|
||||||
) do
|
) do
|
||||||
socket =
|
socket =
|
||||||
assign(socket,
|
assign(socket,
|
||||||
session: session,
|
session: Livebook.Session.get_by_pid(session_pid),
|
||||||
runtime: runtime,
|
runtime: runtime,
|
||||||
return_to: return_to,
|
return_to: return_to,
|
||||||
search: "",
|
search: "",
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ defmodule LivebookWeb.SessionLive.RuntimeComponent do
|
||||||
<div>
|
<div>
|
||||||
<%= live_render(@socket, live_view_for_type(@type),
|
<%= live_render(@socket, live_view_for_type(@type),
|
||||||
id: "runtime-config-#{@type}",
|
id: "runtime-config-#{@type}",
|
||||||
session: %{"session" => @session, "current_runtime" => @runtime}
|
session: %{"session_pid" => @session.pid, "current_runtime" => @runtime}
|
||||||
) %>
|
) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue