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

Refactors and improves the My Books UI + architecture #8597

Merged
merged 7 commits into from
Dec 11, 2023

Conversation

mekarpeles
Copy link
Member

@mekarpeles mekarpeles commented Dec 7, 2023

  • Refactors mybooks.py routes into separate endpoints
  • Cleans up the main My Books Wrapper template
  • Makes /people/{username}/books visitable and sharable when readinglog set to public
  • Standardizes the page title using breadcrumb navigation dropper
  • Adds avatar image to mybooks breadcrumbs
  • Standardizes Edit --vanilla btn styling
  • Adds My Books Wrapper treatment to Lists and List
  • Shows "My" or patron's username in breadcrumb to clarify which page one is on
  • Standardizes chip buttons beneath header across pages
  • Moves "share" btn to its own spot in header

Known Bugs:

  • My Books Sponsorships breadcrumb broken -- Fixed
  • My Sponsorships broken
  • URLs on My Books page carousels should reflect page owner, not logged in patron
  • Breadcrumb dropdown unclickable, likely z-index error
  • Public "{username}'s books" breadcrumbs breaks, shows just: "{username}'s"
  • Private accounts breadcrumbs still show readinglog counts
  • Observations errors for public user (e.g. incognito /people/mekBot/books/observations)
  • chip menu should scroll horizontally
  • share should not appear twice on the screen (share, btn) and should always appear in upper right image
  • Stats section on /books should not break in mobile view on safari (desktop, mobile)
    Missing book cover should gracefully fall-back to placeholder Screenshot 2023-12-07 at 5 49 51 PM
  • The font-size of breadcrumbs should adjust to fit on screen
  • Public List not rendering in/as my books mode w/ sidebar (nice-to-have)
  • Share button does not preserve port, use request.fullpath not ctx.path? (nice-to-have)

Tested (http://ol-dev1.us.archive.org:1337/)

  • My Books (my page, logged in)
  • Public Account (logged in, logged out) Screenshot 2023-12-07 at 12 02 17 AM
    • Tested that /stats, /sponsorships, /observations, /notes all bounced correctly
  • Private Account Screenshot 2023-12-07 at 12 00 30 AM
  • Public "mekBot's Books" incognito works, notes + stats + loans all blocked
  • Public "mekBot's" sponsorships and observations are blocked?
  • "jachamp's Books" incognito successfully shows "private" + shows public lists + lists & list work
  • Public account works for all 3 reading logs, NOT notes

Prepares for #739 done in https://github.com/internetarchive/openlibrary/tree/follows-and-mb-refactor

Technical

Testing

Screenshot

Stakeholders

@mekarpeles mekarpeles force-pushed the refactor/mybooks branch 6 times, most recently from fea1dfc to 8dfd08f Compare December 7, 2023 07:54
@mekarpeles mekarpeles marked this pull request as ready for review December 7, 2023 08:04
@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f6a69b6) 17.61% compared to head (1d93856) 17.61%.
Report is 16 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8597   +/-   ##
=======================================
  Coverage   17.61%   17.61%           
=======================================
  Files          85       85           
  Lines        4456     4456           
  Branches      782      782           
=======================================
  Hits          785      785           
  Misses       3187     3187           
  Partials      484      484           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Refactors mybooks.py routes into separate endpoints
- Cleans up the main My Books Wrapper template
- Makes /people/{username}/books visitable and sharable when readinglog set to public
- Standardizes the page title using breadcrumb navigation dropper
- Adds avatar image to mybooks breadcrumbs
- Standardizes Edit --vanilla btn styling
- Adds My Books Wrapper treatment to Lists and List
- Shows "My" or patron's username in breadcrumb to clarify which page one is on
- Standardizes chip buttons beneath header across pages
- Moves "share" btn to its own spot in header

Known Bugs:
- [X] Public "{username}'s books" breadcrumb breaks, shows just as "{username}'s"
- [X] Breadcrumb dropdown unclickable, likely z-index error
- [X] My Sponsorships broken
- [X] URLs on My Books page carousels should reflect page owner, not logged in patron
- [X] Observations breaks for public user (e.g. incognito /people/mekBot/books/observations)
- [X] Private accounts breadcrumbs shouldn't show readinglog counts
- [ ] Public List not rendering with my books sidebar
- [ ] Share button does not preserve port

