mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-10 17:15:09 +08:00
Add link pointing to a new notebook (#347)
* Add link pointing to a new notebook * Add test
This commit is contained in:
parent
66e2c14ab7
commit
adb9612fbe
4 changed files with 15 additions and 2 deletions
|
@ -695,7 +695,7 @@ Now we have everything we need to connect across notebooks.
|
|||
|
||||
### Notebook connections
|
||||
|
||||
In order to connect across notebooks, open up a new empty notebook
|
||||
In order to connect across notebooks, open up [a new empty notebook](/explore/notebooks/new)
|
||||
in a separate tab, copy and paste the code below to this new notebook,
|
||||
and execute it:
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ inside it. This will also give you a better idea of how you can
|
|||
inspect a remote node in general.
|
||||
|
||||
The first thing we need is a separate Elixir node. For this example,
|
||||
you can do so by opening up a new notebook, since Livebook
|
||||
you can do so by opening up [a new notebook](/explore/notebooks/new), since Livebook
|
||||
automatically starts each notebook as a remote node.
|
||||
|
||||
In practice, you may want to start an existing Elixir system,
|
||||
|
|
|
@ -91,6 +91,10 @@ defmodule LivebookWeb.ExploreLive do
|
|||
end
|
||||
|
||||
@impl true
|
||||
def handle_params(%{"slug" => "new"}, _url, socket) do
|
||||
{:noreply, create_session(socket)}
|
||||
end
|
||||
|
||||
def handle_params(%{"slug" => slug}, _url, socket) do
|
||||
{notebook, images} = Explore.notebook_by_slug!(slug)
|
||||
{:noreply, create_session(socket, notebook: notebook, images: images)}
|
||||
|
|
|
@ -16,4 +16,13 @@ defmodule LivebookWeb.ExploreLiveTest do
|
|||
{:ok, view, _} = live(conn, to)
|
||||
assert render(view) =~ "Welcome to Livebook"
|
||||
end
|
||||
|
||||
test "link to a new notebook creates an empty session", %{conn: conn} do
|
||||
{:ok, view, _} =
|
||||
conn
|
||||
|> live("/explore/notebooks/new")
|
||||
|> follow_redirect(conn)
|
||||
|
||||
assert render(view) =~ "Untitled notebook"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue