Skip to content

fix: restore republish on unit visibility change from outline configure modal#3026

Merged
bradenmacdonald merged 2 commits into
openedx:masterfrom
mitodl:anas/fix-publish-issue
May 1, 2026
Merged

fix: restore republish on unit visibility change from outline configure modal#3026
bradenmacdonald merged 2 commits into
openedx:masterfrom
mitodl:anas/fix-publish-issue

Conversation

@Anas12091101

@Anas12091101 Anas12091101 commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Description

Commit 806135e introduced a ternary that set publish: null when groupAccess was truthy. Since the configure modal always passes groupAccess as {} (an empty object, which is truthy in JS), publish was never set to "republish". The backend requires publish: "republish" to auto-publish visibility changes for units that already have a published version, so changes were silently saved to draft only, requiring a manual publish step to take effect for learners.

Useful information to include:

  • Which user roles will this change impact? "Course Author".
  • Include screenshots for changes to the UI (ideally, both "before" and "after" screenshots, if applicable).

Before

Screen.Recording.2026-04-24.at.8.01.45.PM.mov

After

Screen.Recording.2026-04-24.at.8.05.37.PM.mov

Supporting information

Link to other information about the change, such as GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

Pre-conditions: A course with at least one unit that has already been published.

Steps:

  1. Open the course outline for the course.
  2. Locate a published unit. Confirm learners can see it (visibility status shows "Published").
  3. Click the three-dot menu on the unit → Configure.
  4. Check "Hide from learners" → click Save.
  5. Do not click Publish.
  6. Open the course as a learner (or use the LMS in learner view / masquerade as a student).
  7. Verify the unit is no longer visible to learners without requiring a separate publish step.

Verify the fix is absent (regression check on the broken behavior):

  • On the master branch, repeating steps 1–6 would still show the unit to learners until manually published.

Also test the reverse:

  1. Repeat steps 3–6 but uncheck "Hide from learners" → Save.
  2. Verify the unit becomes visible again to learners immediately.

Also test group access (ensure no regression):

  1. Configure the same unit → Visibility tab → set a group restriction (e.g. restrict to a specific enrollment track).
  2. Save and verify the group restriction is applied correctly.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Avoid propTypes and defaultProps in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Avoid using ../ in import paths. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

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

Copy link
Copy Markdown

Thanks for the pull request, @Anas12091101!

This repository is currently maintained by @bradenmacdonald.

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.

*/
export async function configureCourseUnit(variables: ConfigureUnitData): Promise<object> {
const body = {
publish: variables.groupAccess ? null : variables.type,

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.

@navinkarkera, I am not sure if this was an intentional change in 806135e#diff-d8acab706381e84f07184d02fabb56bdd3c592155995f442f50fdd56493fba52R313. Could you please confirm?

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.

@Anas12091101 Actually, I updated this to match and remove duplicate configure course unit visibility api function: here

This means that before it was not consistent, changing visibility from unit page required a publish while changing visibility from outline did not.

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.

@navinkarkera, has there been a decision to require publishing from the outline page? If so, could you point me to the relevant discussion or reference?

Also, the check variables.groupAccess ? null : variables.type will evaluate to null even when groupAccess is an empty object ({}). Is that intentional?

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.

has there been a decision to require publishing from the outline page? If so, could you point me to the relevant discussion or reference?

@Anas12091101 Nope, I just shared why this change came into picture. I don't mind it in either way (auto publish or not), so no objections to this PR.

Also, the check variables.groupAccess ? null : variables.type will evaluate to null even when groupAccess is an empty object ({}). Is that intentional?

No, like I said, it was copied/moved over from duplicate function from unit page.

@codecov

codecov Bot commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.47%. Comparing base (9c5a4e4) to head (7466b67).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #3026    +/-   ##
========================================
  Coverage   95.47%   95.47%            
========================================
  Files        1381     1381            
  Lines       32563    32565     +2     
  Branches     7228     7445   +217     
========================================
+ Hits        31088    31090     +2     
+ Misses       1419     1406    -13     
- Partials       56       69    +13     

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

@Anas12091101 Anas12091101 moved this from Needs Triage to Ready for Review in Contributions Apr 24, 2026

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

Thanks, especially for the nice testing instructions! Sorry for the delay in reviewing this. If you don't mind opening a backport PR, I'll be happy to merge that too.

@bradenmacdonald bradenmacdonald merged commit f9af238 into openedx:master May 1, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for Review to Done in Contributions May 1, 2026
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.

4 participants