prevent double-click on create backup button
Some checks failed
deploy / deploy (push) Failing after 6m10s
Some checks failed
deploy / deploy (push) Failing after 6m10s
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2af30acb6a
commit
f47a4b90c7
@ -40,18 +40,25 @@ defmodule BerrypodWeb.Admin.Backup do
|
||||
end
|
||||
|
||||
def handle_event("create_backup", _params, socket) do
|
||||
case Backup.create_backup() do
|
||||
{:ok, _path} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:backups, Backup.list_backups())
|
||||
|> assign(:create_backup_status, :saved)}
|
||||
# Ignore if already creating
|
||||
if socket.assigns.create_backup_status == :saving do
|
||||
{:noreply, socket}
|
||||
else
|
||||
socket = assign(socket, :create_backup_status, :saving)
|
||||
|
||||
{:error, error} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:create_backup_status, :error)
|
||||
|> put_flash(:error, "Failed to create backup: #{inspect(error)}")}
|
||||
case Backup.create_backup() do
|
||||
{:ok, _path} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:backups, Backup.list_backups())
|
||||
|> assign(:create_backup_status, :saved)}
|
||||
|
||||
{:error, error} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:create_backup_status, :error)
|
||||
|> put_flash(:error, "Failed to create backup: #{inspect(error)}")}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -323,6 +330,7 @@ defmodule BerrypodWeb.Admin.Backup do
|
||||
type="button"
|
||||
phx-click="create_backup"
|
||||
class="admin-btn admin-btn-primary admin-btn-sm"
|
||||
disabled={@create_backup_status == :saving}
|
||||
>
|
||||
<.icon name="hero-plus-mini" class="size-4" /> Create backup
|
||||
</button>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user