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: manage collections in component sidebar [FC-0062] #1373

Merged
merged 14 commits into from
Oct 15, 2024

Conversation

navinkarkera
Copy link
Contributor

@navinkarkera navinkarkera commented Oct 7, 2024

Description

Adds "Manage collections" section to component sidebar as described in #1287

vokoscreenNG-2024-10-10_16-58-05.mp4

Supporting information

Depends on:

Testing instructions

Concerns

  • Meilisearch displays removed components under a collection. To reproduce,
    • First select multiple collections for a component and confirm it.
    • Verify that the collections page displays the component.
    • Remove all collections from the component and confirm again.
    • The collections page still displays the old component even though the index document is updated. Verify the collections key in response from meilisearch in dev console. Seems like a weird bug in meilisearch where clearing a list (collections key in component) will somehow retain the last value it had while filtering.

@openedx-webhooks
Copy link

openedx-webhooks commented Oct 7, 2024

Thanks for the pull request, @navinkarkera!

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.

@bradenmacdonald
Copy link
Contributor

@navinkarkera Can you please add a description and screenshots to the PR? Also don't forget [FC-0062] in the PR title.

@navinkarkera navinkarkera force-pushed the navin/add-component-to-collection branch from 5f5ae2b to a57cf0e Compare October 8, 2024 11:31
@navinkarkera navinkarkera changed the title feat: manage collections in component sidebar feat: manage collections in component sidebar [FC-0062] Oct 8, 2024
@navinkarkera
Copy link
Contributor Author

@bradenmacdonald Done. I still need to add tests but everything else should be ready for review.

@rpenido
Copy link
Contributor

rpenido commented Oct 8, 2024

Meilisearch displays removed components under a collection.

It only happens when we are removing the LAST collection from an object.

This works:
{collections: {keys: ['coll1', 'coll2']}} > {collections: {keys: ['coll1']}}

This doesn't:
{collections: {keys: ['coll1', 'coll2']}} > {collections: {}}

But this also works:
{collections: {keys: ['coll1', 'coll2']}} > {collections: {keys: []}}

I created a small PR that circumvents this here: open-craft/edx-platform#695

This seems to be a bug upstream. Maybe related to this: meilisearch/meilisearch#4848
I think they weren't able to reproduce it. If you have some time, we can update them about this finding.

Copy link
Contributor

@rpenido rpenido left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thank you for your work, @navinkarkera!

  • I tested this using the instructions from the pr
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

@@ -129,6 +129,7 @@ export interface ContentHit extends BaseContentHit {
breadcrumbs: [{ displayName: string }, ...Array<{ displayName: string, usageKey: string }>];
content?: ContentDetails;
lastPublished: number | null;
collections?: { displayName?: string[], key?: string[] },
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
collections?: { displayName?: string[], key?: string[] },
collections: { displayName?: string[], key?: string[] },

/**
* Fetch a content hit by usage key
*/
export const fetchContentByUsageKey = async (
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't adding the collection data to the getLibraryBlockMetadata return be better?
It will make things simpler on this side (we wouldn't need another context only for this).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rpenido Yes, updated the API include collections data along with component.

Comment on lines 89 to 94
<Button
onClick={onClose}
variant="outline-primary"
>
{intl.formatMessage(messages.manageCollectionsToComponentCancelBtn)}
</Button>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: The style here is a bit different than the one used in the Manage Tags feature

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 designs given in the ticket show button with border but for consistency, modified it to match Manage tags Cancel button.

image

@bradenmacdonald
Copy link
Contributor

@navinkarkera CC @rpenido Within this PR, if you have time, could you please make sure the "Manage Collections" button (and ideally the "Manage Tags" too ) is hidden when the library is read-only for the current user? I've noticed we haven't been supporting the read-only mode very carefully with some of the new features.

@rpenido
Copy link
Contributor

rpenido commented Oct 8, 2024

I've noticed we haven't been supporting the read-only mode very carefully with some of the new features.

I'm adding a readOnly state as part of #1356 to try to handle it better across the sidebar components

@bradenmacdonald
Copy link
Contributor

@rpenido Ah, nice! I was kind of thinking of doing that actually. Looks good.

@navinkarkera navinkarkera force-pushed the navin/add-component-to-collection branch 3 times, most recently from 52ef2c8 to 7e4d568 Compare October 10, 2024 05:12
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 98.18182% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.04%. Comparing base (66b14a5) to head (44c4c25).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/library-authoring/components/ComponentCard.tsx 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1373      +/-   ##
==========================================
+ Coverage   93.01%   93.04%   +0.02%     
==========================================
  Files        1035     1036       +1     
  Lines       19632    19729      +97     
  Branches     4172     4185      +13     
==========================================
+ Hits        18261    18356      +95     
- Misses       1306     1308       +2     
  Partials       65       65              

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

@navinkarkera navinkarkera marked this pull request as ready for review October 10, 2024 05:25
@navinkarkera navinkarkera requested a review from a team as a code owner October 10, 2024 05:25
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Oct 10, 2024
Copy link
Contributor

@ChrisChV ChrisChV left a comment

Choose a reason for hiding this comment

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

Looks good 👍

src/library-authoring/data/api.ts Outdated Show resolved Hide resolved
src/library-authoring/data/apiHooks.ts Outdated Show resolved Hide resolved
@navinkarkera navinkarkera force-pushed the navin/add-component-to-collection branch from 43707d2 to 44c4c25 Compare October 11, 2024 05:35
@ChrisChV ChrisChV merged commit 8448760 into openedx:master Oct 15, 2024
8 checks passed
@ChrisChV ChrisChV deleted the navin/add-component-to-collection branch October 15, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants