[BB-933] Allow overriding xblock icons with plugins - #21433
Conversation
|
Thanks for the pull request, @Agrendalath! I've created OSPR-3801 to keep track of it in JIRA, where we prioritize reviews. 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:
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. |
|
@Agrendalath Thank you for your contribution. Please let me know once it is ready for our review. |
viadanna
left a comment
There was a problem hiding this comment.
Good to go 👍
- I tested this locally on my devstack.
- I read through the code.
-
I checked for accessibility issues. -
Includes documentation.
| An API for returning a css class identifying this module in the context of an icon. | ||
| It can be overridden by setting `GET_UNIT_ICON_IMPL` to an alternative implementation. | ||
| """ | ||
| return self.get_icon_class() |
There was a problem hiding this comment.
If this is defined on XModuleMixin, it will only apply to XModule instances, not XBlock ones, which is the newer class. Since this is where get_icon_class is defined too, that's probably fine, but I don't think this needs to be an XModuleMixin method at all... I think it could just be a top-level method in some runtime/xblock utils file, e.g.
@pluggable_override('GET_UNIT_ICON_IMPL')
def get_icon_for_block(block):
return block.get_icon_class()No need to change now, I'm not an official reviewer here, just pointing out options.
There was a problem hiding this comment.
I was wondering about the correct place for this, but wasn't sure how this could be applied to XBlock, as it doesn't have a method for getting an icon. Should we just raise NotImplementedError when we don't find block.get_icon_class method?
There was a problem hiding this comment.
I was wondering about the correct place for this
I think it should be a top level function in xblock_utils/__init__.py. See my example that I'm replying to here.
Should we just raise NotImplementedError when we don't find block.get_icon_class method?
Return 'other' if it doesn't have a get_icon_class method; that's what get_icon_class does if it isn't overridden anyways.
There was a problem hiding this comment.
Sounds good, I'll move this.
|
@bradenmacdonald, thank you for your review! And sorry for addressing it late, I missed this email. |
|
@natabene, this is ready for the review. |
|
@marcotuts Is this something you want to review before it moves to engineering? |
| mod = import_module(module) | ||
| func = getattr(mod, function) | ||
| return func(*args, **kwargs) | ||
| prev_fn = f # The base method in `edx-platform`. |
There was a problem hiding this comment.
This might need to be partial(f, *args, **kwargs) because it becomes the prev_fn arg later, and the other prev_fn args already have the parameters applied?
There was a problem hiding this comment.
That's a good point. Thank you for catching this!
|
@marcotuts, @natabene, any news on this? |
|
@Agrendalath Sorry, no news yet. |
|
@Agrendalath Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future. |
|
@ormsbee - This is ok to move to engineering review. @Agrendalath - One question I have is that this seems like a large change to edx-platform for this plugin, is this largely a file relocation change, or what makes the change seem (at a glance) as large out of curiosity? Thanks! |
|
@marcotuts, we divided monolithic Btw. does the new courseware experience include these icons or is the navigation part altered in some way? |
|
@marcotuts Does the new courseware experience include these icons? |
|
@bradenmacdonald, @Agrendalath - The icons are used in the new learning sequence bar / MFE: https://github.com/edx/frontend-app-learning Note: We haven not yet release an initial version of this to production on edX.org, still in early testing, but included link as FYI for MFE focused on the course learner experience |
|
@natabene Per @marcotuts's comment above (thanks!), could you please update this to "Engineering Review"? I think the status got lost when we mistakenly closed and re-opened the PR.
|
|
@bradenmacdonald The status is currently set to "Awaiting prioritization" and will be changed to "Engineering review" once we start reviewing it. |
|
@Agrendalath Since the current courseware code (that you've modified here) will eventually be replaced by https://github.com/edx/frontend-app-learning , I think it might make sense to rebase this PR and strip out all the JavaScript/frontend changes, then test it with the frontend-app-learning MFE. That will make it easier to review and forwards-compatible. Also I think it's worth calling more attention to the fact that this introduces a generic decorator for overriding any python function and as such provides a new model for platform extensibility - @natabene could we get some light engineering feedback on that approach soon? |
|
@bradenmacdonald, sure, I'll set aside some time for the next sprint to change this. |
|
@Agrendalath Is this good to review now? openedx/edx-django-utils#64 has been merged |
|
@natabene, yes, this is ready for review. We still need to push the new version of edx/edx-django-utils to PyPi (cf. my last comment on openedx/edx-django-utils#109), but this is not a blocker for reviewing this. |
|
@bradenmacdonald Do you still want to review this as a Core Committer? |
|
@natabene Yes, I'm hoping to get to it soon. Thanks! |
bradenmacdonald
left a comment
There was a problem hiding this comment.
👍 Looks great, thanks!
This is a conditional approval; before we merge, please:
- Get the version bump of
edx-django-utilscompleted, and rebase this - Squash down to a single commit following conventional commits
- I tested this: on my devstack, as described
- I read through the code
- I checked for accessibility issues
- Includes documentation
67dd0f3 to
bfef952
Compare
Don't forget this part ;) |
bfef952 to
01cc05a
Compare
This: 1. Introduces a new override using the `pluggable_override` decorator. It is now possible to specify a custom way of getting XBlock's icon by defining `GET_UNIT_ICON_IMPL` in settings. 2. Introduces a way to add custom `XBLOCK_MIXINS` by defining `XBLOCK_EXTRA_MIXINS` in settings. This allows, e.g. to add new fields to XBlocks.
01cc05a to
c4c7197
Compare
|
Your PR has finished running tests. There were no failures. |
|
@Agrendalath 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
Thanks Braden and @Agrendalath . FYI, when squashing, I hard-wrapped your commit message body at ~80 chars. Git doesn't auto-wrap messages very well :) |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |

This is a follow-up to #19772, which allowed setting custom icons for each unit in Studio. By default the icon would be derived from unit's type. The suggestion was to do move it to a plugin. This PR introduces some changes required to move it to external Django application
Most of this diff is about extracting modals from monolithiccms/static/js/views/modals/course_outline_modals.jsto make them reusable. We also extractedCourseOutlineViewclass into a field incms/static/js/views/pages/course_outline.jsto make this view easily extendable.For overriding implementation of getting icon, we implemented
pluggable_overridedecorator.JIRA tickets: OSPR-3801
Merge deadline: None
Sandbox: https://pr21433.sandbox.opencraft.hosting/ (provisioning)
Testing instructions:
masterversion of edx-django-utils in LMS (make lms-shell):pip install -e git+https://github.com/edx/edx-django-utils.git#egg=edx-django-utilsmake lms-shell):pip install -e git+https://github.com/open-craft/custom-unit-icons.git@agrendalath/bb-933-address_override_changes#egg=custom-unit-iconslms/envs/private.pyand runmake lms-restart:Reviewers
Settings
TODO: