defmodule LivebookWeb.Hub.Edit.PersonalComponent do use LivebookWeb, :live_component alias Livebook.Hubs alias Livebook.Hubs.Personal alias LivebookWeb.LayoutHelpers alias LivebookWeb.NotFoundError @impl true def update(assigns, socket) do socket = assign(socket, assigns) changeset = Personal.change_hub(assigns.hub) secrets = Hubs.get_secrets(assigns.hub) file_systems = Hubs.get_file_systems(assigns.hub, hub_only: true) secret_name = assigns.params["secret_name"] file_system_id = assigns.params["file_system_id"] secret_value = if assigns.live_action == :edit_secret do Enum.find_value(secrets, &(&1.name == secret_name and &1.value)) || raise(NotFoundError, "could not find secret matching #{inspect(secret_name)}") end file_system = if assigns.live_action == :edit_file_system do Enum.find_value(file_systems, &(&1.id == file_system_id && &1)) || raise(NotFoundError, "could not find file system matching #{inspect(file_system_id)}") end {:ok, assign(socket, secrets: secrets, file_system: file_system, file_system_id: file_system_id, file_systems: file_systems, changeset: changeset, stamp_changeset: changeset, secret_name: secret_name, secret_value: secret_value )} end @impl true def render(assigns) do ~H"""
Your personal hub. All data is stored on your machine and only you can access it.
Secrets are a safe way to share credentials and tokens with notebooks.
They are often used by Smart cells and can be read as
environment variables using the LB_ prefix.
File storages are used to store notebooks and their files.
<.live_component module={LivebookWeb.Hub.FileSystemListComponent} id="hub-file-systems-list" hub_id={@hub.id} file_systems={@file_systems} />Notebooks may be stamped using your secret key. A stamp allows to securely store information such as the names of the secrets that you granted access to. You must not share your secret key with others. But you may copy the secret key between different machines you own.
If you change the secret key, you will need to grant access to secrets once again in previously stamped notebooks.
<.form :let={f} id={"#{@id}-stamp"} class="flex flex-col mt-4 space-y-4" for={@stamp_changeset} phx-submit="stamp_save" phx-change="stamp_validate" phx-target={@myself} >