mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-09 16:37:49 +08:00
Allow downloading source from sessions list (#980)
* Support downloading source on a per session basis * Update session_list_component.ex * Add test * Update lib/livebook_web/live/home_live/session_list_component.ex * Update test/livebook_web/live/home_live_test.exs Co-authored-by: José Valim <jose.valim@gmail.com> Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
This commit is contained in:
parent
a308a63994
commit
1a0b9e0f7d
2 changed files with 24 additions and 0 deletions
|
@ -136,6 +136,13 @@ defmodule LivebookWeb.HomeLive.SessionListComponent do
|
|||
</button>
|
||||
</:toggle>
|
||||
<:content>
|
||||
<a class="menu-item text-gray-500"
|
||||
role="menuitem"
|
||||
href={Routes.session_path(@socket, :download_source, session.id, "livemd", include_outputs: false)}
|
||||
download>
|
||||
<.remix_icon icon="download-2-line" class="text-lg"/>
|
||||
<span class="font-medium">Download source</span>
|
||||
</a>
|
||||
<button class="menu-item text-gray-500"
|
||||
type="button"
|
||||
role="menuitem"
|
||||
|
|
|
@ -136,6 +136,23 @@ defmodule LivebookWeb.HomeLiveTest do
|
|||
refute render(view) =~ id
|
||||
end
|
||||
|
||||
test "allows download the source of an existing session", %{conn: conn} do
|
||||
{:ok, session} = Sessions.create_session()
|
||||
Session.set_notebook_name(session.pid, "My notebook")
|
||||
|
||||
{:ok, view, _} = live(conn, "/")
|
||||
|
||||
{:error, {:redirect, %{to: to}}} =
|
||||
view
|
||||
|> element(~s{[data-test-session-id="#{session.id}"] a}, "Download source")
|
||||
|> render_click
|
||||
|
||||
assert to ==
|
||||
Routes.session_path(conn, :download_source, session.id, "livemd",
|
||||
include_outputs: false
|
||||
)
|
||||
end
|
||||
|
||||
test "allows forking existing session", %{conn: conn} do
|
||||
{:ok, session} = Sessions.create_session()
|
||||
Session.set_notebook_name(session.pid, "My notebook")
|
||||
|
|
Loading…
Reference in a new issue