-
Notifications
You must be signed in to change notification settings - Fork 170
fix: only convert assets static file path #2702
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
base: master
Are you sure you want to change the base?
fix: only convert assets static file path #2702
Conversation
|
Thanks for the pull request, @marslanabdulrauf! 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. 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
47ad753 to
a15ea7c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2702 +/- ##
=======================================
Coverage 94.85% 94.86%
=======================================
Files 1232 1233 +1
Lines 27899 27941 +42
Branches 6316 6354 +38
=======================================
+ Hits 26464 26506 +42
Misses 1364 1364
Partials 71 71 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // Check if this is a direct /static/filename.ext pattern (should be converted) | ||
| // vs /static/images/filename.ext pattern (should NOT be converted) |
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.
Technically, I think it is possible to have files in "Files & Uploads" for a course that have subdirectories, but it's rare, so I think this is a reasonable compromise for how to implement this. It is extremely unfortunate that our convention for specifying course assets as /static/foo.ext is in the same namespace as actual system-wide static files like /static/images/placeholder-faculty.png.
An alternative solution would be to move the placeholder-faculty image somewhere else, so it's served with a completely different URL or even changed into an inline SVG. Then we probably wouldn't need to worry about other usages of /static/ and can just assume they're all course assets. I'm wondering if you think that's a cleaner solution?
If we stick with this approach, I do think it would be good to add a couple more lines to the comment here to explain why we're not converting images with subfolders (because even though they may be course assets they're more likely to be some example images that are in Django's static folder).
CC @ormsbee who has more knowledge than me about static assets and their paths.
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.
An alternative solution would be to move the placeholder-faculty image somewhere else, so it's served with a completely different URL or even changed into an inline SVG. Then we probably wouldn't need to worry about other usages of /static/ and can just assume they're all course assets. I'm wondering if you think that's a cleaner solution?
We have a number of static assets under cms > images, lms > images, and common > images. From what I can tell, we are actively using two of the “placeholder” images:
- placeholder-faculty.png
- placeholder-image.png
If that's the full set, then yes, in theory we could move these to a separate folder outside of /static/ without much friction.
However, since images are conventionally served from static paths, it might be more appropriate to leave them where they are. @ormsbee would have better historical context on whether moving these makes sense.
If we stick with this approach, I do think it would be good to add a couple more lines to the comment here to explain why we're not converting images with subfolders (because even though they may be course assets they're more likely to be some example images that are in Django's static folder).
I'll add more detail to the comment 👍
Just to clarify: we’re not excluding all subfolders, only the images/ subfolder.
|
When I use the testing steps from #2668, this fix is only sort of working. When I load the page, it still shows "You've made some changes", and one of the images (using a studio URL like |
|
Thanks @bradenmacdonald for the review. I have added extra comments and fixed the issue where images are only updated when we click anywhere in the editor. |
|
Thanks @marslanabdulrauf. I was just hoping to get some input from @ormsbee or other people before moving this forward. |
Related Ticket:
#2668
https://github.com/mitodl/hq/issues/9166#event-20756793537 (MIT Internal)
Description
This PR updates
replaceStaticWithAssetfunction to not update non-asset static file path e.g;/static/filename.extis path for assets(file) while/static/images/filename.extis standalone file path that don't need to be converted into assets url (/asset-v1:...)Testing instructions
Follow the instructions from #2668 description, just skip the 1st point, don't disable
replaceStaticWithAssetfunction.Best Practices Checklist
We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:
.ts,.tsx).propTypesanddefaultPropsin any new or modified code.src/testUtils.tsx(specificallyinitializeMocks)apiHooks.tsin this repo for examples.messages.tsfiles have adescriptionfor translators to use.../in import paths. To import from parent folders, use@src, e.g.import { initializeMocks } from '@src/testUtils';instead offrom '../../../../testUtils'