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

feat: add library component picker #1356

Conversation

rpenido
Copy link
Contributor

@rpenido rpenido commented Oct 2, 2024

Description

This PR implements the components

Select Library

image

Pick Component

image

Additional Information

Part of:

Depends on:

Testing instruction


Private-ref: FAL-3876

@openedx-webhooks
Copy link

openedx-webhooks commented Oct 2, 2024

Thanks for the pull request, @rpenido!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/2u-tnl. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 2, 2024
@bradenmacdonald
Copy link
Contributor

@rpenido FYI, once we implement #1354 we will need to make it so that this "component picker" mode only shows the published version of things, not the draft.

@rpenido rpenido force-pushed the rpenido/fal-3876-add-library-content-to-a-course branch 4 times, most recently from adb7247 to 785a830 Compare October 4, 2024 00:00
Copy link

codecov bot commented Oct 4, 2024

Codecov Report

Attention: Patch coverage is 98.38188% with 5 lines in your changes missing coverage. Please review.

Project coverage is 93.09%. Comparing base (1ee3229) to head (46babe0).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...brary-authoring/component-picker/SelectLibrary.tsx 90.00% 3 Missing ⚠️
...c/library-authoring/collections/CollectionInfo.tsx 93.33% 1 Missing ⚠️
...ry-authoring/collections/LibraryCollectionPage.tsx 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1356      +/-   ##
==========================================
+ Coverage   93.04%   93.09%   +0.05%     
==========================================
  Files        1043     1047       +4     
  Lines       19954    20128     +174     
  Branches     4155     4266     +111     
==========================================
+ Hits        18566    18738     +172     
+ Misses       1326     1325       -1     
- Partials       62       65       +3     

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

@rpenido rpenido force-pushed the rpenido/fal-3876-add-library-content-to-a-course branch 2 times, most recently from 5b8042d to 5c2842a Compare October 8, 2024 20:28
Comment on lines -194 to -213
<Routes>
<Route
path={TabList.home}
element={(
<LibraryHome tabList={TabList} handleTabChange={handleTabChange} />
)}
/>
<Route
path={TabList.components}
element={<LibraryComponents variant="full" />}
/>
<Route
path={TabList.collections}
element={<LibraryCollections variant="full" />}
/>
<Route
path="*"
element={<NotFoundAlert />}
/>
</Routes>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had to change to render based on a state instead of the route because of the ComponentPicker component

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you elaborate? Why can't we have nested routes, with three home/components/collections routes underneath /library/foo and the same three home/components/collections routes also available underneath /library-component-picker/ ?

Copy link
Contributor Author

@rpenido rpenido Oct 10, 2024

Choose a reason for hiding this comment

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

Hmm. You're right. We can. I didn't think this way when I refactored this.
Do you prefer we stick to the routing approach? We will just need to fix some places where we do absolute redirects to '/library/libraryId' to support this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well what I really want is to implement #1230 ASAP, which will simplify everything. Then the "All/Collections/Components" tabs will essentially be just another filter. But yeah, I do think it should be in the route if possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Though it doesn't need to be in the route for the content picker.

Copy link
Contributor Author

@rpenido rpenido Oct 10, 2024

Choose a reason for hiding this comment

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

Just to be clear, it is still in the URL path as it was. I'm just using states from the context to render the child components instead of the Router component.

I will check how far I'm from using Routes again tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh ok. Maybe that's not so bad? I'll have a look later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be better to fix the Route issue with #1230. I moved more things to the context here, which will help the refactor a bit.

This PR is "functional".
We will probably want to change the endpoint to add the content, but is it possible to test it? It is missing the Modal tough.
I will post a more detailed update about the task status tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

This change seems to have broken the Back/Forward button in the browser. Before, you could change tabs and then press BACK and it would return to the previous tab, but now it's not working.

Comment on lines 23 to 33
<Routes>
<Route
path="collection/:collectionId"
element={<LibraryCollectionPage />}
/>
<Route
path="*"
element={<LibraryAuthoringPage />}
/>
</Routes>
Copy link
Contributor Author

@rpenido rpenido Oct 10, 2024

Choose a reason for hiding this comment

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

We had to change to render based on a state instead of the route because of the ComponentPicker component

Copy link
Contributor

Choose a reason for hiding this comment

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

We can keep this as is, don't need to remove the routes. Using match in line 15 to get collectionId and passing it to LibraryProvider should be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great! Fixed here: 1ce80cb

