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
|
end
|
||||||
|
|
||||||
def handle_event("create_backup", _params, socket) do
|
def handle_event("create_backup", _params, socket) do
|
||||||
case Backup.create_backup() do
|
# Ignore if already creating
|
||||||
{:ok, _path} ->
|
if socket.assigns.create_backup_status == :saving do
|
||||||
{:noreply,
|
{:noreply, socket}
|
||||||
socket
|
else
|
||||||
|> assign(:backups, Backup.list_backups())
|
socket = assign(socket, :create_backup_status, :saving)
|
||||||
|> assign(:create_backup_status, :saved)}
|
|
||||||
|
|
||||||
{:error, error} ->
|
case Backup.create_backup() do
|
||||||
{:noreply,
|
{:ok, _path} ->
|
||||||
socket
|
{:noreply,
|
||||||
|> assign(:create_backup_status, :error)
|
socket
|
||||||
|> put_flash(:error, "Failed to create backup: #{inspect(error)}")}
|
|> 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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -323,6 +330,7 @@ defmodule BerrypodWeb.Admin.Backup do
|
|||||||
type="button"
|
type="button"
|
||||||
phx-click="create_backup"
|
phx-click="create_backup"
|
||||||
class="admin-btn admin-btn-primary admin-btn-sm"
|
class="admin-btn admin-btn-primary admin-btn-sm"
|
||||||
|
disabled={@create_backup_status == :saving}
|
||||||
>
|
>
|
||||||
<.icon name="hero-plus-mini" class="size-4" /> Create backup
|
<.icon name="hero-plus-mini" class="size-4" /> Create backup
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user