diff --git a/app/components/primary_navigation_component.rb b/app/components/primary_navigation_component.rb index 33f5a9529..f9668f812 100644 --- a/app/components/primary_navigation_component.rb +++ b/app/components/primary_navigation_component.rb @@ -5,4 +5,8 @@ class PrimaryNavigationComponent < ViewComponent::Base @items = items super end + + def highlighted_tab?(item, _path) + item[:current] + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cefeea24b..335cc0ff3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -66,7 +66,7 @@ <% if !current_user.nil? %> <%= render PrimaryNavigationComponent.new( - items: primary_items(current_user) + items: primary_items(current_user), ) %> <% end %> diff --git a/spec/components/primary_navigation_component_spec.rb b/spec/components/primary_navigation_component_spec.rb index 999dbfaf5..46f45166d 100644 --- a/spec/components/primary_navigation_component_spec.rb +++ b/spec/components/primary_navigation_component_spec.rb @@ -2,9 +2,11 @@ require "rails_helper" RSpec.describe PrimaryNavigationComponent, type: :component do let(:items) do - [{ text: "Organisations", href: "/organisations", current: true }, - { text: "Users", href: "/users", current: false }, - { text: "Logs ", href: "/logs", current: false }] + [ + NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true), + NavigationItemsHelper::NavigationItem.new("Users", "/users", false), + NavigationItemsHelper::NavigationItem.new("Logs ", "/logs", false), + ] end context "when the item is 'current' in nav tabs" do