Add link pointing to a new notebook (#347)

* Add link pointing to a new notebook

* Add test
This commit is contained in:
Jonatan Kłosko 2021-06-14 21:25:18 +02:00 committed by GitHub
parent 66e2c14ab7
commit adb9612fbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View file

@ -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:

View file

@ -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,

View file

@ -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)}

View file

@ -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