-
-
Notifications
You must be signed in to change notification settings - Fork 290
Feature/sc 32283/sheets desktop update topics homepage navigation #2338
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
Feature/sc 32283/sheets desktop update topics homepage navigation #2338
Conversation
…o-sheets-pool-when-user-tags-topic
…ature/sc-32391/add-topic-to-sheets-pool-when-user-tags-topic
…op-update-topics-homepage-navigation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements module-specific topic displays by supplementing topic entries with a "pools" property and updating the navigation components. Key changes include:
- Adding a "pools" field for topics in the TOC in text.py.
- Updating TopicPage.jsx to filter topics based on the active module.
- Adjusting sidebar components and navigation in NavSidebar.jsx, ReaderPanel.jsx, and TopicsPage.jsx.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
static/js/TopicPage.jsx | Introduces a new topic filter function and refactors topic block rendering. |
static/js/NavSidebar.jsx | Adds a new sidebar module component "JoinTheConversation". |
sefaria/urls.py | Introduces new URL routes for sheets topics. |
static/js/ReaderPanel.jsx | Updates menu rendering based on the active module. |
static/js/TopicsPage.jsx | Modifies sidebar module list to include "JoinTheConversation". |
sefaria/model/text.py | Adds support for a "pools" key in the topic TOC JSON output. |
Files not reviewed (1)
- static/css/s2.css: Language not supported
…navigation' into feature/sc-26865/sheets-desktop-topics-display-sheets-only
sefaria/model/text.py
Outdated
@@ -5157,7 +5158,8 @@ def get_topic_toc_json_recursive(self, topic=None, explored=None, with_descripti | |||
"shouldDisplay": True if len(children) > 0 else topic.should_display(), | |||
"en": topic.get_primary_title("en"), | |||
"he": topic.get_primary_title("he"), | |||
"displayOrder": getattr(topic, "displayOrder", 10000) | |||
"displayOrder": getattr(topic, "displayOrder", 10000), | |||
"pools": DjangoTopic.objects.slug_to_pools[topic.slug] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if i understand correctly, that changes an API response object.
- it seems ok for me, but i think those changes (although small) should be considered from architecture POV.
- IMHO it would be better to add reader_views.topic_page a param that says if it's for library or sheet, and mpving the filtering logics to the server side.
- if we have this response in the dev portal, it should be reflected there also, so you should change the json accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YishaiGlasner Are you sure this changes an API response? Which API url does it change?
Re 2. I do agree that we should take advantage of the request.active_module
attribute set in the ModuleMiddleware
to either sheets
or library
to take advantage of filtering the list of topics on the backend
, although I see no problem having the pools
remain on this object, since it's cached anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yitzhakc i think it adds the key pools
to topics/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YishaiGlasner @yitzhakc I don't think this changes any API results. This changes the Sefaria._topics cache which is handled by the front-end only. /api/topics is not affected by this. And yes, this adds a 'pools' key to every topic in the Sefaria._topics cache. The reason I did it this way is because reader_views.topic_page only gets called if someone loads a topic page server side. Therefore, if you navigate to "Explore" and then go to a topic page, reader_views.topic_page won't get called. Instead, the front-end will use the Sefaria._topics
cache. The problem is that this cache gets set on the backend by get_topic_toc_json (which is in turn called by large_data in context_processors.py) when the server initially loads. This happens long before any request is received with an active_module parameter. Therefore, I don't see how we could take advantage of the active_module parameter in the request.
sefaria/model/text.py
Outdated
@@ -5157,7 +5158,8 @@ def get_topic_toc_json_recursive(self, topic=None, explored=None, with_descripti | |||
"shouldDisplay": True if len(children) > 0 else topic.should_display(), | |||
"en": topic.get_primary_title("en"), | |||
"he": topic.get_primary_title("he"), | |||
"displayOrder": getattr(topic, "displayOrder", 10000) | |||
"displayOrder": getattr(topic, "displayOrder", 10000), | |||
"pools": DjangoTopic.objects.slug_to_pools[topic.slug] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YishaiGlasner Are you sure this changes an API response? Which API url does it change?
Re 2. I do agree that we should take advantage of the request.active_module
attribute set in the ModuleMiddleware
to either sheets
or library
to take advantage of filtering the list of topics on the backend
, although I see no problem having the pools
remain on this object, since it's cached anyways.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…-topics-display-sheets-only Feature/sc 26865/sheets desktop topics display sheets only
…op-update-topics-homepage-navigation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a topic table of contents (TOC) card component and refactors both client and server logic to support module-specific topic navigation (library vs. sheets). Key changes include
- New
TopicTOCCard
component and refactoring ofTopicsPage
/TopicCategory
to use it - Backend updates (
processTopicsTabsData
, URL patterns, view logic) to handle sheets vs. library pools and module-specific topic tabs - Introduction of
_getShortInterfaceLang
helper and widespread refactoring of interface-language slicing
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
static/js/common/TopicTOCCard.jsx | Added reusable TOC card for topics |
static/js/sefaria/sefaria.js | Replaced processTopicsData with processTopicsTabsData ; added tab derivation, module-specific trending, and _getShortInterfaceLang |
static/js/TopicsPage.jsx | Switched to TopicTOCCard for root topics page; updated sidebar |
sourcesheets/views.py | Updated trending tags API to accept n parameter |
sefaria/urls.py | Added /sheets/topics/ URL patterns |
sefaria/model/text.py | Included pools in topic TOC JSON |
reader/views.py | Refactored topic_page view for slug parameter and module checks |
[Various other JS/CSS files] | Refactored language-slice logic; added join-conversation sidebar module and styles |
…op-update-topics-homepage-navigation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
e69039b
to
e70f746
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a module-aware topic table of contents (TOC) for the sheets module by extending topic card rendering and backend tab logic.
- Introduces TopicTOCCard for consistent topic listing across pages
- Refactors topic data processing to assign refs into module-specific tabs
- Adds
pools
metadata on topics and filters subtopics by active module
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
static/js/sefaria/sefaria.js | Adds processTopicsTabsData and _deriveTabDataForTopicLink , updates topic caching to use module-specific pools |
static/js/common/TopicTOCCard.jsx | New component for rendering topic cards in category pages |
static/js/TopicsPage.jsx | Replaces manual category listing with TopicTOCCard and updates sidebar modules |
static/js/TopicPageAll.jsx | Switches to central _getShortInterfaceLang helper |
static/js/TopicLandingPage/TopicsLandingPage.jsx | Uses generic TrendingTopics in sidebar |
static/js/TopicLandingPage/TopicLandingNewsletter.jsx | Uses _getShortInterfaceLang for newsletter analytics |
static/js/TopicEditor.jsx | Simplifies language selection via Sefaria._v |
static/js/Story.jsx | Centralizes short-code language helper |
static/js/StaticPages.jsx | Uses _getShortInterfaceLang for locale in sorting |
static/js/SourceEditor.jsx | Applies short-code helper for sheet descriptions |
static/js/ReaderPanel.jsx | Renders TopicsPage in sheets module and TopicsLandingPage in library |
static/js/ReaderApp.jsx | Adopts _getShortInterfaceLang for interface language slicing |
static/js/NavSidebar.jsx | Adds "JoinTheConversation" module and cleans up trending mapping |
static/css/s2.css | Styles .joinTheConversation and clamps card descriptions |
sourcesheets/views.py | Validates n parameter in trending tags API |
sefaria/utils/util.py | Adds get_short_lang helper |
sefaria/urls.py | Adds routes for sheets topic pages |
sefaria/model/text.py | Extends TOC JSON with pools for module filtering |
reader/views.py | Applies get_short_lang in view logic and enforces module access |
Comments suppressed due to low confidence (4)
static/js/sefaria/sefaria.js:2858
- [nitpick] The new
processTopicsTabsData
function introduces module-specific tab assignment logic but lacks accompanying unit tests. Consider adding tests to verify correct tab grouping for both library and sheets modules.
processTopicsTabsData: function(topicData) {
static/js/common/TopicTOCCard.jsx:10
- The
openTopic
handler referenceschildren
,slug
,en
, andhe
before they are declared (TDZ error). Move the destructuring oftopic
above this handler or referencetopic.slug
etc. directly inside the function.
children ? setNavTopic(slug, {en, he}) : setTopic(slug, {en, he});
static/js/ReaderPanel.jsx:951
TopicsPage
is used here but not imported in this file, causing a ReferenceError. Addimport { TopicsPage } from './TopicsPage';
at the top.
menu = <TopicsPage
sourcesheets/views.py:966
- This error response returns JSON without an HTTP error status. Consider returning a 400 Bad Request (e.g.,
jsonResponse(..., status=400)
) to more clearly signal client input error.
return jsonResponse({"error": "Invalid value for parameter 'n'. It must be an integer."})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements an updated topics table-of-contents (TOC) for the sheets module that filters topics based on the module (sheets vs. library) and updates related views, components, and APIs.
- Introduces a new TopicTOCCard component to standardize topic presentation.
- Updates the topics processor to processTopicsTabsData and applies topic pool filtering in the backend.
- Adjusts trending topics API calls, URL routes, and various UI components for proper handling of the active module.
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
static/js/sefaria/sefaria.js | Updates topics processor, trending topics functions, and language helpers. |
static/js/common/TopicTOCCard.jsx | New component for rendering topic cards with conditional navigation. |
static/js/TopicsPage.jsx | Replaces legacy category rendering with TopicTOCCard usage. |
static/js/TopicPageAll.jsx | Updates topic sorting to leverage the new language helper. |
static/js/TopicLandingPage/* | Adjusts trending topics module and newsletter language handling. |
static/js/TopicEditor.jsx, Story.jsx, etc. | Refactors usage of language conversion to Sefaria._getShortInterfaceLang. |
static/css/s2.css | Adds styling for card clamping and spacing adjustments. |
sourcesheets/views.py | Enhances trending topics API endpoint with parameter validation. |
sefaria/utils/util.py | Adds a helper function to convert full language strings to short codes. |
sefaria/urls.py | Introduces new URL routes for sheets topics. |
sefaria/model/text.py | Adds new property ‘pools’ for topics to facilitate module filtering. |
reader/views.py | Updates topic page processing to normalize slugs and filter topics by active module. |
Comments suppressed due to low confidence (1)
static/js/common/TopicTOCCard.jsx:8
- The openTopic function uses the 'children' variable before its destructuring assignment. Consider moving the destructuring of { slug, children } to before the definition of openTopic to ensure the variable is defined when used.
const openTopic = e => { e.preventDefault(); children ? setNavTopic(slug, {en, he}) : setTopic(slug, {en, he}); }
Description
This PR implements a topic TOC for the sheets module. 1) As opposed to the library module, the topics TOC is not the topics landing page but is the old TopicsPage component. 2) The Topics TOC in the sheets module only shows topics that have sheets associated with them. 3) When viewing a topic category in either the library or sheets module, we only show topics that are appropriate for the given module. In other words, in the sheets module, subtopics are only shown if that subtopic has sheets associated with it, and likewise, in the library module, subtopics are only shown if they have library sources associated with them.
Code Changes
get_topic_toc_json_recursive
, we add a new property to each topic object calledpools
, which is just an array of the topic pools that the topic belongs to. Then, when we already on a topic category page, such as prayer, when we render the TopicCategory component, we call a functionshouldDisplay
to determine if each subtopic (such as Aleinu) actually belongs to the sheets/library topic pool. See the function shouldDisplay in TopicPage.jsx where we filter out all subtopics that are not appropriate for the given Sefaria.activeModule: