Skip to content

feat: compare library component versions#2986

Open
navinkarkera wants to merge 13 commits intoopenedx:masterfrom
open-craft:navin/FAL-4332/change-state
Open

feat: compare library component versions#2986
navinkarkera wants to merge 13 commits intoopenedx:masterfrom
open-craft:navin/FAL-4332/change-state

Conversation

@navinkarkera
Copy link
Copy Markdown
Contributor

@navinkarkera navinkarkera commented Apr 8, 2026

Description

Add entry-level version preview from history log for library components.

Users can now open Show this version from history entries and view old/new versions in side-by-side comparison modal.

Container entries (section/subsection/unit, including legacy chapter/sequential/vertical) are explicitly excluded from component diff modal actions.

Screenshots:

image image

Useful information to include:

  • Which user roles will this change impact? "Course Author".
Change summary generated by AI

1) History log actions + compare modal

  • Added entry action menu (More actions) in HistoryLogGroup for non-container items.
  • Added Show this version action per history entry.
  • Added new HistoryCompareChangesModal component:
    • Modal title: Preview changes: {title}
    • Item icon in title
    • Uses CompareChangesWidget in side-by-side mode
    • Done button closes modal
  • Wired itemId through draft/publish groups and log pages so each entry knows entity key.

2) Container detection utilities

  • Added isContainerType(containerType) in src/generic/key-utils.ts.
  • Added isContainerUsageKey(usageKey) in src/generic/key-utils.ts.
  • Handles both current and legacy container names:
    • section/subsection/unit
    • chapter/sequential/vertical

3) Compare widget enhancements

  • CompareChangesWidget now supports:
    • sideBySide mode
    • optional showTitle
  • Side-by-side layout uses Paragon Card + Stack and renders two previews at once.
  • Tabbed behavior remains for non-side-by-side flow.

4) LibraryBlock preview behavior

  • Added addHeight?: number prop to LibraryBlock.
  • Iframe height now uses iframeHeight + addHeight.
  • If version === 0, component returns null (prevents invalid preview render).

5) Data model updates

  • Extended LibraryHistoryEntry with:
    • oldVersion?: number
    • newVersion?: number

6) i18n messages

Added new history-log messages:

  • previewChangesTitle
  • moreActions
  • showThisVersion
  • doneButton
Supporting information

Testing instructions

  1. Open library component page with history log entries.
  2. Expand draft history group.
  3. Click More actions on entry.
  4. Click Show this version.
  5. Verify modal opens with title Preview changes: <component title> and correct icon.
  6. Verify side-by-side old/new previews render.
  7. Click Done and verify modal closes.
  8. Repeat from publish history group entry.
  9. Open container history log (unit/section/subsection).
  10. Verify More actions is not shown for container entries.

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 open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Apr 8, 2026
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Apr 8, 2026

Thanks for the pull request, @navinkarkera!

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.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Apr 8, 2026
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Apr 8, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Apr 8, 2026
@navinkarkera navinkarkera force-pushed the navin/FAL-4332/change-state branch from 8c565ac to 08c958f Compare April 27, 2026 09:42
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 97.22222% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.52%. Comparing base (da4e81b) to head (bf0d7ea).

Files with missing lines Patch % Lines
...rc/library-authoring/LibraryBlock/LibraryBlock.tsx 66.66% 1 Missing ⚠️
...generic/history-log/HistoryCompareChangesModal.tsx 94.73% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2986    +/-   ##
========================================
  Coverage   95.52%   95.52%            
========================================
  Files        1392     1393     +1     
  Lines       32911    32967    +56     
  Branches     7340     7592   +252     
========================================
+ Hits        31437    31491    +54     
+ Misses       1419     1408    -11     
- Partials       55       68    +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.

@rpenido
Copy link
Copy Markdown
Contributor

rpenido commented Apr 29, 2026

Hi @navinkarkera!
The preview is always showing the same Published version on both sides, in all cases for me.
history

Comment on lines +191 to +192
oldVersion={changeModalData.oldVersion}
newVersion={changeModalData.newVersion || 'published'}
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 don't have these fields in my objects.

{
  "contributor": {
    "username": "edx",
    "profileImageUrls": {
      "full": "http://studio.local.openedx.io:8001/static/studio/images/profiles/default_500.png",
      "large": "http://studio.local.openedx.io:8001/static/studio/images/profiles/default_120.png",
      "medium": "http://studio.local.openedx.io:8001/static/studio/images/profiles/default_50.png",
      "small": "http://studio.local.openedx.io:8001/static/studio/images/profiles/default_30.png"
    }
  },
  "changedAt": "2026-04-29T20:57:07Z",
  "title": "Text",
  "itemType": "html",
  "action": "edited"
}

I'm using master from edx-platform since openedx/openedx-platform#38178 was merged.

@navinkarkera navinkarkera force-pushed the navin/FAL-4332/change-state branch from 2b98b15 to b9e08f8 Compare April 30, 2026 07:14
Copy link
Copy Markdown
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

@navinkarkera navinkarkera marked this pull request as ready for review May 1, 2026 09:25
@navinkarkera navinkarkera requested a review from ChrisChV May 2, 2026 16:04
Copy link
Copy Markdown
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.

@navinkarkera Looks good. 👍 I commented on a nit.

}

export interface HistoryDraftLogGroupProps {
itemId: string;
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.

Per OEP-68, it is necessary to rename this to itemKey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

5 participants