Add a connection error for offline hubs (#2326)

This commit is contained in:
José Valim 2023-11-08 12:26:15 +01:00 committed by GitHub
parent 90c3cfe3a7
commit 97f64b4af4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -312,7 +312,7 @@ defmodule Livebook.Application do
Livebook.Hubs.save_hub(%Livebook.Hubs.Team{
id: "team-#{name}",
hub_name: name,
hub_emoji: "💡",
hub_emoji: "⭐️",
user_id: 0,
org_id: 0,
org_key_id: 0,

View file

@ -38,7 +38,7 @@ defmodule Livebook.Hubs.Team do
field :org_key_id, :integer
field :teams_key, :string
field :org_public_key, :string
field :session_token, :string
field :session_token, :string, redact: true
field :hub_name, :string
field :hub_emoji, :string
@ -137,8 +137,15 @@ defimpl Livebook.Hubs.Provider, for: Livebook.Hubs.Team do
def delete_secret(team, secret), do: Teams.delete_secret(team, secret)
def connection_error(team) do
if reason = TeamClient.get_connection_error(team.id) do
cond do
team.offline ->
"You are running an offline Hub for deployment. You cannot modify its settings."
reason = TeamClient.get_connection_error(team.id) ->
"Cannot connect to Hub: #{reason}.\nWill attempt to reconnect automatically..."
true ->
nil
end
end