Adds Livebook Teams URL and some touch ups (#2120)

This commit is contained in:
Alexandre de Souza 2023-07-28 16:40:18 -03:00 committed by GitHub
parent 5ac14c18bb
commit 6ba0118c2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 10 deletions

View file

@ -25,7 +25,7 @@ config :mime, :types, %{
config :plug_cowboy, :log_exceptions_with_status_code, [407..599]
config :livebook,
teams_url: "http://localhost:4100",
teams_url: "https://teams.livebook.dev",
app_service_name: nil,
app_service_url: nil,
authentication_mode: :token,

View file

@ -70,6 +70,7 @@ defmodule Livebook.Hubs.TeamClient do
derived_keys = Teams.derive_keys(team.teams_key)
headers = [
{"x-lb-version", to_string(Application.spec(:livebook, :vsn))},
{"x-user", to_string(team.user_id)},
{"x-org", to_string(team.org_id)},
{"x-org-key", to_string(team.org_key_id)},

View file

@ -12,6 +12,8 @@ defmodule Livebook.Teams.Connection do
@no_state :no_state
@loop_ping_delay 5_000
@websocket_messages [:ssl, :tcp, :ssl_closed, :tcp_closed, :ssl_error, :tcp_error]
defstruct [:listener, :headers, :http_conn, :websocket, :ref]
@doc """
@ -79,11 +81,8 @@ defmodule Livebook.Teams.Connection do
:keep_state_and_data
end
def handle_event(:info, {:tcp_closed, _port} = message, @no_state, %__MODULE__{} = data) do
handle_websocket_message(message, data)
end
def handle_event(:info, {:tcp, _port, _data} = message, @no_state, %__MODULE__{} = data) do
def handle_event(:info, message, @no_state, %__MODULE__{} = data)
when elem(message, 0) in @websocket_messages do
handle_websocket_message(message, data)
end

View file

@ -88,7 +88,11 @@ defmodule Livebook.Teams.Requests do
defp auth_headers(team) do
token = "#{team.user_id}:#{team.org_id}:#{team.org_key_id}:#{team.session_token}"
[{"authorization", "Bearer " <> token}]
[
{"x-lb-version", to_string(Application.spec(:livebook, :vsn))},
{"authorization", "Bearer " <> token}
]
end
defp post(path, json, headers \\ []) do

View file

@ -158,7 +158,7 @@ defmodule LivebookWeb.Hub.Edit.TeamComponent do
language="dockerfile"
/>
<ol class="text-gray-700">
<ol class="text-gray-700 mt-4 space-y-2 list-disc list-inside">
<li>
You must change <code>/path/to/my/notebooks</code> in the template above
to point to a directory with the `.livemd` files you want to deploy

View file

@ -86,7 +86,7 @@ defmodule LivebookWeb.Hub.SecretFormComponent do
|> push_redirect(to: socket.assigns.return_to)}
else
{:error, changeset} ->
{:noreply, assign(socket, changeset: changeset)}
{:noreply, assign(socket, changeset: Map.replace!(changeset, :action, :validate))}
{:transport_error, error} ->
{:noreply,
@ -100,7 +100,7 @@ defmodule LivebookWeb.Hub.SecretFormComponent do
changeset =
%Secret{}
|> Secrets.change_secret(attrs)
|> Map.put(:action, :validate)
|> Map.replace!(:action, :validate)
{:noreply, assign(socket, changeset: changeset)}
end