@rpenido rpenido force-pushed the rpenido/fal-3876-add-library-content-to-a-course branch 2 times, most recently from 9babe85 to 7e61a2c Compare October 10, 2024 22:30
@rpenido rpenido force-pushed the rpenido/fal-3876-add-library-content-to-a-course branch from 7e61a2c to cdfe3d6 Compare October 10, 2024 22:45
@rpenido rpenido force-pushed the rpenido/fal-3876-add-library-content-to-a-course branch from 46d7a0d to d8f3d7a Compare October 11, 2024 16:37
@rpenido rpenido force-pushed the rpenido/fal-3876-add-library-content-to-a-course branch 2 times, most recently from 0f0a5d6 to 7ca8f22 Compare October 11, 2024 19:12
@rpenido rpenido force-pushed the rpenido/fal-3876-add-library-content-to-a-course branch from a6ec33d to de1be9e Compare October 11, 2024 21:42
@rpenido rpenido force-pushed the rpenido/fal-3876-add-library-content-to-a-course branch 2 times, most recently from ef416c9 to edf787f Compare October 15, 2024 20:02
@rpenido rpenido force-pushed the rpenido/fal-3876-add-library-content-to-a-course branch from edf787f to 3a4497b Compare October 15, 2024 20:14
@rpenido
Copy link
Contributor Author

rpenido commented Oct 15, 2024

@bradenmacdonald Conflicts resolved!

@bradenmacdonald
Copy link
Contributor

@rpenido This is minor, but there's no spacing around the "Next" button and it's touching the edge of the browser window.

Screenshot

@bradenmacdonald
Copy link
Contributor

bradenmacdonald commented Oct 15, 2024

@rpenido Also, the "+ Add Collection" button should not appear in this read-only mode.

Screenshot

Screenshot 2

@bradenmacdonald
Copy link
Contributor

@rpenido When we implement #1385 , we're going to have to change a bunch of things with this modal (to support multi-select, and not to add to the course right away - instead just add to a list and pass that list to the Problem Bank). But this is totally fine for now - just making you aware it will need some changes.

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

Phew! This is a huge PR. Lots of nice refactors in here. Just a few small issues. If you want to address any of my feedback in a follow-up PR or skip it entirely, let me know.

Comment on lines -194 to -213
<Routes>
<Route
path={TabList.home}
element={(
<LibraryHome tabList={TabList} handleTabChange={handleTabChange} />
)}
/>
<Route
path={TabList.components}
element={<LibraryComponents variant="full" />}
/>
<Route
path={TabList.collections}
element={<LibraryCollections variant="full" />}
/>
<Route
path="*"
element={<NotFoundAlert />}
/>
</Routes>
Copy link
Contributor

Choose a reason for hiding this comment

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

This change seems to have broken the Back/Forward button in the browser. Before, you could change tabs and then press BACK and it would return to the previous tab, but now it's not working.

throw new Error('parentLocator is required');
}

// URLSearchParams decodes '+' to ' ', so we need to convert it back
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be needed. The problem was that the ID wasn't properly encoded in the first place. The + should have been replaced with %2B

Screenshot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Unit Outline doesn't use the encoded key in the URL, so I opted not to use it here, either.
image

It will also work if we receive the URL encoded.
Let me know if this is an issue!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but there it's in the path part of the URL. Here it's in a query string, and it's definitely wrong to assume that a + in a query string value will be interpreted as +

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine to leave this in; as you said it's not doing any harm. But we should be encoding the ID when we pass it into the query string.

src/library-authoring/common/context.tsx Outdated Show resolved Hide resolved
src/library-authoring/common/context.tsx Show resolved Hide resolved
@@ -0,0 +1,3 @@
.library-list {
min-height: 620px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this style be removed? When the picker is inset in an iframe, this makes the page longer than it needs to be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This was to make the list have the same height while showing less than 5 results.
Removed here: 72f7b85

@rpenido
Copy link
Contributor Author

rpenido commented Oct 16, 2024

This change seems to have broken the Back/Forward button in the browser. Before, you could change tabs and then press BACK and it would return to the previous tab, but now it's not working.

This should fix it: a31836e
But I think we should use nested routes in the future.

@rpenido
Copy link
Contributor Author

rpenido commented Oct 16, 2024

Phew! This is a huge PR.
Sorry for that @bradenmacdonald ! 😬

I think I addressed the issues. Let me know if I missed anything!

@bradenmacdonald
Copy link
Contributor

bradenmacdonald commented Oct 16, 2024

@rpenido What about the spacing around the "Next" button and the need to hide the " + Add Collection" button?

Edit: I see they're both fixed now :)

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

Looking good now, thanks for this nice work! Let me know when I can merge.

@rpenido
Copy link
Contributor Author

rpenido commented Oct 16, 2024

Looking good now, thanks for this nice work! Let me know when I can merge.

Waiting for the CI/CD. If something fails, I will fix it later today,

@bradenmacdonald bradenmacdonald merged commit b81f611 into openedx:master Oct 16, 2024
8 checks passed
@bradenmacdonald bradenmacdonald deleted the rpenido/fal-3876-add-library-content-to-a-course branch October 16, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants