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
Allow Runtime Configuration #104
Allow Runtime Configuration #104
Conversation
Codecov ReportBase: 69.20% // Head: 69.64% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #104 +/- ##
==========================================
+ Coverage 69.20% 69.64% +0.43%
==========================================
Files 14 16 +2
Lines 276 280 +4
Branches 63 63
==========================================
+ Hits 191 195 +4
Misses 85 85
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
package.json
Outdated
@@ -51,6 +51,7 @@ | |||
"prop-types": "15.8.1", | |||
"react": "16.14.0", | |||
"react-dom": "16.14.0", | |||
"react-helmet": "^6.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to this blog https://www.freecodecamp.org/news/react-helmet-examples/ react-helmet is considered deprecated, and react-helmet-async https://github.com/staylor/react-helmet-async is the new version. Do you have any more information about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @cdeery for your review
The main reason to decided to use react-helmet was other apps like frontend-app-learning
were using it. https://github.com/openedx/frontend-app-learning/blame/master/package.json#L54
I am not able to find more information about an officially deprecated announcement, but that seems to be deprecated according to nfl/react-helmet#689 (in addition the last commit date was 2020) and at the same time is still used for the community check date of this issue nfl/react-helmet#693
We could make the change of the library to react-helmet-async
And @arbrandes this could be something to consider for the FWG, due to different apps are using this library (don´t seem to be a problem with the actual environment but maybe new versions of react don't support it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this looks like a concern for more repos than just this one.
It doesn't excuse us from doing the right thing, of course. @cdeery, would an issue to tackle this across the board be enough to otherwise merge this as is? This is something @abdullahwaheed and FED-BOM could probably help us with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check how react-helmet-async
could be used, for this specific case I think a new context is too much for the purpose of this change then I use another implementation explained in the official repo.
I create a commit to put this into consideration and find the best way to make the change to the library. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dcoa for making this change. I think this is much better. I understand that other teams are using the older version, but this helps with not creating tech debt.
This generally looks ok to me. I am not sure what you mean by using a context is "too much", I would be surprised if it added a noticeable burden to the app. My inclination would be to use the library as indicated as the common pattern, because it looks like it would avoid any bugs that might occur if the explicit argument passing is missed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cdeery I made the changes to use HelmetProvider
, let me know what you think. :)
Thanks for the pull request, @Jacatove! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
4072b8c
to
9eaba30
Compare
09e3ea0
to
6378dfb
Compare
src/index.jsx
Outdated
|
||
subscribe(APP_READY, () => { | ||
ReactDOM.render( | ||
<AppProvider> | ||
<Head /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, but I'm confused by this. If the HelmetProvider is a context, then I would expect it to wrap everything that might modify the head.
<AppProvider>
<HelmetProvider context={helmetContext}>
<Head />
<Header/>
... everything else...
</HelmetProvider>
</AppProvider>
That way, anything that accesses the header is in the context of the provider.
And then the Head implementation contains a Helmet instance that wraps the header metadata.
Am I misunderstanding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, other components can't modify the favicon and title tag, because the values come directly from the config (comes from AppProvider
), that's why I don't think the provider has to wrap all the components inside the app.
Let me know if that makes sense either I'm okay to make the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I see. I think that it would be best to still use the pattern where the app is wrapped for a couple of reasons, but I can see where they don't seem related to the problem you are solving:
- This is the first use of react-helmet-async, and will end up being copy and pasted into other projects as an example. Other projects may use it for other reasons.
- If the use of it is expanded in the future for header metadata that might be modified by the application, having the context wrapping it will make those changed "just work", eliminating bugs and debugging.
If you're ok to make the change, I would really appreciate it. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the change, could you take a look, please? @cdeery
6378dfb
to
6e46f16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thank you for making the changes. This looks good.
@Jacatove 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
Description
This PR is part of the work to make it possible to configure the frontend applications at runtime (you can refer to this openedx/wg-frontend#103).
Changes
Screenshot
In progress
How to test
{
"SITE_NAME": "Test Site",
"LOGO_URL": "https://testimage.com/logo.svg",
"LOGO_TRADEMARK_URL": "https://testimage.com/logo.svg",
"LOGO_WHITE_URL": "https://testimage.com/logo.svg",
"FAVICON_URL": "https://testimage.com/favicon.ico",
}