mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-06 11:35:54 +08:00
Secrets modal title from options (#1443)
* Secrets modal title from options * Applying suggestions
This commit is contained in:
parent
83b21dfd1e
commit
d494e58c6a
3 changed files with 24 additions and 5 deletions
|
@ -335,6 +335,7 @@ const JSView = {
|
|||
this.pushEvent("select_secret", {
|
||||
js_view_ref: this.props.ref,
|
||||
preselect_name: message.preselectName,
|
||||
options: message.options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,6 +408,7 @@ defmodule LivebookWeb.SessionLive do
|
|||
prefill_secret_name={@prefill_secret_name}
|
||||
select_secret_ref={@select_secret_ref}
|
||||
preselect_name={@preselect_name}
|
||||
select_secret_options={@select_secret_options}
|
||||
return_to={@self_path}
|
||||
/>
|
||||
</.modal>
|
||||
|
@ -759,7 +760,9 @@ defmodule LivebookWeb.SessionLive do
|
|||
assign(socket,
|
||||
prefill_secret_name: params["secret_name"],
|
||||
preselect_name: params["preselect_name"],
|
||||
select_secret_ref: if(params["preselect_name"], do: socket.assigns.select_secret_ref)
|
||||
select_secret_ref: if(params["preselect_name"], do: socket.assigns.select_secret_ref),
|
||||
select_secret_options:
|
||||
if(params["preselect_name"], do: socket.assigns.select_secret_options)
|
||||
)}
|
||||
end
|
||||
|
||||
|
@ -1122,10 +1125,18 @@ defmodule LivebookWeb.SessionLive do
|
|||
|
||||
def handle_event(
|
||||
"select_secret",
|
||||
%{"js_view_ref" => select_secret_ref, "preselect_name" => preselect_name},
|
||||
%{
|
||||
"js_view_ref" => select_secret_ref,
|
||||
"preselect_name" => preselect_name,
|
||||
"options" => select_secret_options
|
||||
},
|
||||
socket
|
||||
) do
|
||||
socket = assign(socket, select_secret_ref: select_secret_ref)
|
||||
socket =
|
||||
assign(socket,
|
||||
select_secret_ref: select_secret_ref,
|
||||
select_secret_options: select_secret_options
|
||||
)
|
||||
|
||||
{:noreply,
|
||||
push_patch(socket,
|
||||
|
|
|
@ -9,7 +9,10 @@ defmodule LivebookWeb.SessionLive.SecretsComponent do
|
|||
if socket.assigns[:data] do
|
||||
socket
|
||||
else
|
||||
assign(socket, data: %{"name" => prefill_secret_name(socket), "value" => ""})
|
||||
assign(socket,
|
||||
data: %{"name" => prefill_secret_name(socket), "value" => ""},
|
||||
title: title(socket)
|
||||
)
|
||||
end
|
||||
|
||||
{:ok, socket}
|
||||
|
@ -20,7 +23,7 @@ defmodule LivebookWeb.SessionLive.SecretsComponent do
|
|||
~H"""
|
||||
<div class="p-6 max-w-4xl flex flex-col space-y-5">
|
||||
<h3 class="text-2xl font-semibold text-gray-800">
|
||||
Add secret
|
||||
<%= @title %>
|
||||
</h3>
|
||||
<div class="flex flex-columns gap-4">
|
||||
<%= if @select_secret_ref do %>
|
||||
|
@ -176,4 +179,8 @@ defmodule LivebookWeb.SessionLive.SecretsComponent do
|
|||
defp unavailable_secret?(preselect_name, secrets) do
|
||||
preselect_name not in Enum.map(secrets, & &1.name)
|
||||
end
|
||||
|
||||
defp title(%{assigns: %{select_secret_ref: nil}}), do: "Add secret"
|
||||
defp title(%{assigns: %{select_secret_options: %{"title" => title}}}), do: title
|
||||
defp title(_), do: "Select secret"
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue