Skip to content

feat: Unit card previews [FC-0083] - #1774

Merged
ChrisChV merged 6 commits into
openedx:masterfrom
open-craft:jill/fal-4057-unit-card-previews
Apr 8, 2025
Merged

feat: Unit card previews [FC-0083]#1774
ChrisChV merged 6 commits into
openedx:masterfrom
open-craft:jill/fal-4057-unit-card-previews

Conversation

@pomegranited

@pomegranited pomegranited commented Apr 2, 2025

Copy link
Copy Markdown
Contributor

Description

Adds block tiles to the Unit card to indicate type and quantity of children in the container.

This feature affects Library Authors.

image

Supporting information

Part of: #1618
Includes one commit borrowed from #1762
Private-ref: FAL-4057

Testing instructions

Run latest edx-platform master

In the Authoring MFE:

  1. Create a library
  2. Add a Unit to the library.
    Click the Unit to get its locator key from the URL, starting with lct:
  3. Add some blocks to the library of various types, and note their usage keys in the URL.

Add child blocks using the shell: tutor dev exec cms ./manage.py cms shell:

from opaque_keys.edx.locator import LibraryContainerLocator
from opaque_keys.edx.keys import UsageKeyV2
from openedx.core.djangoapps.content_libraries import api
   
unit = LibraryContainerLocator.from_string('lct:your-unit-key')
block1 = UsageKeyV2.from_string('lb:your-block1-key')
block2 = UsageKeyV2.from_string('lb:your-block2-key')
api.update_container_children(unit, [block1, block2], user_id=None)

Back in the Authoring MFE:

  1. Refresh the library Units to see the block tiles added to the Unit card.
    Maximum 5 blocks should be shown, with <4 showing as 4 blocks and "+N".
  2. Check the responsiveness of the Unit cards by changing your browser width and showing/hiding the sidebar.

Other information

  • The proposed design shows 2 rows of block tiles in the Unit preview, however, using 2 rows causes the Unit card heights to grow, which distorts the cards list.
    I had to give the cards a minimum width of 15rem to ensure 5 block tiles would fit.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Apr 2, 2025
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @pomegranited!

This repository is currently maintained by @openedx/2u-tnl.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are 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.

Details
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.

@rpenido rpenido left a comment

Copy link
Copy Markdown
Contributor

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, @pomegranited!

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

I left some (non-blocking) comments.

Comment thread src/library-authoring/components/BaseCard.tsx Outdated
Comment thread src/library-authoring/data/api.ts Outdated
/**
* Get the URL for a single container children api.
*/
export const getLibraryContainerChildrenApiUrl = (containerId: string) => `${getApiBaseUrl()}/api/libraries/v2/containers/${containerId}/children/`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is ok for now, but we should put this info in our index. Each of these calls took almost 2 sec on my stack.

Since we don't have the children's info on the index yet (and don't plan to have it soon), we could store an array with the first N types on the Unit document, like you did here in the frontend.
What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree we should put the list of child types in the index (can come in a separate PR). But I wonder why each of these calls takes 2 seconds? That seems very slow and it should be super fast considering our unit code is very new and supposedly lightweight.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created a followup task to fix this: #1778

@bradenmacdonald bradenmacdonald Apr 3, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we are iterating through the records here:
https://github.com/openedx/openedx-learning/blob/a79b579fd3f91c763d193c2e6841fb7f9f4796c7/openedx_learning/apps/authoring/units/api.py#L245-L267

Perhaps we are missing a select_related then. Iterating through the records should still be fast, as long as there are no database queries within the loop. Perhaps we need to select_related on entry.entity_version.componentversion outside the loop before accessing it inside the loop.

Comment thread src/library-authoring/components/ContainerCard.tsx Outdated
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Apr 2, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to In Eng Review in Contributions Apr 2, 2025
@codecov

codecov Bot commented Apr 3, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.50%. Comparing base (451b821) to head (aa2e85e).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/library-authoring/data/apiHooks.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1774   +/-   ##
=======================================
  Coverage   93.49%   93.50%           
=======================================
  Files        1128     1128           
  Lines       22882    22908   +26     
  Branches     4963     4951   -12     
=======================================
+ Hits        21394    21419   +25     
- Misses       1412     1421    +9     
+ Partials       76       68    -8     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pomegranited pomegranited mentioned this pull request Apr 4, 2025

@ChrisChV ChrisChV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! I will merge it on Monday morning

@ChrisChV

ChrisChV commented Apr 7, 2025

Copy link
Copy Markdown
Contributor

@pomegranited Could you fix the conflicts?

@pomegranited

Copy link
Copy Markdown
Contributor Author

@ChrisChV Conflicts fixed -- ready for your merge :)

and remove a line accidentally added when resolving conflicts.
@ChrisChV
ChrisChV merged commit 7ceeb32 into openedx:master Apr 8, 2025
@github-project-automation github-project-automation Bot moved this from In Eng Review to Done in Contributions Apr 8, 2025
@ChrisChV
ChrisChV deleted the jill/fal-4057-unit-card-previews branch April 8, 2025 22:47
ChrisChV pushed a commit to open-craft/frontend-app-authoring that referenced this pull request Apr 9, 2025
Adds block tiles to the Unit card to indicate type and quantity of children in the container.
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

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants