defmodule LivebookWeb.SettingsLive.EnvVarsComponent do use LivebookWeb, :live_component alias Livebook.Settings @impl true def render(assigns) do ~H"""
<%= for env_var <- @env_vars do %>
<.env_var_info socket={@socket} env_var={env_var} myself={@myself} />
<% end %>
<%= live_patch("Add environment variable", to: Routes.settings_path(@socket, :add_env_var), class: "button-base button-blue" ) %>
""" end defp env_var_info(assigns) do ~H"""
<.labeled_text label="Key"> <%= @env_var.key %>
<.menu id={"env-var-#{@env_var.key}-menu"}> <:toggle> <:content>
""" end @impl true def handle_event("edit_env_var", %{"env_var" => key}, socket) do {:noreply, push_patch(socket, to: Routes.settings_path(socket, :edit_env_var, key))} end def handle_event("delete_env_var", %{"env_var" => key}, socket) do Settings.delete_env_var(key) {:noreply, socket} end end