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

Minimal Library Asset Support #1383

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Conversation

ormsbee
Copy link
Contributor

@ormsbee ormsbee commented Oct 15, 2024

This is a subset of #1349 that doesn't have all the Files & Uploads changes, but just has:

  • refactor: switch Content Library XBlock preview to Studio
  • fix: disable static asset mangling for v2 Content Libraries

@ormsbee ormsbee requested a review from a team as a code owner October 15, 2024 04:38
@ormsbee ormsbee mentioned this pull request Oct 15, 2024
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.04%. Comparing base (66b14a5) to head (234496b).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1383      +/-   ##
==========================================
+ Coverage   93.01%   93.04%   +0.02%     
==========================================
  Files        1035     1043       +8     
  Lines       19632    19956     +324     
  Branches     4172     4223      +51     
==========================================
+ Hits        18261    18568     +307     
- Misses       1306     1326      +20     
+ Partials       65       62       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@Ian2012 Ian2012 left a comment

Choose a reason for hiding this comment

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

Tested locally, working ok.

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.

only nits, merge away

// because the code currently just doesn't handle it correctly. Libraries don't mangle the path
// into an asset key–it might be sufficient to remove the initial "/" in a "/static/images/foo.png"
// link, and then set the base URL to the correct ComponentVersion base.
if (!learningContextId.startsWith('lib:')) {
Copy link
Member

Choose a reason for hiding this comment

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

[nit]

Suggested change
if (!learningContextId.startsWith('lib:')) {
if (!isLibraryKey(learningContextId)) {

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, we have key helper methods in src/generic/key-utils.ts

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 hadn't realized. Will do.

// into an asset key–it might be sufficient to remove the initial "/" in a "/static/images/foo.png"
// link, and then set the base URL to the correct ComponentVersion base.
if (!learningContextId.startsWith('lib:')) {
// assets in expandable text areas so not support relative urls so all assets must have the lms
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// assets in expandable text areas so not support relative urls so all assets must have the lms
// assets in expandable text areas do not support relative urls so all assets must have the lms

not your typo, but so->do

// So until we handle it better, just disable static asset URL substitutions
// when dealing with Library content.
return false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bradenmacdonald, @kdmccormick: I changed this to be a simpler early return–since I realized that this function returns false if it finds no matching static URLs.

Copy link
Member

Choose a reason for hiding this comment

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

LGTM!

edx-platform commit 7316111 (PR #35598) moved the XBlock embed view so
that it can be rendered on either LMS or Studio. This commit moves the
frontend to actually call the Studio endpoint. This will make Content
Library static asset display easier, because that view will only be made
available through Studio and not the LMS.
The static asset substitution used to make images show up properly when
in the TinyMCE editor doesn't work for Content Libraries. Unfortunately,
this will cause the static asset references in XBlock content to get
mangled and saved incorrectly. So until we can handle it correctly,
we're just going to disable it entirely if the LearningContext is a v2
Content Library.

This means that static assets won't display properly in the editor
itself, but it should at least get written/preserved correctly, so that
those assets will show up properly in XBlock previews.
@ormsbee ormsbee force-pushed the minimal-asset-support branch from 0cfac35 to 234496b Compare October 16, 2024 15:10
@ormsbee ormsbee merged commit 1bdea09 into openedx:master Oct 16, 2024
8 checks passed
@ormsbee ormsbee deleted the minimal-asset-support branch October 16, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants