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 Limit number of pseuds on profile and sidebar #4554

Merged
merged 17 commits into from
Jul 6, 2023

Conversation

neuroalien
Copy link
Contributor

@neuroalien neuroalien commented Jun 22, 2023

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-5901

Purpose

What does this PR do?

  • Limits the number of pseuds shown on the user's profile and on the user sidebar to the configured value in ArchiveConfig.ITEMS_PER_PAGE (with cesy's contribution)
  • Dynamically loads pseuds on profile page (tickinginstant, sarken)

Testing Instructions

How can the Archive's QA team verify that this is working as you intended?

If you have a Jira account with access, please update or comment on the issue
with any new or missing testing instructions instead.

References

Are there other relevant issues/pull requests/mailing list discussions?

Credit

What name and pronouns should we use to credit you in the Archive of Our Own's Release Notes?

alien, they/them

However, more people contributed to this PR over the years (years!), who should also be credited.

neuroalien and others added 15 commits July 29, 2020 16:36
The view was a bit confusing, pulling information from various parts of the user entity, the profile, and the preferences.

In extracting it to a presenter, I realised that if the preference was set to show it, we were showing the birthday section even if the field itself was empty, so I changed that to not show the section.

Refactor some specs to remove duplication.

Update ignore file for Brakeman to ignore the newly introduced false positive.
These yaks aren't going to shave themselves...
Fixes a long-standing bug where the intention of the code was always to show the current pseud at the top of the pseud switcher.
The maximum number of pseuds on the profile page is now tested in `pseuds.feature`.
And remove user request spec, as per review.
Show different link text, depending on whether there are more pseuds in total than there are shown on profile.
I mean Hound. Yes, that's what I mean.

* Double quoting strings
* Using `let` like DHH intended us to instead of instance variables
* Assertive language in spec descriptions
* Explicit expectations ("Do not use `be` without an argument")
Comment on lines +34 to +40
@user = User.find_by(login: params[:user_id])

if @user.nil?
flash[:error] = ts("Sorry, there's no user by that name.")
redirect_to root_path
return
end
Copy link
Contributor

@Bilka2 Bilka2 Jun 26, 2023

Choose a reason for hiding this comment

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

Based on recent other PRs regarding misspelled usernames (#4312 + #4376), I think this should use find_by! so it results in a 404 error instead of redirecting when the user is nonexistent.

@scottsds scottsds merged commit 09c7c2f into otwcode:master Jul 6, 2023
neuroalien added a commit to neuroalien/otwarchive that referenced this pull request Jul 16, 2023
When we started limiting the number of pseuds in the sidebar, the way to guarantee that the current pseud would show up in the sidebar was to show it at the top of the pseud switcher.

However, [AO3-6249](https://otwarchive.atlassian.net/browse/AO3-6249) decided that the pseud switcher should always say "Pseuds" at the top.

We broke this behaviour in otwcode#4554.

Fixing it in c3e4ab9 resulted in the current pseud not showing in the sidebar in some conditions.

Move or add the current pseud at the beginning of the list, whether or not it is present in the abbreviated list.

We are aware that this could make the abbreviated list in the pseud switcher show `ITEMS_PER_PAGE` + 1 pseuds in some cases, discuss with @sarken if you disagree.
sarken added a commit that referenced this pull request Jul 16, 2023
* AO3-5901 Pseud switcher text on the New Pseud page

Provide fallback text for the edge case of the New Pseud page, where `@pseud` is defined, but doesn't have a `name` yet.

* Update app/views/users/_sidebar.html.erb

Co-authored-by: sarken <[email protected]>

* AO3-5901 Ensure pseud switcher shows current pseud

When we started limiting the number of pseuds in the sidebar, the way to guarantee that the current pseud would show up in the sidebar was to show it at the top of the pseud switcher.

However, [AO3-6249](https://otwarchive.atlassian.net/browse/AO3-6249) decided that the pseud switcher should always say "Pseuds" at the top.

We broke this behaviour in #4554.

Fixing it in c3e4ab9 resulted in the current pseud not showing in the sidebar in some conditions.

Move or add the current pseud at the beginning of the list, whether or not it is present in the abbreviated list.

We are aware that this could make the abbreviated list in the pseud switcher show `ITEMS_PER_PAGE` + 1 pseuds in some cases, discuss with @sarken if you disagree.

* AO3-5901 Don't use instance vars in helpers

The Hound has arisen from its slumber as soon as I touched some ancient scrolls, and so I've tried to appease it with the following sacrifices:
- add spaces after and before curly bois (`{` and `}`)
- IN-TER-PO-LATE! IN-TER-PO-LATE! (AKA prefer interpolation to string concatenation)
- stop using instance vars in helper method

The latter change has morally forced my hand to:
-  separate the method that determines which pseuds to show in the sidebar selector from the method that outputs the HTML
- remove the `print_` prefix from the method that I touched, as [per precedent](50f7b7e)

* AO3-5901 Remove code unused since 2013

This method has had no callers since c10ef8a#diff-638a702b43ccba6b5dcb42edd2c6f8bb4ba56c492cb2ef7ccf56815663743e07.

Tacking it onto this issue because its presence confused me when deciding whether the `pseuds_for_sidebar` method belonged in the user helper or the pseud helper.

---------

Co-authored-by: sarken <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants