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
This commit is contained in:
Jeremy Friesen 2022-04-05 16:18:09 -04:00 committed by GitHub
parent 7fade0f1f1
commit eef989cabf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,9 @@
<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>