mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-30 15:27:24 +08:00
Minor improvements (#1669)
This commit is contained in:
parent
d70764517f
commit
dd2b7fa0e6
10 changed files with 36 additions and 17 deletions
|
|
@ -110,8 +110,8 @@ defmodule Livebook.Hubs do
|
|||
|
||||
* `:hub_connected`
|
||||
* `:hub_disconnected`
|
||||
* `{:connection_error, reason}`
|
||||
* `{:disconnection_error, reason}`
|
||||
* `{:hub_connection_failed, reason}`
|
||||
* `{:hub_disconnection_failed, reason}`
|
||||
|
||||
Topic `hubs:secrets`:
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ defmodule Livebook.Hubs.Broadcasts do
|
|||
"""
|
||||
@spec hub_connection_failed(String.t()) :: broadcast()
|
||||
def hub_connection_failed(reason) when is_binary(reason) do
|
||||
broadcast(@connection_topic, {:connection_error, reason})
|
||||
broadcast(@connection_topic, {:hub_connection_failed, reason})
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
@ -46,7 +46,7 @@ defmodule Livebook.Hubs.Broadcasts do
|
|||
"""
|
||||
@spec hub_disconnection_failed(String.t()) :: broadcast()
|
||||
def hub_disconnection_failed(reason) when is_binary(reason) do
|
||||
broadcast(@connection_topic, {:disconnection_error, reason})
|
||||
broadcast(@connection_topic, {:hub_disconnection_failed, reason})
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
|
|||
|
|
@ -79,7 +79,11 @@ defmodule LivebookWeb.FormHelpers do
|
|||
<.remix_icon icon="emotion-line" class="text-xl" />
|
||||
</button>
|
||||
</div>
|
||||
<div id={"#{@id}-container"} data-emoji-container class="absolute mt-10 hidden" />
|
||||
<div
|
||||
id={"#{@id}-container"}
|
||||
data-emoji-container
|
||||
class={["absolute hidden", @container_class]}
|
||||
/>
|
||||
<%= hidden_input(@form, @field, class: "hidden emoji-picker-input", "data-emoji-input": true) %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ defmodule LivebookWeb.SidebarHook do
|
|||
{:halt, assign(socket, saved_hubs: Livebook.Hubs.get_metadatas())}
|
||||
end
|
||||
|
||||
@error_events ~w(connection_error disconnection_error)a
|
||||
@error_events ~w(hub_connection_failed hub_disconnection_failed)a
|
||||
|
||||
defp handle_info({event, _reason}, socket) when event in @error_events do
|
||||
{:halt, assign(socket, saved_hubs: Livebook.Hubs.get_metadatas())}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,12 @@ defmodule LivebookWeb.Hub.Edit.EnterpriseComponent do
|
|||
<div class="grid grid-cols-1 md:grid-cols-1 gap-3">
|
||||
<.input_wrapper form={f} field={:hub_emoji} class="flex flex-col space-y-1">
|
||||
<div class="input-label">Emoji</div>
|
||||
<.emoji_input id="enterprise-emoji-input" form={f} field={:hub_emoji} />
|
||||
<.emoji_input
|
||||
id="enterprise-emoji-input"
|
||||
form={f}
|
||||
field={:hub_emoji}
|
||||
container_class="mt-10"
|
||||
/>
|
||||
</.input_wrapper>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,12 @@ defmodule LivebookWeb.Hub.Edit.FlyComponent do
|
|||
|
||||
<.input_wrapper form={f} field={:hub_emoji} class="flex flex-col space-y-1">
|
||||
<div class="input-label">Emoji</div>
|
||||
<.emoji_input id="fly-emoji-input" form={f} field={:hub_emoji} />
|
||||
<.emoji_input
|
||||
id="fly-emoji-input"
|
||||
form={f}
|
||||
field={:hub_emoji}
|
||||
container_class="mt-10"
|
||||
/>
|
||||
</.input_wrapper>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -82,9 +82,14 @@ defmodule LivebookWeb.Hub.New.EnterpriseComponent do
|
|||
<%= text_input(f, :hub_name, class: "input", readonly: true) %>
|
||||
</.input_wrapper>
|
||||
|
||||
<.input_wrapper form={f} field={:hub_emoji} class="flex flex-col space-y-1">
|
||||
<.input_wrapper form={f} field={:hub_emoji} class="flex relative flex-col space-y-1">
|
||||
<div class="input-label">Emoji</div>
|
||||
<.emoji_input id="enterprise-emoji-input" form={f} field={:hub_emoji} />
|
||||
<.emoji_input
|
||||
id="enterprise-emoji-input"
|
||||
form={f}
|
||||
field={:hub_emoji}
|
||||
container_class="mt-10"
|
||||
/>
|
||||
</.input_wrapper>
|
||||
</div>
|
||||
|
||||
|
|
@ -116,7 +121,7 @@ defmodule LivebookWeb.Hub.New.EnterpriseComponent do
|
|||
{:ok, pid} = EnterpriseClient.start_link(base)
|
||||
|
||||
receive do
|
||||
{:connection_error, reason} ->
|
||||
{:hub_connection_failed, reason} ->
|
||||
EnterpriseClient.stop(pid)
|
||||
|
||||
{:noreply,
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ defmodule LivebookWeb.Hub.New.FlyComponent do
|
|||
<%= text_input(f, :hub_name, class: "input") %>
|
||||
</.input_wrapper>
|
||||
|
||||
<.input_wrapper form={f} field={:hub_emoji} class="flex flex-col space-y-1">
|
||||
<.input_wrapper form={f} field={:hub_emoji} class="flex relative flex-col space-y-1">
|
||||
<div class="input-label">Emoji</div>
|
||||
<.emoji_input id="fly-emoji-input" form={f} field={:hub_emoji} />
|
||||
<.emoji_input id="fly-emoji-input" form={f} field={:hub_emoji} container_class="mt-1" />
|
||||
</.input_wrapper>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -339,9 +339,9 @@ defmodule LivebookWeb.SettingsLive do
|
|||
end
|
||||
|
||||
def handle_event("save", %{"env_var" => attrs}, socket) do
|
||||
env_var = %Livebook.Settings.EnvVar{}
|
||||
env_var = socket.assigns.env_var || %Livebook.Settings.EnvVar{}
|
||||
|
||||
case Livebook.Settings.set_env_var(socket.assigns.env_var || env_var, attrs) do
|
||||
case Livebook.Settings.set_env_var(env_var, attrs) do
|
||||
{:ok, _} ->
|
||||
{:noreply, push_patch(socket, to: Routes.settings_path(socket, :page))}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ defmodule Livebook.Hubs.EnterpriseClientTest do
|
|||
enterprise = build(:enterprise, url: "http://localhost:9999", token: token)
|
||||
|
||||
EnterpriseClient.start_link(enterprise)
|
||||
assert_receive {:connection_error, "connection refused"}
|
||||
assert_receive {:hub_connection_failed, "connection refused"}
|
||||
end
|
||||
|
||||
test "rejects the web socket connection with invalid credentials", %{url: url} do
|
||||
enterprise = build(:enterprise, url: url, token: "foo")
|
||||
|
||||
EnterpriseClient.start_link(enterprise)
|
||||
assert_receive {:connection_error, reason}
|
||||
assert_receive {:hub_connection_failed, reason}
|
||||
assert reason =~ "the given token is invalid"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue