add admin prefix to note and channel urls
This commit is contained in:
parent
d8d288c1e9
commit
4ca873d77b
|
@ -15,13 +15,13 @@
|
|||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<.link
|
||||
href={~p"/channels"}
|
||||
href={~p"/admin/channels"}
|
||||
class="text-[0.8125rem] font-semibold leading-6 text-zinc-900 hover:text-zinc-700"
|
||||
>
|
||||
Channels
|
||||
</.link>
|
||||
<.link
|
||||
href={~p"/notes"}
|
||||
href={~p"/admin/notes"}
|
||||
class="text-[0.8125rem] font-semibold leading-6 text-zinc-900 hover:text-zinc-700"
|
||||
>
|
||||
Notes
|
||||
|
|
|
@ -19,7 +19,7 @@ defmodule ChiyaWeb.ChannelController do
|
|||
{:ok, channel} ->
|
||||
conn
|
||||
|> put_flash(:info, "Channel created successfully.")
|
||||
|> redirect(to: ~p"/channels/#{channel}")
|
||||
|> redirect(to: ~p"/admin/channels/#{channel}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, :new, changeset: changeset)
|
||||
|
@ -44,7 +44,7 @@ defmodule ChiyaWeb.ChannelController do
|
|||
{:ok, channel} ->
|
||||
conn
|
||||
|> put_flash(:info, "Channel updated successfully.")
|
||||
|> redirect(to: ~p"/channels/#{channel}")
|
||||
|> redirect(to: ~p"/admin/channels/#{channel}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, :edit, channel: channel, changeset: changeset)
|
||||
|
@ -57,6 +57,6 @@ defmodule ChiyaWeb.ChannelController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Channel deleted successfully.")
|
||||
|> redirect(to: ~p"/channels")
|
||||
|> redirect(to: ~p"/admin/channels")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
<:subtitle>Use this form to manage channel records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.channel_form changeset={@changeset} action={~p"/channels/#{@channel}"} />
|
||||
<.channel_form changeset={@changeset} action={~p"/admin/channels/#{@channel}"} />
|
||||
|
||||
<.back navigate={~p"/channels"}>Back to channels</.back>
|
||||
<.back navigate={~p"/admin/channels"}>Back to channels</.back>
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<.header>
|
||||
Listing Channels
|
||||
<:actions>
|
||||
<.link href={~p"/channels/new"}>
|
||||
<.link href={~p"/admin/channels/new"}>
|
||||
<.button>New Channel</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<.table id="channels" rows={@channels} row_click={&JS.navigate(~p"/channels/#{&1}")}>
|
||||
<.table id="channels" rows={@channels} row_click={&JS.navigate(~p"/admin/channels/#{&1}")}>
|
||||
<:col :let={channel} label="Name"><%= channel.name %></:col>
|
||||
<:col :let={channel} label="Visibility"><%= channel.visibility %></:col>
|
||||
<:col :let={channel} label="Slug"><%= channel.slug %></:col>
|
||||
<:action :let={channel}>
|
||||
<div class="sr-only">
|
||||
<.link navigate={~p"/channels/#{channel}"}>Show</.link>
|
||||
<.link navigate={~p"/admin/channels/#{channel}"}>Show</.link>
|
||||
</div>
|
||||
<.link navigate={~p"/channels/#{channel}/edit"}>Edit</.link>
|
||||
<.link navigate={~p"/admin/channels/#{channel}/edit"}>Edit</.link>
|
||||
</:action>
|
||||
<:action :let={channel}>
|
||||
<.link href={~p"/channels/#{channel}"} method="delete" data-confirm="Are you sure?">
|
||||
<.link href={~p"/admin/channels/#{channel}"} method="delete" data-confirm="Are you sure?">
|
||||
Delete
|
||||
</.link>
|
||||
</:action>
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
<:subtitle>Use this form to manage channel records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.channel_form changeset={@changeset} action={~p"/channels"} />
|
||||
<.channel_form changeset={@changeset} action={~p"/admin/channels"} />
|
||||
|
||||
<.back navigate={~p"/channels"}>Back to channels</.back>
|
||||
<.back navigate={~p"/admin/channels"}>Back to channels</.back>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Channel <%= @channel.id %>
|
||||
<:subtitle>This is a channel record from your database.</:subtitle>
|
||||
<:actions>
|
||||
<.link href={~p"/channels/#{@channel}/edit"}>
|
||||
<.link href={~p"/admin/channels/#{@channel}/edit"}>
|
||||
<.button>Edit channel</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
|
@ -15,4 +15,4 @@
|
|||
<:item title="Slug"><%= @channel.slug %></:item>
|
||||
</.list>
|
||||
|
||||
<.back navigate={~p"/channels"}>Back to channels</.back>
|
||||
<.back navigate={~p"/admin/channels"}>Back to channels</.back>
|
||||
|
|
|
@ -21,7 +21,7 @@ defmodule ChiyaWeb.NoteController do
|
|||
{:ok, note} ->
|
||||
conn
|
||||
|> put_flash(:info, "Note created successfully.")
|
||||
|> redirect(to: ~p"/notes/#{note}")
|
||||
|> redirect(to: ~p"/admin/notes/#{note}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, :new, changeset: changeset, channels: to_channel_options())
|
||||
|
@ -47,7 +47,7 @@ defmodule ChiyaWeb.NoteController do
|
|||
{:ok, note} ->
|
||||
conn
|
||||
|> put_flash(:info, "Note updated successfully.")
|
||||
|> redirect(to: ~p"/notes/#{note}")
|
||||
|> redirect(to: ~p"/admin/notes/#{note}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, :edit, note: note, changeset: changeset, channels: to_channel_options())
|
||||
|
@ -60,7 +60,7 @@ defmodule ChiyaWeb.NoteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Note deleted successfully.")
|
||||
|> redirect(to: ~p"/notes")
|
||||
|> redirect(to: ~p"/admin/notes")
|
||||
end
|
||||
|
||||
defp from_channel_ids(note_params) do
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
<:subtitle>Use this form to manage note records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.note_form changeset={@changeset} action={~p"/notes/#{@note}"} channels={@channels} />
|
||||
<.note_form changeset={@changeset} action={~p"/admin/notes/#{@note}"} channels={@channels} />
|
||||
|
||||
<.back navigate={~p"/notes"}>Back to notes</.back>
|
||||
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<.header>
|
||||
Listing Notes
|
||||
<:actions>
|
||||
<.link href={~p"/notes/new"}>
|
||||
<.link href={~p"/admin/notes/new"}>
|
||||
<.button>New Note</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<.table id="notes" rows={@notes} row_click={&JS.navigate(~p"/notes/#{&1}")}>
|
||||
<.table id="notes" rows={@notes} row_click={&JS.navigate(~p"/admin/notes/#{&1}")}>
|
||||
<:col :let={note} label="Name"><%= note.name %></:col>
|
||||
<:col :let={note} label="Slug"><%= note.slug %></:col>
|
||||
<:col :let={note} label="Published at"><%= note.published_at %></:col>
|
||||
|
@ -15,12 +15,12 @@
|
|||
<:col :let={note} label="Url"><%= note.url %></:col>
|
||||
<:action :let={note}>
|
||||
<div class="sr-only">
|
||||
<.link navigate={~p"/notes/#{note}"}>Show</.link>
|
||||
<.link navigate={~p"/admin/notes/#{note}"}>Show</.link>
|
||||
</div>
|
||||
<.link navigate={~p"/notes/#{note}/edit"}>Edit</.link>
|
||||
<.link navigate={~p"/admin/notes/#{note}/edit"}>Edit</.link>
|
||||
</:action>
|
||||
<:action :let={note}>
|
||||
<.link href={~p"/notes/#{note}"} method="delete" data-confirm="Are you sure?">
|
||||
<.link href={~p"/admin/notes/#{note}"} method="delete" data-confirm="Are you sure?">
|
||||
Delete
|
||||
</.link>
|
||||
</:action>
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
<:subtitle>Use this form to manage note records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.note_form changeset={@changeset} action={~p"/notes"} channels={@channels} />
|
||||
<.note_form changeset={@changeset} action={~p"/admin/notes"} channels={@channels} />
|
||||
|
||||
<.back navigate={~p"/notes"}>Back to notes</.back>
|
||||
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Note <%= @note.id %>
|
||||
<:subtitle>This is a note record from your database.</:subtitle>
|
||||
<:actions>
|
||||
<.link href={~p"/notes/#{@note}/edit"}>
|
||||
<.link href={~p"/admin/notes/#{@note}/edit"}>
|
||||
<.button>Edit note</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
|
@ -17,4 +17,4 @@
|
|||
<:item title="Url"><%= @note.url %></:item>
|
||||
</.list>
|
||||
|
||||
<.back navigate={~p"/notes"}>Back to notes</.back>
|
||||
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
|
||||
|
|
|
@ -19,31 +19,31 @@ defmodule ChiyaWeb.ChannelControllerTest do
|
|||
|
||||
describe "index" do
|
||||
test "lists all channels", %{conn: conn} do
|
||||
conn = get(conn, ~p"/channels")
|
||||
conn = get(conn, ~p"/admin/channels")
|
||||
assert html_response(conn, 200) =~ "Listing Channels"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new channel" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, ~p"/channels/new")
|
||||
conn = get(conn, ~p"/admin/channels/new")
|
||||
assert html_response(conn, 200) =~ "New Channel"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create channel" do
|
||||
test "redirects to show when data is valid", %{conn: conn} do
|
||||
conn = post(conn, ~p"/channels", channel: @create_attrs)
|
||||
conn = post(conn, ~p"/admin/channels", channel: @create_attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == ~p"/channels/#{id}"
|
||||
assert redirected_to(conn) == ~p"/admin/channels/#{id}"
|
||||
|
||||
conn = get(conn, ~p"/channels/#{id}")
|
||||
conn = get(conn, ~p"/admin/channels/#{id}")
|
||||
assert html_response(conn, 200) =~ "Channel #{id}"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, ~p"/channels", channel: @invalid_attrs)
|
||||
conn = post(conn, ~p"/admin/channels", channel: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Channel"
|
||||
end
|
||||
end
|
||||
|
@ -52,7 +52,7 @@ defmodule ChiyaWeb.ChannelControllerTest do
|
|||
setup [:create_channel]
|
||||
|
||||
test "renders form for editing chosen channel", %{conn: conn, channel: channel} do
|
||||
conn = get(conn, ~p"/channels/#{channel}/edit")
|
||||
conn = get(conn, ~p"/admin/channels/#{channel}/edit")
|
||||
assert html_response(conn, 200) =~ "Edit Channel"
|
||||
end
|
||||
end
|
||||
|
@ -61,15 +61,15 @@ defmodule ChiyaWeb.ChannelControllerTest do
|
|||
setup [:create_channel]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, channel: channel} do
|
||||
conn = put(conn, ~p"/channels/#{channel}", channel: @update_attrs)
|
||||
assert redirected_to(conn) == ~p"/channels/#{channel}"
|
||||
conn = put(conn, ~p"/admin/channels/#{channel}", channel: @update_attrs)
|
||||
assert redirected_to(conn) == ~p"/admin/channels/#{channel}"
|
||||
|
||||
conn = get(conn, ~p"/channels/#{channel}")
|
||||
conn = get(conn, ~p"/admin/channels/#{channel}")
|
||||
assert html_response(conn, 200) =~ "some updated content"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, channel: channel} do
|
||||
conn = put(conn, ~p"/channels/#{channel}", channel: @invalid_attrs)
|
||||
conn = put(conn, ~p"/admin/channels/#{channel}", channel: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Edit Channel"
|
||||
end
|
||||
end
|
||||
|
@ -78,11 +78,11 @@ defmodule ChiyaWeb.ChannelControllerTest do
|
|||
setup [:create_channel]
|
||||
|
||||
test "deletes chosen channel", %{conn: conn, channel: channel} do
|
||||
conn = delete(conn, ~p"/channels/#{channel}")
|
||||
assert redirected_to(conn) == ~p"/channels"
|
||||
conn = delete(conn, ~p"/admin/channels/#{channel}")
|
||||
assert redirected_to(conn) == ~p"/admin/channels"
|
||||
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, ~p"/channels/#{channel}")
|
||||
get(conn, ~p"/admin/channels/#{channel}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,31 +23,31 @@ defmodule ChiyaWeb.NoteControllerTest do
|
|||
|
||||
describe "index" do
|
||||
test "lists all notes", %{conn: conn} do
|
||||
conn = get(conn, ~p"/notes")
|
||||
conn = get(conn, ~p"/admin/notes")
|
||||
assert html_response(conn, 200) =~ "Listing Notes"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new note" do
|
||||
test "renders form", %{conn: conn} do
|
||||
conn = get(conn, ~p"/notes/new")
|
||||
conn = get(conn, ~p"/admin/notes/new")
|
||||
assert html_response(conn, 200) =~ "New Note"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create note" do
|
||||
test "redirects to show when data is valid", %{conn: conn} do
|
||||
conn = post(conn, ~p"/notes", note: @create_attrs)
|
||||
conn = post(conn, ~p"/admin/notes", note: @create_attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == ~p"/notes/#{id}"
|
||||
assert redirected_to(conn) == ~p"/admin/notes/#{id}"
|
||||
|
||||
conn = get(conn, ~p"/notes/#{id}")
|
||||
conn = get(conn, ~p"/admin/notes/#{id}")
|
||||
assert html_response(conn, 200) =~ "Note #{id}"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
conn = post(conn, ~p"/notes", note: @invalid_attrs)
|
||||
conn = post(conn, ~p"/admin/notes", note: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Note"
|
||||
end
|
||||
end
|
||||
|
@ -57,12 +57,12 @@ defmodule ChiyaWeb.NoteControllerTest do
|
|||
|
||||
test "redirects to show when selecting a channel", %{conn: conn, channel: channel} do
|
||||
attrs = Map.put_new(@create_attrs, :channels, [to_string(channel.id)])
|
||||
conn = post(conn, ~p"/notes", note: attrs)
|
||||
conn = post(conn, ~p"/admin/notes", note: attrs)
|
||||
|
||||
assert %{id: id} = redirected_params(conn)
|
||||
assert redirected_to(conn) == ~p"/notes/#{id}"
|
||||
assert redirected_to(conn) == ~p"/admin/notes/#{id}"
|
||||
|
||||
conn = get(conn, ~p"/notes/#{id}")
|
||||
conn = get(conn, ~p"/admin/notes/#{id}")
|
||||
assert html_response(conn, 200) =~ "Note #{id}"
|
||||
end
|
||||
end
|
||||
|
@ -71,7 +71,7 @@ defmodule ChiyaWeb.NoteControllerTest do
|
|||
setup [:create_note]
|
||||
|
||||
test "renders form for editing chosen note", %{conn: conn, note: note} do
|
||||
conn = get(conn, ~p"/notes/#{note}/edit")
|
||||
conn = get(conn, ~p"/admin/notes/#{note}/edit")
|
||||
assert html_response(conn, 200) =~ "Edit Note"
|
||||
end
|
||||
end
|
||||
|
@ -80,15 +80,15 @@ defmodule ChiyaWeb.NoteControllerTest do
|
|||
setup [:create_note]
|
||||
|
||||
test "redirects when data is valid", %{conn: conn, note: note} do
|
||||
conn = put(conn, ~p"/notes/#{note}", note: @update_attrs)
|
||||
assert redirected_to(conn) == ~p"/notes/#{note}"
|
||||
conn = put(conn, ~p"/admin/notes/#{note}", note: @update_attrs)
|
||||
assert redirected_to(conn) == ~p"/admin/notes/#{note}"
|
||||
|
||||
conn = get(conn, ~p"/notes/#{note}")
|
||||
conn = get(conn, ~p"/admin/notes/#{note}")
|
||||
assert html_response(conn, 200) =~ "some updated content"
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn, note: note} do
|
||||
conn = put(conn, ~p"/notes/#{note}", note: @invalid_attrs)
|
||||
conn = put(conn, ~p"/admin/notes/#{note}", note: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "Edit Note"
|
||||
end
|
||||
end
|
||||
|
@ -103,14 +103,14 @@ defmodule ChiyaWeb.NoteControllerTest do
|
|||
channel2: channel2
|
||||
} do
|
||||
attrs = Map.put_new(@update_attrs, :channels, [to_string(channel.id)])
|
||||
conn = put(conn, ~p"/notes/#{note}", note: attrs)
|
||||
assert redirected_to(conn) == ~p"/notes/#{note}"
|
||||
conn = put(conn, ~p"/admin/notes/#{note}", note: attrs)
|
||||
assert redirected_to(conn) == ~p"/admin/notes/#{note}"
|
||||
|
||||
attrs = Map.put_new(@update_attrs, :channels, [to_string(channel2.id)])
|
||||
conn = put(conn, ~p"/notes/#{note}", note: attrs)
|
||||
assert redirected_to(conn) == ~p"/notes/#{note}"
|
||||
conn = put(conn, ~p"/admin/notes/#{note}", note: attrs)
|
||||
assert redirected_to(conn) == ~p"/admin/notes/#{note}"
|
||||
|
||||
conn = get(conn, ~p"/notes/#{note}")
|
||||
conn = get(conn, ~p"/admin/notes/#{note}")
|
||||
assert html_response(conn, 200) =~ "some updated content"
|
||||
end
|
||||
end
|
||||
|
@ -119,11 +119,11 @@ defmodule ChiyaWeb.NoteControllerTest do
|
|||
setup [:create_note]
|
||||
|
||||
test "deletes chosen note", %{conn: conn, note: note} do
|
||||
conn = delete(conn, ~p"/notes/#{note}")
|
||||
assert redirected_to(conn) == ~p"/notes"
|
||||
conn = delete(conn, ~p"/admin/notes/#{note}")
|
||||
assert redirected_to(conn) == ~p"/admin/notes"
|
||||
|
||||
assert_error_sent 404, fn ->
|
||||
get(conn, ~p"/notes/#{note}")
|
||||
get(conn, ~p"/admin/notes/#{note}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue