Skip to content

fix: Issue with read-only units in libraries & published version of units in library units picker [FC-0083] - #1926

Merged
ChrisChV merged 2 commits into
openedx:masterfrom
open-craft:chris/FAL-4157-fix-add-unit-bugs
May 12, 2025
Merged

fix: Issue with read-only units in libraries & published version of units in library units picker [FC-0083]#1926
ChrisChV merged 2 commits into
openedx:masterfrom
open-craft:chris/FAL-4157-fix-add-unit-bugs

Conversation

@ChrisChV

@ChrisChV ChrisChV commented May 8, 2025

Copy link
Copy Markdown
Contributor

Description

Fixes the issues from #1633 (comment):

  1. 85b4b5b

In successfully added units, the "add new component" widget appears sometimes. I'm not sure exactly what conditions cause it to appear and not appear, however I noticed it appears after publishing a unit, but not after a subsequent refresh of the page.

  1. 275db21

In the "add existing unit" modal, the preview shows draft versions of units. ie: if a unit is published with 2 components, then a third component is added within the library, but the component and unit are not published, the preview for the unit shows three components. If you open the sidebar, it also shows three components.

Supporting information

Testing instructions

  1. 85b4b5b
  • Go to the library home of a library
  • Create a unit and publish it.
  • Go to a course and add the unit from the library.
  • Verify that the unit is in read-only mode.
  • Change the unit's visibility, verify that the unit is on read-only mode.
  • Change the enable discussion value in unit settings, verify that the unit is on read-onlt mode.
  • Publish the unit. Verify that the unit is on read-only mode.
  1. 275db21
  • Go to the library home of a library
  • Create a uni.
  • Add a component to the unit.
  • Publish the unit.
  • Edit the component
  • Add another component to the unit.
  • DON'T publish the component.
  • Go to a course and open the library units picker.
  • Verify that the unit has only the published component and it shows the published content of the component.

Other information

This issue:

  1. I do not think this is an issue because it appears this behavior only happens with units created before this story was built, but never-published units (that were created prior to "add existing unit" feature) are showing up for me in the 'add unit' modal. I'm able to select and click 'add to unit.' Upon refresh, an empty unit appears
    https://github.com/user-attachments/assets/be87abe5-3ef3-4643-9700-c7cd0e7fc224
    Units created AFTER are not appearing in the "add to unit" modal, so I do not think this is an actual issue?

Has been fixed in openedx/openedx-platform#36630

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

openedx-webhooks commented May 8, 2025

Copy link
Copy Markdown

Thanks for the pull request, @ChrisChV!

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.

@ChrisChV
ChrisChV marked this pull request as draft May 8, 2025 23:45
@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions May 8, 2025
@ChrisChV
ChrisChV force-pushed the chris/FAL-4157-fix-add-unit-bugs branch from c1b95c4 to 85b4b5b Compare May 9, 2025 00:21
@codecov

codecov Bot commented May 9, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.82%. Comparing base (cdb8016) to head (275db21).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1926      +/-   ##
==========================================
- Coverage   93.82%   93.82%   -0.01%     
==========================================
  Files        1147     1147              
  Lines       23976    23983       +7     
  Branches     5155     5057      -98     
==========================================
+ Hits        22495    22501       +6     
- Misses       1413     1414       +1     
  Partials       68       68              

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

@ChrisChV ChrisChV changed the title fix: read-only state of units after any update fix: read-only state of units after any update [FC-0083] May 9, 2025
@ChrisChV
ChrisChV force-pushed the chris/FAL-4157-fix-add-unit-bugs branch from 1cc680f to 98d5557 Compare May 9, 2025 01:53
@ChrisChV
ChrisChV force-pushed the chris/FAL-4157-fix-add-unit-bugs branch from 98d5557 to 275db21 Compare May 9, 2025 02:53
@ChrisChV
ChrisChV marked this pull request as ready for review May 9, 2025 02:54

@pomegranited pomegranited 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.

👍

  • I tested this using the excellent testing instructions on the PR
  • I read through the code
  • I checked for accessibility issues N/A
  • Includes documentation N/A
  • User-facing strings are extracted for translation N/A

@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label May 9, 2025
@ChrisChV ChrisChV changed the title fix: read-only state of units after any update [FC-0083] fix: Issue with read-only units in libraries & published version of units in library units picker [FC-0083] May 9, 2025
@ChrisChV
ChrisChV merged commit 7b2cc12 into openedx:master May 12, 2025
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in Contributions May 12, 2025
@ChrisChV
ChrisChV deleted the chris/FAL-4157-fix-add-unit-bugs branch May 12, 2025 14:45
ChrisChV added a commit to open-craft/frontend-app-authoring that referenced this pull request May 12, 2025
…nits in library units picker [FC-0083] (openedx#1926)

Fixes the issues from openedx#1633 (comment)

* In successfully added units, the "add new component" widget appears sometimes
* In the "add existing unit" modal, the preview shows draft versions of units
const { unitId, readOnly } = useLibraryContext();
const { readOnly, showOnlyPublished } = useLibraryContext();
const { sidebarComponentInfo } = useSidebarContext();
const unitId = sidebarComponentInfo?.id;

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.

@ChrisChV This is breaking unit page when you select any component inside it and reload. The reason being that sidebarComponentInfo?.id is set to component when selected. Getting unitId from useLibraryContext fixes it, but I might be missing something. Is a reason for doing this?

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.

When I wanted to add a unit to a course, in the component picker, when I opened the unit info sidebar, it generated an error in the context. This code fixed that, but when I reverted that code, it seems that it no longer generates the error, so I think it's safe to revert the code 👍

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