mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-11-09 21:51:42 +08:00
Update persistence and app forms (#1840)
This commit is contained in:
parent
a98fce7e92
commit
2e12b74603
3 changed files with 37 additions and 24 deletions
|
|
@ -91,6 +91,7 @@ defmodule LivebookWeb.FormComponents do
|
||||||
attr :value, :any
|
attr :value, :any
|
||||||
attr :errors, :list, default: []
|
attr :errors, :list, default: []
|
||||||
attr :field, Phoenix.HTML.FormField, doc: "a form field struct retrieved from the form"
|
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)
|
attr :rest, :global, include: ~w(autocomplete readonly disabled)
|
||||||
|
|
||||||
|
|
@ -105,7 +106,7 @@ defmodule LivebookWeb.FormComponents do
|
||||||
name={@name}
|
name={@name}
|
||||||
id={@id || @name}
|
id={@id || @name}
|
||||||
value={Phoenix.HTML.Form.normalize_value("text", @value)}
|
value={Phoenix.HTML.Form.normalize_value("text", @value)}
|
||||||
class="input pr-8"
|
class={["input pr-8", @class]}
|
||||||
{@rest}
|
{@rest}
|
||||||
/>
|
/>
|
||||||
</.with_password_toggle>
|
</.with_password_toggle>
|
||||||
|
|
@ -249,7 +250,7 @@ defmodule LivebookWeb.FormComponents do
|
||||||
checked={to_string(@value) == @checked_value}
|
checked={to_string(@value) == @checked_value}
|
||||||
{@rest}
|
{@rest}
|
||||||
/>
|
/>
|
||||||
<span :if={@label}><%= @label %></span>
|
<span :if={@label} class="text-gray-700"><%= @label %></span>
|
||||||
</label>
|
</label>
|
||||||
<.error :for={msg <- @errors}><%= msg %></.error>
|
<.error :for={msg <- @errors}><%= msg %></.error>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,13 @@ defmodule LivebookWeb.SessionLive.AppInfoComponent do
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col space-y-4">
|
<div class="flex flex-col space-y-4">
|
||||||
<.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"
|
||||||
|
/>
|
||||||
<div class="flex flex-col space-y-1">
|
<div class="flex flex-col space-y-1">
|
||||||
<.checkbox_field
|
<.checkbox_field
|
||||||
field={f[:access_type]}
|
field={f[:access_type]}
|
||||||
|
|
@ -79,7 +85,12 @@ defmodule LivebookWeb.SessionLive.AppInfoComponent do
|
||||||
unchecked_value="public"
|
unchecked_value="public"
|
||||||
/>
|
/>
|
||||||
<%= if Ecto.Changeset.get_field(@changeset, :access_type) == :protected do %>
|
<%= 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 %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<.checkbox_field field={f[:show_source]} label="Show source" />
|
<.checkbox_field field={f[:show_source]} label="Show source" />
|
||||||
|
|
|
||||||
|
|
@ -83,36 +83,37 @@ defmodule LivebookWeb.SessionLive.PersistenceComponent do
|
||||||
target={{__MODULE__, @id}}
|
target={{__MODULE__, @id}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<.label>File</.label>
|
||||||
|
<div class="whitespace-nowrap text-gray-700 leading-4">
|
||||||
|
<%= normalize_file(@draft_file).path %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<form
|
<form
|
||||||
phx-change="set_options"
|
phx-change="set_options"
|
||||||
phx-target={@myself}
|
phx-target={@myself}
|
||||||
phx-nosubmit
|
phx-nosubmit
|
||||||
class="flex flex-col space-y-4 items-start max-w-full"
|
class="flex flex-col items-start max-w-full"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col space-y-4">
|
<div class="flex flex-col space-y-6">
|
||||||
<.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"
|
name="persist_outputs"
|
||||||
label="Persist outputs"
|
label="Persist outputs"
|
||||||
value={@new_attrs.persist_outputs}
|
value={@new_attrs.persist_outputs}
|
||||||
/>
|
/>
|
||||||
<div class="flex space-x-2 items-center">
|
|
||||||
<span class="text-gray-700 whitespace-nowrap">Autosave</span>
|
|
||||||
<.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", ""}
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<span class="text-gray-700 whitespace-nowrap pt-2">
|
|
||||||
File: <%= normalize_file(@draft_file).path %>
|
|
||||||
</span>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue