-
Notifications
You must be signed in to change notification settings - Fork 80
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
feat: Add lib v2/legacy tabs in studio home #1050
feat: Add lib v2/legacy tabs in studio home #1050
Conversation
Thanks for the pull request, @yusuf-musleh! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
@yusuf-musleh Can you check if there's a way to update the URL, so when I click on the "Libraries" tab, the URL changes from |
@bradenmacdonald I've implemented this here in 17a5070. The url path now updates with I opted for paths rather than query params as react-router would always refresh the page when dealing/changing query params (I've tried a bunch of different approaches), as opposed to changing the paths when the routes point to the same component which doesn't cause a refresh. |
17a5070
to
025a85d
Compare
0439a24
to
975b8db
Compare
@bradenmacdonald I had to temporarily remove the ts/tsx related code to get the tests to run (da189c1 and 14933d2). I assume once the new frontend-build is merged this will no longer be an issue. |
@yusuf-musleh Yes, that's right. |
975b8db
to
8b96268
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1050 +/- ##
=======================================
Coverage 92.59% 92.59%
=======================================
Files 708 710 +2
Lines 12614 12683 +69
Branches 2768 2797 +29
=======================================
+ Hits 11680 11744 +64
- Misses 899 903 +4
- Partials 35 36 +1 ☔ View full report in Codecov by Sentry. |
Hi @yusuf-musleh! Just to note that I think you should skip the tests from |
@rpenido Good point! Thanks for the pointer, I've added it. |
ad85c17
to
7a8488d
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.
Hi @yusuf-musleh , I found a few things to fix, but this is working fine in general.
Feel free to push back on anything :)
src/index.jsx
Outdated
@@ -52,6 +53,9 @@ const App = () => { | |||
createRoutesFromElements( | |||
<Route> | |||
<Route path="/home" element={<StudioHome />} /> | |||
<Route path="/libraries" element={<StudioHome />} /> | |||
<Route path="/legacy-libraries" element={<StudioHome />} /> |
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.
nit: could this path mention v1 instead of "legacy"? I don't have strong feelings about this, just don't like to see words like "old" or "legacy" (or "new") in URLs.
<Route path="/legacy-libraries" element={<StudioHome />} /> | |
<Route path="/libraries-v1" element={<StudioHome />} /> |
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.
I agree, it's cleaner that way, updated here: a0a30b7
src/studio-home/StudioHome.jsx
Outdated
if (isMixedOrV2LibrariesMode(libMode)) { | ||
libraryHref = libraryAuthoringMfeUrl && redirectToLibraryAuthoringMfe | ||
? `${libraryAuthoringMfeUrl}create` | ||
: `${window.location.origin}/course-authoring/library/create`; |
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.
MFEs can be deployed to different paths, so we can't hard-code /course-authoring
here., but we can use these helpers from frontend-platform:
import { getConfig, getPath } from '@edx/frontend-platform';
: `${window.location.origin}/course-authoring/library/create`; | |
: `${getPath(getConfig().PUBLIC_PATH)}library/create`; |
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.
Got it, updated it here: 2859741
setConfig({ | ||
...getConfig(), | ||
LIBRARY_MODE: 'v1 only', | ||
}); |
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.
Looks like you've set things up for testing here, but haven't added the actual tests yet?
Or maybe these changes aren't needed with your tab-section tests below?
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.
For this test, the library mode needs to be set to v1 only
. I set it back to mixed
inside beforeEach
to make sure the rest of the tests have the correct mode.
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.
Oh gotcha.. thanks for explaining!
@@ -62,7 +62,7 @@ module.exports = { | |||
}, | |||
], | |||
librariesEnabled: true, |
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.
Reminder: we also need a test where librariesEnabled: false
, to check the placeholder page redirect.
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.
? `${libraryAuthoringMfeUrl}library/${id}` | ||
// Redirection to the placeholder is done in the MFE rather than | ||
// through the backend i.e. redirection from cms, because this this will probably change | ||
: `${window.location.origin}/course-authoring/library/${id}` |
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.
Same comment as here about generating course authoring MFE URLs.
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.
Updated: 2859741
navigate( | ||
libMode === 'v1 only' | ||
? '/libraries' | ||
: '/legacy-libraries', |
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.
I understand switching the label for v1 Libraries to "Legacy Libraries" if v2 libraries are enabled -- that makes sense, and it will help users transition from v1 to v2.
But I don't think we need to use a different URL as well -- that's making things too complicated.
tab === TABS_LIST.legacyLibraries
should always resolve to '/legacy-libraries'tab === TABS_LIST.libraries
should resolve to/libraries
.
This would simplify your useEffect
above too.
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.
That makes sense, I've changed it here: 094086e
<CardItem | ||
key={`${org}+${slug}`} | ||
isLibraries | ||
displayName={title} |
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.
The ContentLibrary model doesn't have a title
field.. I'm not sure what should go here instead?
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.
That's right, however the serializers have the title
field.
Here is an example of what is returned in the from the API:
{
"id": "lib:SampleTaxonomyOrg1:TL1",
"type": "complex",
"org": "SampleTaxonomyOrg1",
"slug": "TL1",
"title": "Test Library 1",
"description": "",
"num_blocks": 0,
"version": 0,
"last_published": null,
"allow_lti": false,
"allow_public_learning": false,
"allow_public_read": false,
"has_unpublished_changes": false,
"has_unpublished_deletes": false,
"license": ""
}
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.
Oh my mistake, you're totally correct, there is a title
field in the serializer, and it's the library's learning package title. But since I was naughty and neglected to use the content_libraries.api
to create my libraries, they didn't have learning packages, so I had no titles to click on.
My bad!
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.
ohh I see, gotcha!
@@ -62,7 +62,7 @@ module.exports = { | |||
}, | |||
], | |||
librariesEnabled: true, | |||
libraryAuthoringMfeUrl: 'http://localhost:3001', | |||
libraryAuthoringMfeUrl: 'http://localhost:3001/', |
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.
The platform default for this URL does not contain the trailing slash, but usually with a fully-deployed MFE, there's a PUBLIC_PATH
variable that can default to /
.
But I don't know for sure that our MFE configurations are consistent enough to rely on the presence of a trailing slash. Instead of constructing Library Authoring URLs from simple string concatenation, could you create a function that handles inserting the trailing slash if needed?
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.
Interesting, I wasn't familiar with that! That's a good idea, I've added the function here 567dcb4
e08b1ce
to
2e3fa43
Compare
@pomegranited Thanks for the detailed review! I believe I addressed all the comments and it should be ready to go for another round when you get a chance. One more thing to note is, once the new frontend-build PRs are merged, I need to revert some commits on this PR to bring back the typescript code I removed to get the tests running: |
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.
👍 Works perfectly, and the code looks great.
- I tested this using my tutor dev stack and @yusuf-musleh 's spectacular testing instructions :)
- I read through the code, including the temporary TS/X changes.
- I checked for accessibility issues by using my keyboard alone to navigate the new tabs and pages.
- Includes documentation -- updates README
- User-facing strings are extracted for translation
Thanks @pomegranited for the great review! @xitij2000 This is ready for CC when you have a chance. |
I generally prefer to run and test the code as well especially after a review round in case something breaks. My devstack is fixed now so I am reviewing this right now. |
Sounds good, will do. |
@xitij2000 Just checking in to see in case I missed the review or if it wasn't submitted yet. |
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.
Looks good! Just feel like the image doesn't belong here.
README.rst
Outdated
.. image:: ./docs/readme-images/feature-v2-and-legacy-libs.png | ||
|
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.
I think we can leave out the image. They get outdated quick and it's a large chunk of data that will forever be a part of this repo and increase its size. Having it in the PR should be enough.
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.
Thanks for the review! Good point, I've removed it.
When lib mode is set to "mixed", both "Libraries" and "Legacy Libraries" tabs are show in the Studio Home. When "Libraries" is clicked, v2 libraries are fetched, when "Legacy Libraries" is clicked, v1 libraries are fetched. When lib mode is set to "v1 only" or "v2 only", only one tab "Libraries" is show and only the respective libraries are fetched when the tab is clicked.
This is to switch between different library modes.
The path updates when selecting tabs, when accessing the url with the path directly it will open its respective tab. Navigating using the browser back/forward buttons is also supported.
This commit is temporary as the current frontend build system in tests doesnt support TS syntax. That should be fixed soon, and this commit should be removed.
This is a temporary commit since there are currently no webpack loaders that support tsx files in the test running. This commit should be removed once that is fixed upstream.
2e3fa43
to
09e3979
Compare
@yusuf-musleh 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
Description
This PR adds a new configuration flag that shows/hides tabs in studio home along with some new functionality around to V1 and V2 Libraries.
When the new
LIBRARY_MODE
flag is set to"mixed"
(default in dev) it will show "Libraries" and "Legacy Libraries" tabs that correspond to v1 and v2 tabs respectively:When the new
LIBRARY_MODE
flag is set to"v1 only"
(default in production) or"v2 only"
, only one tab "Libraries" is shown and only the respective libraries are fetched when the tab is clicked.In addition to the above changes, the URL/route now updates when clicking on the tabs, and navigating to it directly would open up that tab as well as a new placeholder page that you will be redirected to when clicking on a v2 library if the library authoring MFE is not enabled:
Supporting information
Related Tickets:
Testing instructions
studio.library_authoring_mfe
waffle flag enabled in thepageSize
in https://github.com/openedx/frontend-app-course-authoring/pull/1050/files#diff-8eef2c5f738aa3151262ca0ca6634eb16c533410f9286ce96c0a58061590bac4R57 to a lower number, and confirm going through multiple pages of results)/libraries
studio.library_authoring_mfe
waffle flag, and then clicking on a v2 library it should take you to the placeholder page (shown in screenshot above), the url should reflect the clicked v2 library (eg:/library/lib:SampleTaxonomyOrg1:AL1
)studio.library_authoring_mfe
waffle flag is disabled, it should redirect you to the placeholder page/libraries-v1
LIBRARY_MODE
is "mixed", clicking on "New Library" should still take you to the library authoring mfe to create a new v2 libraryLIBRARY_MODE
flag to "v2 only" and restart the course-authoring container/libraries
LIBRARY_MODE
flag to "v1 only" and restart the course-authoring container/libraries-v1
Private-ref: FAL-3751