Tested
- [X] "My Books" works (as me), shows share, (stats, privacy & export chips)
- [X] "My Books" loans, readinglogs, reviews, notes, stats all work
- [X] Public "mekBot's Books" incognito works, notes + stats + loans all blocked
- [X] Public "mekBot's" sponsorships and observations are blocked?
- [X] "jachamp's Books" incognito successfully shows "private" + shows public lists + lists & list work
- [X] Public account works for all 3 reading logs, NOT notes
@mekarpeles mekarpeles added the On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing label Dec 7, 2023
openlibrary/plugins/openlibrary/lists.py Outdated Show resolved Hide resolved
openlibrary/plugins/openlibrary/lists.py Outdated Show resolved Hide resolved
And robust to usernames with special characters
mb = MyBooksTemplate(username, 'lists')
template = self.render_template(path, show_header=False)
return mb.render(template=template, header_title=_("Lists"), page=mb.user)
if path.startswith("/people/"):
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we should simply break the path regex into different functions rather than trying to collapse them into one, just a suggestion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Long term these should be two separate classes I reckon. They're pretty different in terms of function.

mekarpeles and others added 2 commits December 8, 2023 05:16
- top menu chips now wrap
- my books stats permissions work on mobile, (chrome, safari)
- deleted duplicate share buttons
- fixed mobile alignment of share button
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Tested:

  • ✅ non-people /lists page
  • ✅ people /lists page
  • ✅ Imports & exports
    • Nitpick: dropper says "My Imports and exports", sidebar says "Imports & Exports Options"
  • ✅ /account/loans
    • Bug (pre-existing): "Loans" not highlighted in sidebar when on loans page
  • ✅ stats works / is private
  • ✅ sorting reading log works for myself and others
  • ✅ Searching reading log works for myself and others
    • Bug (pre-existing): A search with no matches confusingly shows the "You have no books on this shelf" screen"
openlibrary/plugins/upstream/mybooks.py Outdated Show resolved Hide resolved
openlibrary/plugins/upstream/mybooks.py Outdated Show resolved Hide resolved
openlibrary/plugins/upstream/mybooks.py Outdated Show resolved Hide resolved
ratings=None,
year=None,
):
if self.me and self.is_my_page and self.key in self.ALL_KEYS:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if self.me and self.is_my_page and self.key in self.ALL_KEYS:
if self.is_my_page and self.key in self.ALL_KEYS:
mb = MyBooksTemplate(username, 'lists')
template = self.render_template(path, show_header=False)
return mb.render(template=template, header_title=_("Lists"), page=mb.user)
if path.startswith("/people/"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Long term these should be two separate classes I reckon. They're pretty different in terms of function.

$if owners_page:
<div>
<h1 class="details-title">My Stats</h1>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<h1 class="details-title">My Stats</h1>
<h1 class="details-title">$_('My Stats')</h1>
@@ -0,0 +1,25 @@
$def with (mb)

$ readinglog = mb.key in ['currently-reading', 'already-read', 'want-to-read']
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would be better in the MyBooks class; some is_readinglog(key: str) -> bool

Copy link
Collaborator

@cdrini cdrini Dec 11, 2023

Choose a reason for hiding this comment

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

This should be name mybooks_shell.html. view.html makes me think it's /people/ScarTissue , the profile page, since {type}/view.html correspond to infogamy types

openlibrary/templates/books/breadcrumb_select.html Outdated Show resolved Hide resolved
@@ -75,24 +75,27 @@ a.cta-btn {
border: 2px solid @link-blue;
background: lighten(desaturate(@link-blue, 56%), 67%);
}
&--vanilla {
&--vanilla, &--vanilla:visited, &--vanilla:link {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we doing this? I think this is frowned upon for accessibility.

Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Lgtm! Small suggestions left. Merge at your discretion

@mekarpeles mekarpeles merged commit b121d32 into master Dec 11, 2023
4 checks passed
@mekarpeles mekarpeles deleted the refactor/mybooks branch December 11, 2023 17:36
@jimchamp
Copy link
Collaborator

Sidebar is broken on account settings page:
image

https://staging.openlibrary.org/account?debug=true

Suspect this is due to counts being None.

@jimchamp jimchamp removed the On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants