Skip to content

Commit

Permalink
AO3-6238 Random Items button on a collection doesn't work from the co…
Browse files Browse the repository at this point in the history
…llection homepage (#4462)

* change remote from true to false

* address linter comments pt 1

* address linter comments pt 2

* fix UTs by fixing missing translation error

* internationalization changes

* fixed random link and added UT

* commit erb linter autocorrect

* fix linter issue

* revert mistaken change
  • Loading branch information
Cesium-Ice authored Jan 22, 2025
1 parent 0b05a7e commit 36ca470
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 35 deletions.
54 changes: 23 additions & 31 deletions app/views/collections/_sidebar.html.erb
Original file line number Diff line number Diff line change
@@ -1,62 +1,54 @@
<div id="dashboard" class="region" role="navigation region">
<h3 class="landmark heading">Dashboard</h3>
<h3 class="landmark heading"><%= t(".landmark.dashboard") %></h3>
<ul class="navigation actions">
<li><%= span_if_current ts('Dashboard', key: 'dashboard'), @collection %></li>
<li><%= span_if_current ts('Profile', key: 'dashboard'), collection_profile_path(@collection) %></li>
<li><%= span_if_current t(".dashboard"), @collection %></li>
<li><%= span_if_current t(".profile"), collection_profile_path(@collection) %></li>
<% if !@collection.collection_profile.faq.blank? %>
<li><%= span_if_current ts('FAQ', key: 'dashboard'), collection_profile_path(@collection, :anchor => "faq") %></li>
<li><%= span_if_current t(".faq"), collection_profile_path(@collection, anchor: "faq") %></li>
<% end %>
<% if !@collection.collection_profile.rules.blank? %>
<li><%= span_if_current ts('Rules', key: 'dashboard'), collection_profile_path(@collection, :anchor => "rules") %></li>
<li><%= span_if_current t(".rules"), collection_profile_path(@collection, anchor: "rules") %></li>
<% end %>

<% if @collection.parent %>
<li><%= link_to ts('Parent Collection', key: 'dashboard'), collection_path(@collection.parent) %></li>
<li><%= link_to t(".parent_collection"), collection_path(@collection.parent) %></li>
<% else %>
<li><%= span_if_current ts("Subcollections (%{count})", key: 'dashboard', :count => @collection.children.count), collection_collections_path(@collection) %></li>
<li><%= span_if_current t(".subcollections", count: @collection.children.count), collection_collections_path(@collection) %></li>
<% end %>
</ul>

<!-- challenge section of dash -->
<% if @collection.challenge %>
<%= render :partial => "challenge/#{challenge_class_name(@collection)}/challenge_sidebar" %>
<%= render partial: "challenge/#{challenge_class_name(@collection)}/challenge_sidebar" %>
<% end %>

<h4 class="landmark heading">Contents</h4>
<h4 class="landmark heading"><%= t(".landmark.contents") %></h4>
<ul class="navigation actions">
<li><%= span_if_current ts("Fandoms (%{count})", key: 'dashboard', count: SearchCounts.fandom_count_for_collection(@collection)), collection_fandoms_path(@collection) %></li>
<li><%= span_if_current t(".fandoms", count: SearchCounts.fandom_count_for_collection(@collection)), collection_fandoms_path(@collection) %></li>

<li><%= span_if_current ts("Works (%{count})", key: 'dashboard', count: SearchCounts.work_count_for_collection(@collection)), collection_works_path(@collection) %></li>
<li><%= span_if_current t(".works", count: SearchCounts.work_count_for_collection(@collection)), collection_works_path(@collection) %></li>

<li><%= span_if_current ts("Bookmarked Items (%{count})", key: 'dashboard', count: SearchCounts.bookmarkable_count_for_collection(@collection)), collection_bookmarks_path(@collection) %></li>
<li><%= span_if_current t(".bookmarks", count: SearchCounts.bookmarkable_count_for_collection(@collection)), collection_bookmarks_path(@collection) %></li>

<li>
<% if controller.controller_name == 'collections' && controller.action_name == 'show' %>
<%= link_to 'Random Items',
:url => collection_path(@collection, :show_random => true), :method => :get, :remote => true %>
<% else %>
<%= link_to 'Random Items', collection_path(@collection, :show_random => true) %>
<% end %>
</li>
<li><%= span_if_current ts('People', key: 'dashboard'), collection_people_path(@collection) %></li>
<li><%= span_if_current ts('Tags', key: 'dashboard'), collection_tags_path(@collection) %></li>
</ul>
<li><%= span_if_current t(".random_items"), collection_path(@collection, show_random: true) %></li>
<li><%= span_if_current t(".people"), collection_people_path(@collection) %></li>
<li><%= span_if_current t(".tags"), collection_tags_path(@collection) %></li>
</ul>

<% if @collection.user_is_maintainer?(current_user)%>
<h4 class="landmark heading">Choices</h4>
<% if @collection.user_is_maintainer?(current_user) %>
<h4 class="landmark heading"><%= t(".landmark.choices") %></h4>
<ul class="navigation actions">
<li><%= span_if_current(ts('Manage Items', key: 'dashboard'), collection_items_path(@collection)) %></li>
<li><%= span_if_current(t(".manage_items"), collection_items_path(@collection)) %></li>
<% if @collection.user_is_owner?(current_user) %>
<% if @collection.challenge %>
<% if @collection.prompt_meme? %>
<li><%= span_if_current ts('Challenge Settings', key: 'dashboard'), edit_collection_prompt_meme_path(@collection) %></li>
<li><%= span_if_current t(".challenge_settings"), edit_collection_prompt_meme_path(@collection) %></li>
<% elsif @collection.gift_exchange? %>
<li><%= span_if_current ts('Challenge Settings', key: 'dashboard'), edit_collection_gift_exchange_path(@collection) %></li>
<li><%= span_if_current t(".challenge_settings"), edit_collection_gift_exchange_path(@collection) %></li>
<% end %>
<% end %>
<li><%= span_if_current ts('Collection Settings', key: 'dashboard'), edit_collection_path(@collection) %></li>
<li><%= span_if_current t(".collection_settings"), edit_collection_path(@collection) %></li>
<% end %>
</ul>
<% end %>
</div>

8 changes: 4 additions & 4 deletions app/views/wrangling_guidelines/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--Descriptive page name, messages and instructions-->
<h2 class="heading"><%= link_to ts('Wrangling Guidelines'), wrangling_guidelines_path %> > <%= @wrangling_guideline.title %></h2>
<h2 class="heading"><%= link_to t(".heading"), wrangling_guidelines_path %> > <%= @wrangling_guideline.title %></h2>
<!--/descriptions-->

<!--subnav-->
Expand All @@ -11,12 +11,12 @@
<% if policy(:wrangling).edit? %>
<div class="header">
<h3 class="heading">
Updated: <%=h @wrangling_guideline.updated_at %> | <%= link_to ts('Edit'), edit_wrangling_guideline_path(@wrangling_guideline) %>
Updated: <%= h @wrangling_guideline.updated_at %> | <%= link_to t(".edit"), edit_wrangling_guideline_path(@wrangling_guideline) %>
</h3>
</div>
<% end %>
<div class="userstuff">
<%=raw sanitize_field(@wrangling_guideline, :content) %>
<%= raw sanitize_field(@wrangling_guideline, :content) %>
</div>
</div>
<!--/content-->
<!--/content-->
24 changes: 24 additions & 0 deletions config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,26 @@ en:
form:
icon:
delete: Delete collection icon and revert to our default. This will also remove the icon alt text and comment text.
sidebar:
bookmarks: Bookmarked Items (%{count})
challenge_settings: Challenge Settings
collection_settings: Collection Settings
dashboard: Dashboard
fandoms: Fandoms (%{count})
faq: FAQ
landmark:
choices: Choices
contents: Contents
dashboard: Dashboard
manage_items: Manage Items
parent_collection: Parent Collection
people: People
profile: Profile
random_items: Random Items
rules: Rules
subcollections: Subcollections (%{count})
tags: Tags
works: Works (%{count})
comments:
comment_form:
anonymous_creator: Anonymous Creator
Expand Down Expand Up @@ -1939,3 +1959,7 @@ en:
unrevealed: A translation of a work in an unrevealed collection
work_module:
draft_deletion_notice_html: This draft will be <strong>scheduled for deletion</strong> on %{deletion_date}.
wrangling_guidelines:
show:
edit: Edit
heading: Wrangling Guidelines
17 changes: 17 additions & 0 deletions features/collections/collection_dashboard.feature
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,20 @@ Feature: Collection
Then I should see "Dashboard Light"
And I should see "Recent bookmarks"
And I should see "Bookmarks (6)" within "#collection-bookmarks"

Scenario: Given that I am on a collection's homepage the "Random Items" button should work

Given I have a collection "Dashboard Light" with name "dashboard_light"
And I am logged in as "user"
When I post the work "Work 1" in the collection "Dashboard Light"
And I post the work "Work 2" in the collection "Dashboard Light"
And I post the work "Work 3" in the collection "Dashboard Light"
And I post the work "Work 4" in the collection "Dashboard Light"
And I post the work "Work 5" in the collection "Dashboard Light"
And I post the work "Work 6" in the collection "Dashboard Light"
When I go to "Dashboard Light" collection's page
Then I should see "Random Items"

When I go to "Dashboard Light" collection's page
And I follow "Random Items"
Then I should see "Random works"

0 comments on commit 36ca470

Please sign in to comment.