-
Notifications
You must be signed in to change notification settings - Fork 82
Allow customization of external URLs #809
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 customization of external URLs #809
Conversation
|
Thanks for the pull request, @wgu-taylor-payne! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #809 +/- ##
==========================================
+ Coverage 86.79% 87.12% +0.33%
==========================================
Files 48 48
Lines 1401 1406 +5
Branches 297 300 +3
==========================================
+ Hits 1216 1225 +9
+ Misses 172 168 -4
Partials 13 13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
086fe61 to
276fff7
Compare
276fff7 to
cac5048
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.
Pull Request Overview
This PR introduces the getExternalLinkUrl function to allow customization of external URLs by providing a custom mapping via the configuration object. Key changes include:
- Adding the getExternalLinkUrl function in src/config.js with accompanying documentation.
- Introducing thorough tests in src/getExternalLinkUrl.test.js to cover various scenarios.
- Updating relevant documentation in README.md and example usage in ExamplePage.jsx.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/index.js | Updated re-exports to include getExternalLinkUrl. |
| src/getExternalLinkUrl.test.js | Added tests to validate getExternalLinkUrl behavior under multiple scenarios. |
| src/config.js | Introduced getExternalLinkUrl function and updated documentation for external URL customization. |
| example/ExamplePage.jsx | Demonstrated usage of getExternalLinkUrl in a React example page. |
| env.config.js | Provided a sample customExternalUrls mapping in the configuration object. |
| README.md | Updated instructions to guide users on configuring custom external links with getExternalLinkUrl. |
Files not reviewed (1)
- .env.development: Language not supported
Comments suppressed due to low confidence (1)
src/config.js:315
- The docstring states that a warning is logged for invalid URLs, but the implementation does not log any warning. Consider updating the documentation or adding the warning logging for consistency.
* If the input URL is invalid, a warning is logged and '#' is returned.
|
I'm not going to be able to provide a comprehensive review on this PR. But I do wonder why the values in |
|
The ports in |
arbrandes
left a comment
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 love the included documentation and tests, thank you! The code looks great, too.
I only raised a matter of function/object naming, which we should discuss before merging.
1edd96e to
a41e178
Compare
brian-smith-tcril
left a comment
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.
Overall this looks great! Would you be able to move the .env changes and the README changes that aren't related to URL overrides to a separate PR? I think they're valuable changes but I'd prefer to keep this PR targeted to the one task.
Create the getExternalLinkUrl function and make it available for use in frontend apps. It checks for a `customExternalUrls` object in the config to see if a custom URL has been provided for a given URL. Use getExternalLinkUrl in the example app for this package. One link is overridden with a custom URL while the other is not.
fa6db41 to
1dc67f9
Compare
brian-smith-tcril
left a comment
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.
Thank you so much for putting this together!
LGTM!
arbrandes
left a comment
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.
Looks great! 👍🏼
|
Hey did we ever document this somewhere? We should document it for the Ulmo release. |
This PR includes an update to the readme https://github.com/openedx/frontend-platform?tab=readme-ov-file#overriding-default-external-links |
Description:
This adds a
getExternalLinkUrlfunction to theconfig.jsmodule. This provides a way for external links to be customized/overridden in frontend apps. To customize links, it is required to provide aexternalLinkUrlOverridesobject as part of the config object defined inenv.config.js. This object maps default URLs to custom URLs. Given a URL, thegetExternalLinkUrlwill check the config object viagetConfigfor a matching key, and if found, will return the value, which is a custom URL to be used in place of the default URL. If no match is found, the function will return the URL passed in (if it is a valid string).getExternalLinkUrlcan be used when no custom configuration is provided. Also, it will still work in these cases:externalLinkUrlOverridesdoes not exist in the config object.externalLinkUrlOverridesexists, but is empty.externalLinkUrlOverridesexists, and is not empty, but does not contain a mapping for the URL provided.In all of these scenarios, the URL passed into the function will be returned to the function. An exception to this is the case where an invalid argument is supplied to the
urlparameter. In this case the function will fall back to a default value of'#'.Closes #798
Merge checklist:
frontend-platform. This can be done by runningnpm startand opening http://localhost:8080.module.config.jsfile infrontend-build.fix,feat) and is appropriate for your code change. Consider whether your code is a breaking change, and modify your commit accordingly.Post merge: