Skip to content

Load waffle flags using React Query #2068

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

Merged
merged 9 commits into from
Jun 5, 2025

Conversation

bradenmacdonald
Copy link
Contributor

@bradenmacdonald bradenmacdonald commented Jun 3, 2025

This PR moves waffle flags out of the redux state and loads them with React Query instead.

Features:

  • the default flag values (e.g. useNewHomePage: true) will be instantly available to the application, but may change once the server responds with updated flags. If you need to not render something until you know its final value for sure, use the isLoading status.
  • Likewise, within a course context, the system-wide waffle flags will be used by default until we've loaded any course-specific flags that may be set.
  • A handy mockWaffleFlags() function is available for use in tests, though only one or two tests are actually using it.

TODO:

How to test:

Verify some waffle flags are working. For example:

  1. Go to http://studio.local.openedx.io:8001/admin/waffle/flag/ and set legacy_studio.advanced_settings to True for Everyone. Now refresh, and the "Advanced Settings" menu in each course should go to the legacy Studio page. Then change it back to False (or remove it) and confirm "Advanced Settings" now stays in the MFE.
  2. Verify that in courses and libraries, the contentstore.use_react_markdown_editor waffle flag controls whether or not the "Switch to markdown editor" button appears. Note that it only works in brand new problems, not editing existing ones.
    Screenshot 2025-06-04 at 11 15 07 AM

Sorry, something went wrong.

@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 Jun 3, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Jun 3, 2025

Thanks for the pull request, @bradenmacdonald!

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.


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 Jun 3, 2025
@bradenmacdonald bradenmacdonald changed the base branch from master to braden/modernize-tests June 3, 2025 01:01
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.03%. Comparing base (9a2dac6) to head (96e7a02).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2068      +/-   ##
==========================================
+ Coverage   94.01%   94.03%   +0.01%     
==========================================
  Files        1162     1163       +1     
  Lines       24434    24441       +7     
  Branches     5187     5305     +118     
==========================================
+ Hits        22972    22982      +10     
+ Misses       1394     1382      -12     
- Partials       68       77       +9     

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

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Jun 3, 2025
@bradenmacdonald bradenmacdonald changed the base branch from braden/modernize-tests to master June 4, 2025 04:06
@bradenmacdonald bradenmacdonald marked this pull request as ready for review June 4, 2025 05:10
@bradenmacdonald bradenmacdonald changed the title [WIP] Load waffle flags using React Query Load waffle flags using React Query Jun 4, 2025
@kdmccormick kdmccormick added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Jun 4, 2025
@kdmccormick kdmccormick self-requested a review June 4, 2025 18:24
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

Copy link
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Looks great. Some non-blocking questions, one request for a longer comment.

I read the code and unit tests, and tested manually on the PR sandbox by adding contentstore.use_react_markdown_editor and confirming that it causes "Switch to Markdown editor" to show up for new problems. I tested with both:

  • instance-level Waffle-on
  • instance-level Waffle-off, and course-level Waffle-on

src/data/api.ts Outdated
| 'useVideoGalleryFlow'
);

/** The default values of waffle flags. helpful if you're overriding them for a test case. */
Copy link
Member

Choose a reason for hiding this comment

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

Can you say more about these? They're not actually edx-platform defaults; rather, they're the default that we test with, right? Or do these defaults actually have significance on the app?

