docbrown/app/views/stories/articles_search/_nav_menu.html.erb
Jeremy Friesen eef989cabf
Conditionally rendering "Search > My Posts" by policy (#17113)
When a user does not have any posts NOR can they create posts, we are to
hide the "Search > My Posts" section.

I have chosen not to write a test for this as it's exercising a well
tested policy and we don't have a unit test for this view.  As part of
forem/forem#17076 I introduced some cypress tests.  But that feels like
quite a bit of overkill for this feature.

Closes forem/forem#16837
Related to forem/forem#16821
2022-04-05 16:18:09 -04:00

22 lines
1.1 KiB
Text

<ul class="crayons-navigation">
<li><a class="query-filter-button crayons-navigation__item" data-filter="class_name:Article" href="javascript:;">
<%= t("views.search.nav.posts") %>
</a></li>
<li><a class="query-filter-button crayons-navigation__item" data-filter="class_name:PodcastEpisode" href="javascript:;">
<%= t("views.search.nav.podcasts") %>
</a></li>
<li><a class="query-filter-button crayons-navigation__item" data-filter="class_name:User" href="javascript:;">
<%= t("views.search.nav.people") %>
</a></li>
<li><a class="query-filter-button crayons-navigation__item" data-filter="class_name:Tag" href="javascript:;">
<%= t("views.search.nav.tags") %>
</a></li>
<li><a class="query-filter-button crayons-navigation__item" data-filter="class_name:Comment" href="javascript:;">
<%= t("views.search.nav.comments") %>
</a></li>
<% if policy(Article).has_existing_articles_or_can_create_new_ones? %>
<li><a class="query-filter-button my-posts-query-button crayons-navigation__item" data-filter="MY_POSTS" href="javascript:;">
<%= t("views.search.nav.my_posts") %>
</a></li>
<% end %>
</ul>