From 2e12b7460316d70abad2e8488ead336b1d293f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Wed, 29 Mar 2023 20:07:37 +0100 Subject: [PATCH] Update persistence and app forms (#1840) --- .../components/form_components.ex | 5 ++- .../live/session_live/app_info_component.ex | 15 ++++++- .../session_live/persistence_component.ex | 41 ++++++++++--------- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/lib/livebook_web/components/form_components.ex b/lib/livebook_web/components/form_components.ex index faa170b70..8b14f0d3f 100644 --- a/lib/livebook_web/components/form_components.ex +++ b/lib/livebook_web/components/form_components.ex @@ -91,6 +91,7 @@ defmodule LivebookWeb.FormComponents do attr :value, :any attr :errors, :list, default: [] attr :field, Phoenix.HTML.FormField, doc: "a form field struct retrieved from the form" + attr :class, :string, default: nil attr :rest, :global, include: ~w(autocomplete readonly disabled) @@ -105,7 +106,7 @@ defmodule LivebookWeb.FormComponents do name={@name} id={@id || @name} value={Phoenix.HTML.Form.normalize_value("text", @value)} - class="input pr-8" + class={["input pr-8", @class]} {@rest} /> @@ -249,7 +250,7 @@ defmodule LivebookWeb.FormComponents do checked={to_string(@value) == @checked_value} {@rest} /> - <%= @label %> + <%= @label %> <.error :for={msg <- @errors}><%= msg %> diff --git a/lib/livebook_web/live/session_live/app_info_component.ex b/lib/livebook_web/live/session_live/app_info_component.ex index 7407e3324..eed8bd63a 100644 --- a/lib/livebook_web/live/session_live/app_info_component.ex +++ b/lib/livebook_web/live/session_live/app_info_component.ex @@ -70,7 +70,13 @@ defmodule LivebookWeb.SessionLive.AppInfoComponent do autocomplete="off" >
- <.text_field field={f[:slug]} label="Slug" spellcheck="false" phx-debounce /> + <.text_field + field={f[:slug]} + label="Slug" + spellcheck="false" + phx-debounce + class="bg-gray-100" + />
<.checkbox_field field={f[:access_type]} @@ -79,7 +85,12 @@ defmodule LivebookWeb.SessionLive.AppInfoComponent do unchecked_value="public" /> <%= if Ecto.Changeset.get_field(@changeset, :access_type) == :protected do %> - <.password_field field={f[:password]} spellcheck="false" phx-debounce /> + <.password_field + field={f[:password]} + spellcheck="false" + phx-debounce + class="bg-gray-100" + /> <% end %>
<.checkbox_field field={f[:show_source]} label="Show source" /> diff --git a/lib/livebook_web/live/session_live/persistence_component.ex b/lib/livebook_web/live/session_live/persistence_component.ex index 7f3e7d8b0..926726694 100644 --- a/lib/livebook_web/live/session_live/persistence_component.ex +++ b/lib/livebook_web/live/session_live/persistence_component.ex @@ -83,36 +83,37 @@ defmodule LivebookWeb.SessionLive.PersistenceComponent do target={{__MODULE__, @id}} />
+
+ <.label>File +
+ <%= normalize_file(@draft_file).path %> +
+
-
- <.switch_field +
+ <.select_field + name="autosave_interval_s" + label="Autosave" + value={@new_attrs.autosave_interval_s || ""} + options={[ + {"every 5 seconds", "5"}, + {"every 30 seconds", "30"}, + {"every minute", "60"}, + {"every 10 minutes", "600"}, + {"never", ""} + ]} + /> + <.checkbox_field name="persist_outputs" label="Persist outputs" value={@new_attrs.persist_outputs} /> -
- Autosave - <.select_field - name="autosave_interval_s" - value={@new_attrs.autosave_interval_s || ""} - options={[ - {"every 5 seconds", "5"}, - {"every 30 seconds", "30"}, - {"every minute", "60"}, - {"every 10 minutes", "600"}, - {"never", ""} - ]} - /> -
- - File: <%= normalize_file(@draft_file).path %> -