migrate admin forms to inline feedback
All checks were successful
deploy / deploy (push) Successful in 1m26s
All checks were successful
deploy / deploy (push) Successful in 1m26s
Replace put_flash calls with inline feedback for form saves: - Email settings: "Now send a test email" after saving - Settings: from address and signing secret saves - Page editor: save button shows "Saved" checkmark Inline feedback appears next to save buttons and auto-clears after 3 seconds. Banners (put_flash) remain for page-level outcomes like deletions, state changes, and async operations. Task 3 of notification overhaul. Theme editor skipped as it auto-saves. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,8 @@ defmodule BerrypodWeb.Admin.Settings do
|
||||
|> assign(:site_live, Settings.site_live?())
|
||||
|> assign(:cart_recovery_enabled, Settings.abandoned_cart_recovery_enabled?())
|
||||
|> assign(:from_address, Settings.get_setting("email_from_address") || user.email)
|
||||
|> assign(:from_address_status, :idle)
|
||||
|> assign(:signing_secret_status, :idle)
|
||||
|> assign_stripe_state()
|
||||
|> assign_products_state()
|
||||
|> assign_account_state(user)}
|
||||
@@ -116,11 +118,12 @@ defmodule BerrypodWeb.Admin.Settings do
|
||||
|
||||
if address != "" do
|
||||
Settings.put_setting("email_from_address", address)
|
||||
Process.send_after(self(), :clear_from_address_status, 3000)
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:from_address, address)
|
||||
|> put_flash(:info, "From address saved")}
|
||||
|> assign(:from_address_status, :saved)}
|
||||
else
|
||||
{:noreply, put_flash(socket, :error, "From address can't be blank")}
|
||||
end
|
||||
@@ -181,11 +184,12 @@ defmodule BerrypodWeb.Admin.Settings do
|
||||
{:noreply, put_flash(socket, :error, "Please enter a signing secret")}
|
||||
else
|
||||
StripeSetup.save_signing_secret(secret)
|
||||
Process.send_after(self(), :clear_signing_secret_status, 3000)
|
||||
|
||||
socket =
|
||||
socket
|
||||
|> assign_stripe_state()
|
||||
|> put_flash(:info, "Webhook signing secret saved")
|
||||
|> assign(:signing_secret_status, :saved)
|
||||
|
||||
{:noreply, socket}
|
||||
end
|
||||
@@ -289,6 +293,17 @@ defmodule BerrypodWeb.Admin.Settings do
|
||||
end
|
||||
end
|
||||
|
||||
# -- Clear status messages --
|
||||
|
||||
@impl true
|
||||
def handle_info(:clear_from_address_status, socket) do
|
||||
{:noreply, assign(socket, :from_address_status, :idle)}
|
||||
end
|
||||
|
||||
def handle_info(:clear_signing_secret_status, socket) do
|
||||
{:noreply, assign(socket, :signing_secret_status, :idle)}
|
||||
end
|
||||
|
||||
# -- Render --
|
||||
|
||||
@impl true
|
||||
@@ -364,6 +379,7 @@ defmodule BerrypodWeb.Admin.Settings do
|
||||
stripe_has_signing_secret={@stripe_has_signing_secret}
|
||||
secret_form={@secret_form}
|
||||
advanced_open={@stripe_advanced_open}
|
||||
signing_secret_status={@signing_secret_status}
|
||||
/>
|
||||
<% end %>
|
||||
</section>
|
||||
@@ -448,6 +464,7 @@ defmodule BerrypodWeb.Admin.Settings do
|
||||
placeholder="noreply@yourshop.com"
|
||||
/>
|
||||
<.button phx-disable-with="Saving...">Save</.button>
|
||||
<.inline_feedback status={@from_address_status} />
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
@@ -704,6 +721,7 @@ defmodule BerrypodWeb.Admin.Settings do
|
||||
/>
|
||||
<div class="admin-form-actions-sm">
|
||||
<.button phx-disable-with="Saving...">Save signing secret</.button>
|
||||
<.inline_feedback status={@signing_secret_status} />
|
||||
</div>
|
||||
</.form>
|
||||
<% else %>
|
||||
@@ -733,6 +751,7 @@ defmodule BerrypodWeb.Admin.Settings do
|
||||
/>
|
||||
<div class="admin-form-actions-sm">
|
||||
<.button phx-disable-with="Saving...">Save signing secret</.button>
|
||||
<.inline_feedback status={@signing_secret_status} />
|
||||
</div>
|
||||
</.form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user