Skip to content

feat: Add slots to add tab links and add mechanism for plugin routes #1645

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

xitij2000
Copy link
Contributor

@xitij2000 xitij2000 commented Mar 21, 2025

Description

This PR adds mechanisms to add course tabs using a frontend plugin.

It includes two plugin slots:

  • course_tab_links_slot: This slot allows adding additional course tabs or modifying existing course tabs.
  • course_page_route_slot: This slot allows create a full new page in the learning MFE.

It also adds a new mechanism to add course routes using the PLUGIN_ROUTES config. This is a simple array that adds new routes for the MFE that can then be handled by plugins.

The combination of the above will allow injecting a new course tab by:

  • Adding a new route to the PLUGIN_ROUTES array.
  • Adding a slot to the course page route slot so that the page is rendered on that route
  • Adding a new link to the course_tab_links_slot.

It is also possible to add the links anywhere else, to simply add new pages that are not tabs.

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

openedx-webhooks commented Mar 21, 2025

Thanks for the pull request, @xitij2000!

This repository is currently maintained by @openedx/committers-frontend-app-learning.

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.


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.

Copy link

codecov bot commented Mar 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@ddbc212). Learn more about missing BASE report.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1645   +/-   ##
=========================================
  Coverage          ?   90.50%           
=========================================
  Files             ?      347           
  Lines             ?     5837           
  Branches          ?     1363           
=========================================
  Hits              ?     5283           
  Misses            ?      537           
  Partials          ?       17           

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

@itsjeyd itsjeyd added the core contributor PR author is a Core Contributor (who may or may not have write access to this repo). label Apr 1, 2025
@itsjeyd itsjeyd moved this from Needs Triage to Waiting on Author in Contributions Apr 1, 2025
@xitij2000 xitij2000 force-pushed the kshitij/tab-slots branch 2 times, most recently from 83693c3 to b9df318 Compare May 2, 2025 06:54
@xitij2000 xitij2000 force-pushed the kshitij/tab-slots branch 2 times, most recently from 7245d96 to e040882 Compare June 9, 2025 11:28
@xitij2000 xitij2000 marked this pull request as ready for review June 9, 2025 11:29
@itsjeyd itsjeyd moved this from Waiting on Author to Ready for Review in Contributions Jun 12, 2025
@itsjeyd itsjeyd added the waiting for eng review PR is ready for review. Review and merge it, or suggest changes. label Jun 12, 2025
@itsjeyd itsjeyd requested a review from a team June 12, 2025 09:04
@xitij2000 xitij2000 force-pushed the kshitij/tab-slots branch 3 times, most recently from d6afeb0 to 7affcf0 Compare June 20, 2025 13:45
@xitij2000 xitij2000 force-pushed the kshitij/tab-slots branch from 7affcf0 to fd9df35 Compare June 20, 2025 13:47
@xitij2000
Copy link
Contributor Author

@bradenmacdonald Would love to get your thoughts on the approach used in this PR. It's doing a few non-standard things.

We wanted to add a new course tab, for which we need two things.

  1. We need some way to add an actual tab. This is a straightforward slot.
  2. We need some place for the tab to link to.

To add a new page that feels like part of the platform we need some way to extend the routes to allow creating a new page. I tried making the routes pluggable, but the router refuses to work with components that aren't a Route. Which led to the approach used here, which is to add a config value for defining new routes, each route gets its own slot so you can create a new page there.

@bradenmacdonald
Copy link
Contributor

@xitij2000 I don't think plugins can add <Route> objects directly, because as you said, the Router won't accept any children that aren't <Route>. But I think what you can do is add a catch-all route going to an empty page that has a plugin slot and on that page, each plugin can add a <Routes><Route ... /></Routes> entry as a separate slot, and that will work fine.

This is because:

  • <Routes> can appear anywhere within the page hierarchy
  • Multiple <Routes> can even appear on the same page

See https://github.com/openedx/frontend-app-authoring/blob/aeefcc639f430c4769b0903cad0da7977cb40cf3/src/pages-and-resources/PagesAndResources.jsx#L88-L93 for an example of this. It's not wrapped in a plugin slot, but it would work just the same way if it were.

Also, I think we want to move away from a very config-heavy plugin approach toward something where plugins "register themselves" and require minimal config other than installation, so I think this sort of approach (adding <Routes> to an empty slot) is better long-term.

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). open-source-contribution PR author is not from Axim or 2U waiting for eng review PR is ready for review. Review and merge it, or suggest changes.
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

4 participants