mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-27 22:06:38 +08:00
Persist show-source app option (#1859)
This commit is contained in:
parent
01bcf1fd1a
commit
f9efd2079c
4 changed files with 13 additions and 5 deletions
|
|
@ -86,7 +86,7 @@ defmodule Livebook.LiveMarkdown.Export do
|
|||
end
|
||||
|
||||
defp app_settings_metadata(app_settings) do
|
||||
keys = [:slug, :access_type]
|
||||
keys = [:slug, :access_type, :show_source]
|
||||
|
||||
put_unless_default(
|
||||
%{},
|
||||
|
|
|
|||
|
|
@ -404,6 +404,9 @@ defmodule Livebook.LiveMarkdown.Import do
|
|||
{"slug", slug}, attrs ->
|
||||
Map.put(attrs, :slug, slug)
|
||||
|
||||
{"show_source", show_source}, attrs ->
|
||||
Map.put(attrs, :show_source, show_source)
|
||||
|
||||
{"access_type", access_type}, attrs when access_type in ["public", "protected"] ->
|
||||
Map.put(attrs, :access_type, String.to_atom(access_type))
|
||||
|
||||
|
|
|
|||
|
|
@ -1146,11 +1146,16 @@ defmodule Livebook.LiveMarkdown.ExportTest do
|
|||
notebook = %{
|
||||
Notebook.new()
|
||||
| name: "My Notebook",
|
||||
app_settings: %{Notebook.AppSettings.new() | slug: "app", access_type: :public}
|
||||
app_settings: %{
|
||||
Notebook.AppSettings.new()
|
||||
| slug: "app",
|
||||
access_type: :public,
|
||||
show_source: true
|
||||
}
|
||||
}
|
||||
|
||||
expected_document = """
|
||||
<!-- livebook:{"app_settings":{"access_type":"public","slug":"app"}} -->
|
||||
<!-- livebook:{"app_settings":{"access_type":"public","show_source":true,"slug":"app"}} -->
|
||||
|
||||
# My Notebook
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -750,7 +750,7 @@ defmodule Livebook.LiveMarkdown.ImportTest do
|
|||
describe "app settings" do
|
||||
test "imports settings" do
|
||||
markdown = """
|
||||
<!-- livebook:{"app_settings":{"access_type":"public","slug":"app"}} -->
|
||||
<!-- livebook:{"app_settings":{"access_type":"public","show_source":true,"slug":"app"}} -->
|
||||
|
||||
# My Notebook
|
||||
"""
|
||||
|
|
@ -759,7 +759,7 @@ defmodule Livebook.LiveMarkdown.ImportTest do
|
|||
|
||||
assert %Notebook{
|
||||
name: "My Notebook",
|
||||
app_settings: %{slug: "app", access_type: :public}
|
||||
app_settings: %{slug: "app", access_type: :public, show_source: true}
|
||||
} = notebook
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue