Skip to content
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

ref: Make react_config available in context #81654

Merged
merged 13 commits into from
Dec 6, 2024
Merged

Conversation

BYK
Copy link
Member

@BYK BYK commented Dec 4, 2024

This patch refactors a 10-year-old hack where we used a template tag to produce the initial data JSON, making the contents of that blob unavailable to any Django template. With this, all views extending from base gets a react_config context object so we can do things like sniffing user's language or theme preferences if available and modify the HTML output based on that.

Related #81611

This patch refactors a 10-year-old hack where we used a template tag to produce the initial data JSON, making the contents of that blob unavailable to any Django template. With this, all views extending from base gets a `react_config` context object so we can do things like sniffing user's language or theme preferences if available and modify the HTML output based on that.

Related #81611
@BYK BYK requested review from JonasBa, markstory and scttcper December 4, 2024 13:07
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Dec 4, 2024
@BYK
Copy link
Member Author

BYK commented Dec 4, 2024

@scttcper - if this works, we should be able to do something like {% block wrapperclass %}theme-{% react_config.user.options.theme %}{% endblock %} in layout.html. Obviously, we need to do something about the default version but I'm confident that we can figure this out.

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #81654      +/-   ##
==========================================
+ Coverage   80.35%   80.46%   +0.10%     
==========================================
  Files        7253     7252       -1     
  Lines      320569   321989    +1420     
  Branches    20859    20811      -48     
==========================================
+ Hits       257600   259082    +1482     
+ Misses      62574    62507      -67     
- Partials      395      400       +5     

Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

Looking good.

@BYK BYK marked this pull request as ready for review December 5, 2024 20:34
@BYK BYK requested a review from a team as a code owner December 5, 2024 20:34
@BYK BYK merged commit 595e932 into master Dec 6, 2024
49 checks passed
@BYK BYK deleted the byk/ref/react_config_template branch December 6, 2024 15:10
mifu67 pushed a commit that referenced this pull request Dec 10, 2024
This patch refactors a 10-year-old hack where we used a template tag to
produce the initial data JSON, making the contents of that blob
unavailable to any Django template. With this, all views extending from
base gets a `react_config` context object so we can do things like
sniffing user's language or theme preferences if available and modify
the HTML output based on that.

Related #81611
BYK added a commit that referenced this pull request Dec 19, 2024
BYK added a commit that referenced this pull request Dec 19, 2024
BYK added a commit that referenced this pull request Dec 20, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants