From 39ea8e0deb6d18787f512bedf86fefd42f4727dd Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sat, 5 Apr 2025 21:58:33 +0300 Subject: [PATCH] Add links for Publisher and Servers to navbar if user is signed in. --- .../components/layouts/app.html.heex | 5 ++++- .../components/my_partials/navbar.ex | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/decentralised_book_index_web/components/layouts/app.html.heex b/lib/decentralised_book_index_web/components/layouts/app.html.heex index c68571d..5e47000 100644 --- a/lib/decentralised_book_index_web/components/layouts/app.html.heex +++ b/lib/decentralised_book_index_web/components/layouts/app.html.heex @@ -1,5 +1,8 @@
- <.partial_navbar page_title={assigns[:page_title]} /> + <.partial_navbar + page_title={assigns[:page_title]} + current_user={assigns[:current_user]} + />
diff --git a/lib/decentralised_book_index_web/components/my_partials/navbar.ex b/lib/decentralised_book_index_web/components/my_partials/navbar.ex index 7d1a284..a4b095d 100644 --- a/lib/decentralised_book_index_web/components/my_partials/navbar.ex +++ b/lib/decentralised_book_index_web/components/my_partials/navbar.ex @@ -3,7 +3,8 @@ defmodule DecentralisedBookIndexWeb.Components.MyPartials.Navbar do use DecentralisedBookIndexWeb, :verified_routes alias Phoenix.LiveView.JS - attr(:page_title, :string, required: true) + attr :page_title, :string, required: true + attr :current_user, :map, default: nil def partial_navbar(assigns) do ~H""" @@ -32,6 +33,14 @@ defmodule DecentralisedBookIndexWeb.Components.MyPartials.Navbar do
  • Authors
  • + <%= if @current_user != nil do %> +
  • + Publishers +
  • +
  • + Servers +
  • + <% end %>