diff --git a/lib/livebook/file_system.ex b/lib/livebook/file_system.ex index a65443a4f68..a72b3b74b9c 100644 --- a/lib/livebook/file_system.ex +++ b/lib/livebook/file_system.ex @@ -23,7 +23,7 @@ defprotocol Livebook.FileSystem do Path has most of the semantics of regular file paths, with the following exceptions: - * path must be be absolute for consistency + * path must be absolute for consistency * directory path must have a trailing slash, whereas regular file path must not have a trailing slash. Rationale: certain file diff --git a/lib/livebook_web/live/session_live/add_file_entry_upload_component.ex b/lib/livebook_web/live/session_live/add_file_entry_upload_component.ex index 226fb73f506..59e0bffccf6 100644 --- a/lib/livebook_web/live/session_live/add_file_entry_upload_component.ex +++ b/lib/livebook_web/live/session_live/add_file_entry_upload_component.ex @@ -1,4 +1,11 @@ defmodule LivebookWeb.SessionLive.AddFileEntryUploadComponent do + # TODO REMOVE BEFORE FLIGHT!!!!!! + """ + TODO: + - add uploaded file in a sidebar "Files/references" + - validate radio (when user forgot to choose one of options) + """ + use LivebookWeb, :live_component import Ecto.Changeset @@ -23,11 +30,11 @@ defmodule LivebookWeb.SessionLive.AddFileEntryUploadComponent do end defp changeset(attrs \\ %{}) do - data = %{name: nil} - types = %{name: :string} + data = %{name: nil, store_local?: true} + types = %{name: :string, store_local?: :boolean} - cast({data, types}, attrs, [:name]) - |> validate_required([:name]) + cast({data, types}, attrs, [:name, :store_local?]) + |> validate_required([:name, :store_local?]) |> Livebook.Notebook.validate_file_entry_name(:name) end @@ -62,6 +69,13 @@ defmodule LivebookWeb.SessionLive.AddFileEntryUploadComponent do autocomplete="off" phx-debounce="200" /> + <.radio_field + field={f[:storage_type]} + options={[ + {"local", "Store in the notebook files as an attachment"}, + {"s3", "Upload to your S3 storage and store link"} + ]} + />