(I see you pulled these from an existing object in src/data/slice.js, so I'm not trying to nitpick this too much, just looking for clarity).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh interesting. I assumed that these defaults matched the platform defaults. These are what the MFE will assume while it's waiting to load the actual values from the server. (If we don't want to assume anything, components that depend on waffle flags should block rendering until isLoading is false, but I think that's a worse experience.)

I would suggest that we follow this up with a PR to either change these defaults to match the platform defaults, or change the platform defaults to match these. But I think that should be isolated to a separate change, since this PR is trying to be an internal refactor that doesn't change behavior meaningfully.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I don't think you should fix these in this PR. Could you just amend your comment to say something like "frontend defaults if we fail to load flags from edx-platform -- may drift from edx-platform's actual defaults".

If you feel moved to, you could write an issue and link it here, but I'm not losing sleep over it. FWIW, my inclination here is actually "turn everything on by default in order to maximize test coverage" rather than "try to keep lockstep with edx-platform."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created a GitHub issue #2094 and put it into the comments.

@kdmccormick
Copy link
Member

@bradenmacdonald Btw, can you confirm whether you're looking to backport this to Teak? I think it would be good to have the markdown editor working in libraries.

@bradenmacdonald
Copy link
Contributor Author

@kdmccormick I could backport a more targeted PR to Teak. i.e. instead of this refactor ("don't pass it in to Editor from three places; check it in Editor"), I can just "pass it in to Editor from Library page too".

@kdmccormick
Copy link
Member

@bradenmacdonald That would be great!

@bradenmacdonald bradenmacdonald merged commit 5991fd3 into openedx:master Jun 5, 2025
7 checks passed
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in Contributions Jun 5, 2025
@bradenmacdonald bradenmacdonald deleted the braden/waffle-flags branch June 5, 2025 18:03
@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@bradenmacdonald
Copy link
Contributor Author

I could backport a more targeted PR to Teak. i.e. instead of this refactor ("don't pass it in to Editor from three places; check it in Editor"), I can just "pass it in to Editor from Library page too".

Backport: #2098

But I think it's blocked on #2099 and I'm not sure who will take that fix on, so for now it's just indefinitely on hold.

bradenmacdonald added a commit to open-craft/frontend-app-authoring that referenced this pull request Jun 10, 2025
This fix is also achieved on master via 5991fd3 / openedx#2068 but this is a simpler fix, not a direct backport of that refactor.
bradenmacdonald added a commit that referenced this pull request Jun 12, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
* fix: enable markdown editor for problems in libraries too

This fix is also achieved on master via 5991fd3 / #2068 but this is a simpler fix, not a direct backport of that refactor.

* fix: remove duplicate markdown_edited save request (#2127)

Removes the unnecessary duplicate save  request of markdown_edited
value to the backend.

Part of: #2099
Backports: 62589ae

---------

Co-authored-by: Muhammad Anas <[email protected]>
ihor-romaniuk pushed a commit to raccoongang/frontend-app-authoring that referenced this pull request Jun 19, 2025
* fix: enable markdown editor for problems in libraries too

This fix is also achieved on master via 5991fd3 / openedx#2068 but this is a simpler fix, not a direct backport of that refactor.

* fix: remove duplicate markdown_edited save request (openedx#2127)

Removes the unnecessary duplicate save  request of markdown_edited
value to the backend.

Part of: openedx#2099
Backports: 62589ae

---------

Co-authored-by: Muhammad Anas <[email protected]>
ihor-romaniuk pushed a commit to raccoongang/frontend-app-authoring that referenced this pull request Jun 20, 2025
* fix: enable markdown editor for problems in libraries too

This fix is also achieved on master via 5991fd3 / openedx#2068 but this is a simpler fix, not a direct backport of that refactor.

* fix: remove duplicate markdown_edited save request (openedx#2127)

Removes the unnecessary duplicate save  request of markdown_edited
value to the backend.

Part of: openedx#2099
Backports: 62589ae

---------

Co-authored-by: Muhammad Anas <[email protected]>
luisfelipec95 pushed a commit to eduNEXT/frontend-app-course-authoring that referenced this pull request Jul 4, 2025

Verified

This commit was signed with the committer’s verified signature.
luisfelipec95 Luis Felipe Castaño
* fix: enable markdown editor for problems in libraries too

This fix is also achieved on master via 5991fd3 / openedx#2068 but this is a simpler fix, not a direct backport of that refactor.

* fix: remove duplicate markdown_edited save request (openedx#2127)

Removes the unnecessary duplicate save  request of markdown_edited
value to the backend.

Part of: openedx#2099
Backports: 62589ae

---------

Co-authored-by: Muhammad Anas <[email protected]>
luisfelipec95 pushed a commit to eduNEXT/frontend-app-course-authoring that referenced this pull request Jul 7, 2025

Verified

This commit was signed with the committer’s verified signature.
luisfelipec95 Luis Felipe Castaño
* fix: enable markdown editor for problems in libraries too

This fix is also achieved on master via 5991fd3 / openedx#2068 but this is a simpler fix, not a direct backport of that refactor.

* fix: remove duplicate markdown_edited save request (openedx#2127)

Removes the unnecessary duplicate save  request of markdown_edited
value to the backend.

Part of: openedx#2099
Backports: 62589ae

---------

Co-authored-by: Muhammad Anas <[email protected]>
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). create-sandbox open-craft-grove should create a sandbox environment from this PR open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants