Delete media items (#20)

* Added method for deleting media files and their content

* Adds controllers and methods for deleting media and files

* Improved tmpfile setup and teardown for tests

* Actually got tmpfile cleanup running once per suite run

* Finally fixed flash messages
This commit is contained in:
Kieran
2024-02-15 17:51:19 -08:00
committed by GitHub
parent 58771ee37b
commit c5fcb8fe12
17 changed files with 305 additions and 33 deletions
+31 -22
View File
@@ -112,24 +112,29 @@ defmodule PinchflatWeb.CoreComponents do
<div
:if={msg = render_slot(@inner_block) || Phoenix.Flash.get(@flash, @kind)}
id={@id}
phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("##{@id}")}
class="pb-8"
role="alert"
class={[
"fixed top-2 right-2 mr-2 w-80 sm:w-96 z-50 rounded-lg p-3 ring-1",
@kind == :info && "bg-emerald-50 text-emerald-800 ring-emerald-500 fill-cyan-900",
@kind == :error && "bg-rose-50 text-rose-900 shadow-md ring-rose-500 fill-rose-900"
]}
{@rest}
>
<p :if={@title} class="flex items-center gap-1.5 text-sm font-semibold leading-6">
<.icon :if={@kind == :info} name="hero-information-circle-mini" class="h-4 w-4" />
<.icon :if={@kind == :error} name="hero-exclamation-circle-mini" class="h-4 w-4" />
<%= @title %>
</p>
<p class="mt-2 text-sm leading-5"><%= msg %></p>
<button type="button" class="group absolute top-1 right-1 p-2" aria-label={gettext("close")}>
<.icon name="hero-x-mark-solid" class="h-5 w-5 opacity-40 group-hover:opacity-70" />
</button>
<div class={[
"flex justify-between w-full border-l-6 bg-opacity-[50%] p-5 shadow-md dark:bg-opacity-40 dark:text-white",
@kind == :info && "border-[#34D399] bg-[#34D399]",
@kind == :error && "border-[#F87171] bg-[#F87171]"
]}>
<main>
<h5 :if={@title} class="mb-2 text-lg font-bold">
<%= @title %>
</h5>
<p class="mt-2 text-md leading-5 opacity-80"><%= msg %></p>
</main>
<button
type="button"
aria-label={gettext("close")}
phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("##{@id}")}
>
<.icon name="hero-x-mark-solid" class="h-7 w-7 opacity-70 hover:opacity-100" />
</button>
</div>
</div>
"""
end
@@ -146,7 +151,7 @@ defmodule PinchflatWeb.CoreComponents do
def flash_group(assigns) do
~H"""
<div id={@id}>
<div class="flex flex-col gap-7.5" id={@id}>
<.flash kind={:info} title="Success!" flash={@flash} />
<.flash kind={:error} title="Error!" flash={@flash} />
<.flash
@@ -632,9 +637,11 @@ defmodule PinchflatWeb.CoreComponents do
def show(js \\ %JS{}, selector) do
JS.show(js,
to: selector,
transition:
{"transition-all transform ease-out duration-300", "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
"opacity-100 translate-y-0 sm:scale-100"}
transition: {
"transition-all transform ease-out duration-300",
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
"opacity-100 translate-y-0 sm:scale-100"
}
)
end
@@ -642,9 +649,11 @@ defmodule PinchflatWeb.CoreComponents do
JS.hide(js,
to: selector,
time: 200,
transition:
{"transition-all transform ease-in duration-200", "opacity-100 translate-y-0 sm:scale-100",
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"}
transition: {
"transition-all transform ease-in duration-200",
"opacity-100 translate-y-0 sm:scale-100",
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
}
)
end