Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-5901 Pseud switcher text on the New Pseud page #4579

Merged
merged 5 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/helpers/pseuds_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ def print_pseud_list(user, pseuds, first: true)
end
end

def pseuds_for_sidebar(user, pseud)
pseuds = user.pseuds.abbreviated_list - [pseud]
pseuds = pseuds.sort
pseuds = [pseud] + pseuds if pseud && !pseud.new_record?
pseuds
end

# used in the sidebar
def print_pseud_selector(pseuds)
pseuds -= [@pseud] if @pseud && @pseud.new_record?
list = pseuds.sort.collect {|pseud| "<li>" + span_if_current(pseud.name, [pseud.user, pseud]) + "</li>"}.join("").html_safe
def pseud_selector(pseuds)
pseuds.collect { |pseud| "<li>#{span_if_current(pseud.name, [pseud.user, pseud])}</li>" }.join.html_safe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Correctable] Layout/SingleLineBlockChain: Put method call on a separate line if chained to a single line block.

end
end
11 changes: 0 additions & 11 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ def is_maintainer?
current_user.is_a?(User) ? current_user.maintained_collections.present? : false
end

def sidebar_pseud_link_text(user, pseud)
text = if current_page?(user)
ts('Pseuds')
elsif pseud.present? && !pseud.new_record?
pseud.name
else
user.login
end
(text + ' &#8595;').html_safe
end

# Prints user pseuds with links to anchors for each pseud on the page and the description as the title
def print_pseuds(user)
user.pseuds.collect(&:name).join(', ')
Expand Down
5 changes: 2 additions & 3 deletions app/views/users/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
<li><%= span_if_current ts("Profile"), user_profile_path(@user) %></li>
<% if @user.pseuds.size > 1 %>
<li class="pseud" aria-haspopup="true">
<% pseud_link_text = current_page?(@user) ? ts("Pseuds") : (@pseud ? @pseud.name : @user.login) %>
<a href="#" title="<%= ts("Pseud Switcher") %>"><%= pseud_link_text %></a>
<a href="#" title="<%= ts("Pseud Switcher") %>"><%= ts("Pseuds") %></a>
<ul class="expandable secondary">
<%= print_pseud_selector(@user.pseuds.abbreviated_list) %>
<%= pseud_selector(pseuds_for_sidebar(@user, @pseud)) %>
<li><%= span_if_current ts("All Pseuds (%{pseud_number})", :pseud_number => @user.pseuds.count), user_pseuds_path(@user) %></li>
</ul>
</li>
Expand Down
4 changes: 2 additions & 2 deletions features/other_a/pseuds.feature
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ Scenario: Many pseuds
And I should see "All Pseuds (4)" within "ul.expandable"

When I go to my "Slartibartfast" pseud page
Then I should see "Slartibartfast" within "li.pseud > a"
And I should not see "Slartibartfast" within "ul.expandable"
Then I should see "Pseuds" within "li.pseud > a"
And I should see "Slartibartfast" within "ul.expandable"

When I go to my pseuds page
Then I should not see "Zaphod (Zaphod)" within "ul.pseud.index"
Expand Down