fix: make Configure button toggle - clicking again collapses the form
This commit is contained in:
parent
6e85d61101
commit
ea7d82a489
1 changed files with 25 additions and 17 deletions
|
|
@ -255,26 +255,34 @@ defmodule ToweropsWeb.Org.SettingsLive do
|
|||
|
||||
@impl true
|
||||
def handle_event("configure", %{"provider" => provider}, socket) do
|
||||
integration = Map.get(socket.assigns.integrations, provider)
|
||||
if socket.assigns.configuring == provider do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:configuring, nil)
|
||||
|> assign(:integration_form, nil)
|
||||
|> assign(:test_result, nil)}
|
||||
else
|
||||
integration = Map.get(socket.assigns.integrations, provider)
|
||||
|
||||
form =
|
||||
case integration do
|
||||
nil ->
|
||||
%Integration{}
|
||||
|> Integrations.change_integration(%{provider: provider})
|
||||
|> to_form()
|
||||
form =
|
||||
case integration do
|
||||
nil ->
|
||||
%Integration{}
|
||||
|> Integrations.change_integration(%{provider: provider})
|
||||
|> to_form()
|
||||
|
||||
existing ->
|
||||
existing
|
||||
|> Integrations.change_integration(%{})
|
||||
|> to_form()
|
||||
end
|
||||
existing ->
|
||||
existing
|
||||
|> Integrations.change_integration(%{})
|
||||
|> to_form()
|
||||
end
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:configuring, provider)
|
||||
|> assign(:integration_form, form)
|
||||
|> assign(:test_result, nil)}
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:configuring, provider)
|
||||
|> assign(:integration_form, form)
|
||||
|> assign(:test_result, nil)}
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue