Change routes from "/records/*" to "/collection/*"
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<%= gettext("Stats") %>
|
||||
</.link>
|
||||
<.link
|
||||
navigate={~p"/records"}
|
||||
navigate={~p"/collection"}
|
||||
class={section_link_classes(assigns[:nav_section], :records)}
|
||||
>
|
||||
<%= gettext("Collection") %>
|
||||
|
||||
@@ -96,7 +96,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
||||
|> Map.put(:query, query)
|
||||
|> Map.take([:query, :page, :page_size])
|
||||
|
||||
{:noreply, push_patch(socket, to: ~p"/records?#{qs}")}
|
||||
{:noreply, push_patch(socket, to: ~p"/collection?#{qs}")}
|
||||
end
|
||||
|
||||
def handle_event("import", %{"id" => musicbrainz_id, "format" => format}, socket) do
|
||||
@@ -110,7 +110,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, gettext("Record imported successfully"))
|
||||
|> push_navigate(to: ~p"/records/#{record.id}")}
|
||||
|> push_navigate(to: ~p"/collection/#{record.id}")}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
{:noreply, assign(socket, form: to_form(changeset))}
|
||||
@@ -119,7 +119,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:error, gettext("Error importing record") <> "," <> inspect(reason))
|
||||
|> push_patch(to: ~p"/records")}
|
||||
|> push_patch(to: ~p"/collection")}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -149,7 +149,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
||||
|> Map.take([:query, :page, :page_size])
|
||||
|> Enum.filter(fn {_, v} -> v not in ["", nil] end)
|
||||
|
||||
~p"/records?#{qs}"
|
||||
~p"/collection?#{qs}"
|
||||
end
|
||||
|
||||
defp musicbrainz_url(record) do
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
autocapitalize="none"
|
||||
/>
|
||||
</form>
|
||||
<.link patch={~p"/records/import"}>
|
||||
<.link patch={~p"/collection/import"}>
|
||||
<.button><%= gettext("Import") %></.button>
|
||||
</.link>
|
||||
</div>
|
||||
@@ -36,7 +36,7 @@
|
||||
>
|
||||
<li
|
||||
:for={{id, record} <- @streams.records}
|
||||
phx-click={JS.navigate(~p"/records/#{record}")}
|
||||
phx-click={JS.navigate(~p"/collection/#{record}")}
|
||||
class="flex justify-between gap-x-6 py-5 hover:bg-zinc-50 dark:hover:bg-zinc-800 px-2 -mx-2 md:px-4 md:-mx-4 cursor-pointer"
|
||||
id={id}
|
||||
>
|
||||
@@ -51,7 +51,7 @@
|
||||
<.link
|
||||
:for={artist <- record.artists}
|
||||
class="text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300"
|
||||
patch={~p"/records?query=mbid:#{artist.musicbrainz_id}"}
|
||||
patch={~p"/collection?query=mbid:#{artist.musicbrainz_id}"}
|
||||
>
|
||||
<%= artist.name %>
|
||||
</.link>
|
||||
@@ -151,7 +151,7 @@
|
||||
role="menuitem"
|
||||
tabindex="-1"
|
||||
id={"actions-#{record.id}-show"}
|
||||
navigate={~p"/records/#{record}"}
|
||||
navigate={~p"/collection/#{record}"}
|
||||
>
|
||||
<%= gettext("Show") %>
|
||||
</.link>
|
||||
@@ -171,7 +171,7 @@
|
||||
role="menuitem"
|
||||
tabindex="-1"
|
||||
id={"actions-#{record.id}-edit"}
|
||||
patch={~p"/records/#{record}/edit"}
|
||||
patch={~p"/collection/#{record}/edit"}
|
||||
>
|
||||
<%= gettext("Edit") %>
|
||||
</.link>
|
||||
|
||||
@@ -9,9 +9,9 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
if connected?(socket) do
|
||||
socket
|
||||
|> get_connect_params()
|
||||
|> Map.get("_live_referer", ~p"/records")
|
||||
|> Map.get("_live_referer", ~p"/collection")
|
||||
else
|
||||
~p"/records"
|
||||
~p"/collection"
|
||||
end
|
||||
|
||||
socket =
|
||||
@@ -40,7 +40,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
record = Records.get_record!(id)
|
||||
{:ok, _} = Records.delete_record(record)
|
||||
|
||||
{:noreply, push_navigate(socket, to: ~p"/records")}
|
||||
{:noreply, push_navigate(socket, to: ~p"/collection")}
|
||||
end
|
||||
|
||||
def handle_event("refresh_musicbrainz_data", %{"id" => id}, socket) do
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<.link
|
||||
:for={artist <- @record.artists}
|
||||
class="text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300"
|
||||
patch={~p"/records?query=mbid:#{artist.musicbrainz_id}"}
|
||||
patch={~p"/collection?query=mbid:#{artist.musicbrainz_id}"}
|
||||
>
|
||||
<%= artist.name %>
|
||||
</.link>
|
||||
@@ -27,7 +27,7 @@
|
||||
</p>
|
||||
|
||||
<nav class="mt-5 isolate inline-flex rounded-md shadow-sm">
|
||||
<.link patch={~p"/records/#{@record}/show/edit"} phx-click={JS.push_focus()}>
|
||||
<.link patch={~p"/collection/#{@record}/show/edit"} phx-click={JS.push_focus()}>
|
||||
<.button type="button" class="relative inline-flex items-center rounded-r-none">
|
||||
<%= gettext("Edit") %>
|
||||
</.button>
|
||||
@@ -159,7 +159,7 @@
|
||||
:if={@live_action == :edit}
|
||||
id="record-modal"
|
||||
show
|
||||
on_cancel={JS.patch(~p"/records/#{@record}")}
|
||||
on_cancel={JS.patch(~p"/collection/#{@record}")}
|
||||
>
|
||||
<.live_component
|
||||
module={MusicLibraryWeb.RecordLive.FormComponent}
|
||||
@@ -168,6 +168,6 @@
|
||||
action={@live_action}
|
||||
show_purchased_at={true}
|
||||
record={@record}
|
||||
patch={~p"/records/#{@record}"}
|
||||
patch={~p"/collection/#{@record}"}
|
||||
/>
|
||||
</.modal>
|
||||
|
||||
@@ -12,7 +12,7 @@ defmodule MusicLibraryWeb.StatsLive.DataComponents do
|
||||
"relative overflow-hidden rounded-md bg-white dark:bg-zinc-800 px-4 pb-3 pt-5 shadow sm:px-6 sm:pt-6 cursor-pointer",
|
||||
@class
|
||||
]}
|
||||
phx-click={JS.navigate(~p"/records/#{@record}")}
|
||||
phx-click={JS.navigate(~p"/collection/#{@record}")}
|
||||
>
|
||||
<dt>
|
||||
<img
|
||||
@@ -29,7 +29,7 @@ defmodule MusicLibraryWeb.StatsLive.DataComponents do
|
||||
<.link
|
||||
:for={artist <- @record.artists}
|
||||
class="text-sm md:text-base lg:text-2xl text-zinc-900 hover:text-zinc-500 dark:text-zinc-300 dark:hover:text-zinc-200"
|
||||
patch={~p"/records?query=mbid:#{artist.musicbrainz_id}"}
|
||||
patch={~p"/collection?query=mbid:#{artist.musicbrainz_id}"}
|
||||
>
|
||||
<%= artist.name %>
|
||||
</.link>
|
||||
|
||||
@@ -8,7 +8,11 @@
|
||||
title={gettext("Latest purchase")}
|
||||
class="col-span-2 sm:col-span-3"
|
||||
/>
|
||||
<.counter title={gettext("Total collection")} count={@collection_count} path={~p"/records"} />
|
||||
<.counter
|
||||
title={gettext("Total collection")}
|
||||
count={@collection_count}
|
||||
path={~p"/collection"}
|
||||
/>
|
||||
<.counter title={gettext("Total wishlist")} count={@wishlist_count} path={~p"/wishlist"} />
|
||||
</dl>
|
||||
</div>
|
||||
@@ -28,7 +32,7 @@
|
||||
<dd class="mt-1 text-center">
|
||||
<a
|
||||
class="text-xl lg:text-2xl font-semibold hover:text-zinc-500 dark:text-zinc-300 dark:hover:text-zinc-200"
|
||||
href={~p"/records?query=format:#{format}"}
|
||||
href={~p"/collection?query=format:#{format}"}
|
||||
>
|
||||
<%= count %>
|
||||
</a>
|
||||
@@ -52,7 +56,7 @@
|
||||
<dd class="mt-1 text-center">
|
||||
<a
|
||||
class="text-xl lg:text-2xl font-semibold hover:text-zinc-500 dark:text-zinc-300 dark:hover:text-zinc-200"
|
||||
href={~p"/records?query=type:#{type}"}
|
||||
href={~p"/collection?query=type:#{type}"}
|
||||
>
|
||||
<%= count %>
|
||||
</a>
|
||||
|
||||
@@ -32,12 +32,12 @@ defmodule MusicLibraryWeb.Router do
|
||||
|
||||
live "/", StatsLive.Index, :index
|
||||
|
||||
live "/records", CollectionLive.Index, :index
|
||||
live "/records/import", CollectionLive.Index, :import
|
||||
live "/records/:id/edit", CollectionLive.Index, :edit
|
||||
live "/collection", CollectionLive.Index, :index
|
||||
live "/collection/import", CollectionLive.Index, :import
|
||||
live "/collection/:id/edit", CollectionLive.Index, :edit
|
||||
|
||||
live "/records/:id", CollectionLive.Show, :show
|
||||
live "/records/:id/show/edit", CollectionLive.Show, :edit
|
||||
live "/collection/:id", CollectionLive.Show, :show
|
||||
live "/collection/:id/show/edit", CollectionLive.Show, :edit
|
||||
|
||||
live "/wishlist", WishlistLive.Index, :index
|
||||
live "/wishlist/import", WishlistLive.Index, :import
|
||||
|
||||
@@ -100,7 +100,7 @@ msgstr ""
|
||||
msgid "Format"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:18
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:22
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Formats"
|
||||
msgstr ""
|
||||
@@ -178,7 +178,7 @@ msgid "No results"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/index.html.heex:121
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:155
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:159
|
||||
#: lib/music_library_web/live/wishlist_live/index.html.heex:121
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Open options"
|
||||
@@ -292,12 +292,12 @@ msgstr ""
|
||||
msgid "The application has been updated, please reload."
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:11
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:12
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Total collection"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:12
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:16
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Total wishlist"
|
||||
msgstr ""
|
||||
@@ -307,7 +307,7 @@ msgstr ""
|
||||
msgid "Type"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:42
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:46
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Types"
|
||||
msgstr ""
|
||||
@@ -363,7 +363,7 @@ msgstr ""
|
||||
msgid "MusicBrainz data"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:67
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:71
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Scrobble activity"
|
||||
msgstr ""
|
||||
@@ -373,12 +373,12 @@ msgstr ""
|
||||
msgid "Choose which format to import"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:124
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:128
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Collected"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:137
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:141
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Wishlisted"
|
||||
msgstr ""
|
||||
@@ -411,7 +411,7 @@ msgstr ""
|
||||
msgid "MusicBrainz data refreshed successfully"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:74
|
||||
#: lib/music_library_web/live/stats_live/index.html.heex:78
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Refresh LastFm Feed"
|
||||
msgstr ""
|
||||
|
||||
@@ -36,7 +36,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
conn: conn,
|
||||
wishlist: wishlist_records
|
||||
} do
|
||||
{:ok, index_live, _html} = live(conn, ~p"/records")
|
||||
{:ok, index_live, _html} = live(conn, ~p"/collection")
|
||||
|
||||
for record <- wishlist_records do
|
||||
refute has_element?(index_live, "#records-#{record.id}")
|
||||
@@ -44,7 +44,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
end
|
||||
|
||||
test "shows purchased records", %{conn: conn, collection: records} do
|
||||
{:ok, index_live, html} = live(conn, ~p"/records")
|
||||
{:ok, index_live, html} = live(conn, ~p"/collection")
|
||||
|
||||
assert html =~ "Collection"
|
||||
|
||||
@@ -81,7 +81,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
setup [:fill_collection]
|
||||
|
||||
test "uses query string params", %{conn: conn, collection: records} do
|
||||
{:ok, page_2_live, page_2_html} = live(conn, ~p"/records?page=2&page_size=25")
|
||||
{:ok, page_2_live, page_2_html} = live(conn, ~p"/collection?page=2&page_size=25")
|
||||
|
||||
{page_2_present, page_2_absent} =
|
||||
Enum.split_with(records, fn record ->
|
||||
@@ -98,7 +98,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
assert has_element?(page_2_pagination, "a", "4")
|
||||
assert has_element?(page_2_pagination, "a", "5")
|
||||
|
||||
{:ok, page_3_live, page_3_html} = live(conn, ~p"/records?page=3&page_size=25")
|
||||
{:ok, page_3_live, page_3_html} = live(conn, ~p"/collection?page=3&page_size=25")
|
||||
|
||||
{page_3_present, page_3_absent} =
|
||||
Enum.split_with(records, fn record ->
|
||||
@@ -128,7 +128,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
test "supports raw queries", %{conn: conn, collection: records} do
|
||||
[record | _rest] = records
|
||||
qs = [query: record.title]
|
||||
{:ok, index_live, _html} = live(conn, ~p"/records?#{qs}")
|
||||
{:ok, index_live, _html} = live(conn, ~p"/collection?#{qs}")
|
||||
|
||||
record_row =
|
||||
index_live
|
||||
@@ -168,7 +168,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
page_size: @default_records_page_size
|
||||
]
|
||||
|
||||
{:ok, index_live, _html} = live(conn, ~p"/records?#{qs}")
|
||||
{:ok, index_live, _html} = live(conn, ~p"/collection?#{qs}")
|
||||
|
||||
for record <- present do
|
||||
record_row =
|
||||
@@ -199,20 +199,20 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
test "can navigate to the record edit form", %{conn: conn} do
|
||||
record = record_fixture()
|
||||
|
||||
{:ok, index_live, _html} = live(conn, ~p"/records")
|
||||
{:ok, index_live, _html} = live(conn, ~p"/collection")
|
||||
|
||||
assert index_live
|
||||
|> element("#records-#{record.id} a", "Edit")
|
||||
|> render_click() =~ "Edit"
|
||||
|
||||
assert_patch(index_live, ~p"/records/#{record}/edit")
|
||||
assert_patch(index_live, ~p"/collection/#{record}/edit")
|
||||
|
||||
assert index_live |> render() =~ "Edit"
|
||||
end
|
||||
|
||||
test "can change the record cover", %{conn: conn} do
|
||||
record = record_fixture(cover_data: File.read!(marbles_cover_fixture()))
|
||||
{:ok, form_live, html} = live(conn, ~p"/records/#{record.id}/edit")
|
||||
{:ok, form_live, html} = live(conn, ~p"/collection/#{record.id}/edit")
|
||||
|
||||
assert html =~ ~p"/covers/#{record.id}?vsn=#{record.cover_hash}"
|
||||
|
||||
@@ -256,7 +256,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
|
||||
describe "Importing a new record" do
|
||||
test "it shows the import modal", %{conn: conn} do
|
||||
{:ok, index_live, _html} = live(conn, ~p"/records")
|
||||
{:ok, index_live, _html} = live(conn, ~p"/collection")
|
||||
|
||||
import_dialog =
|
||||
index_live
|
||||
@@ -266,11 +266,11 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
assert import_dialog =~ "Search for a record on MusicBrainz"
|
||||
assert import_dialog =~ "No results"
|
||||
|
||||
assert_patch(index_live, ~p"/records/import")
|
||||
assert_patch(index_live, ~p"/collection/import")
|
||||
end
|
||||
|
||||
test "it imports a record when selected", %{conn: conn} do
|
||||
{:ok, import_live, _html} = live(conn, ~p"/records/import")
|
||||
{:ok, import_live, _html} = live(conn, ~p"/collection/import")
|
||||
|
||||
mock_results = release_group_search_results()
|
||||
|
||||
@@ -348,7 +348,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|
||||
musicbrainz_id: "1932f5b6-0b7b-4050-b1df-833ca89e5f44"
|
||||
} = marillion
|
||||
|
||||
assert_redirect(import_live, ~p"/records/#{record.id}")
|
||||
assert_redirect(import_live, ~p"/collection/#{record.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,13 +19,13 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do
|
||||
test "can navigate to the record edit form", %{conn: conn} do
|
||||
record = record_fixture()
|
||||
|
||||
{:ok, show_live, _html} = live(conn, ~p"/records/#{record.id}")
|
||||
{:ok, show_live, _html} = live(conn, ~p"/collection/#{record.id}")
|
||||
|
||||
assert show_live
|
||||
|> element("a", "Edit")
|
||||
|> render_click() =~ "Edit"
|
||||
|
||||
assert_patch(show_live, ~p"/records/#{record}/show/edit")
|
||||
assert_patch(show_live, ~p"/collection/#{record}/show/edit")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ defmodule MusicLibraryWeb.CollectionLive.ShowTest do
|
||||
test "it includes all needed information", %{conn: conn} do
|
||||
record = record_fixture()
|
||||
|
||||
{:ok, _show_live, html} = live(conn, ~p"/records/#{record.id}")
|
||||
{:ok, _show_live, html} = live(conn, ~p"/collection/#{record.id}")
|
||||
|
||||
assert html =~ escape(record.title)
|
||||
assert html =~ to_string(record.release)
|
||||
|
||||
Reference in New Issue
Block a user