[TNL-5947] Fix: Don't show visibility settings on library pages. - #14073
[TNL-5947] Fix: Don't show visibility settings on library pages.#14073itsjeyd wants to merge 6 commits into
Conversation
|
Thanks for the pull request, @itsjeyd! It looks like you're a member of a company that does contract work for edX. If you're doing this work as part of a paid contract with edX, you should talk to edX about who will review this pull request. If this work is not part of a paid contract with edX, then you should ensure that there is an OSPR issue to track this work in JIRA, so that we don't lose track of your pull request. |
|
|
||
| elif view_name in PREVIEW_VIEWS + container_views: | ||
| is_pages_view = view_name == STUDENT_VIEW # Only the "Pages" view uses student view in Studio | ||
| is_library_view = view_name == 'container_child_preview' |
There was a problem hiding this comment.
How do we know that only libraries will have the view name "container_child_preview"? Won't that be the case for any child of a container view (for instance, components inside of content experiments/split_test_module)?
FYI @andy-armstrong
There was a problem hiding this comment.
Also, this method shouldn't know anything about libraries. It is unfortunate that this file already has some library-specific logic, but I would very much hope that things that are specific to libraries can remain within library code.
There was a problem hiding this comment.
@cahrens Ah, perhaps the naming of the variable is a little confusing: The library root block itself uses container_preview as a view name. Child blocks that are added to a library use container_child_preview. That view name was added as part of the main content library implementation (#6459), and doesn't seem to be used anywhere else.
I just checked, components inside of content experiments don't use container_child_preview (like child blocks on unit pages, they use reorderable_container_child_preview).
There was a problem hiding this comment.
If the view name is specific to libraries, then yes, I think it should be renamed.
But I also think that this CMS code should not have to know about libraries. Is there no way to keep the logic contained within libraries?
| elif view_name in PREVIEW_VIEWS + container_views: | ||
| is_pages_view = view_name == STUDENT_VIEW # Only the "Pages" view uses student view in Studio | ||
| can_edit = has_studio_write_access(request.user, usage_key.course_key) | ||
| can_edit_visibility = not view_name == 'container_child_preview' |
There was a problem hiding this comment.
I don't think that this rename really helps. It just leads one to wonder why children of containers can't have visibility settings.
What I meant is that the library view name should be renamed so that it is clear that it is specific to libraries. And the library code should be contained with libraries themselves, not put into views/item.py. Adding logic that is specific to libraries in this method is technical debt.
to reflect the fact that this view name is only used for components displayed on library pages.
rendering a newly added component on a library page (instead of setting this info based on view name inside "xblock_view_handler").
| this.render({refresh: true, block_added: block_added}); | ||
| } else { | ||
| this.refreshChildXBlock(xblockElement, block_added, is_duplicate); | ||
| renderParameters = {can_edit_visibility: false}; |
There was a problem hiding this comment.
paged_container is a general class for containers that can be paginated. This is the wrong place to be setting can_edit_visibility (although the general approach seems like a good idea).
The disabling of visibility editing needs to be contained in library-specific code.
There was a problem hiding this comment.
@cahrens Agreed that it would be best to contain disabling of visibility editing in library-specific code. But unless I'm missing something, I'm already doing that here:
There are two files called paged_container.js, cms/static/js/views/pages/paged_container.js and cms/static/js/views/paged_container.js. The code in this file (cms/static/js/views/pages/paged_container.js) seems to be library-specific: On library pages, it is pulled in by cms/static/js/factories/library.js. It is not referenced anywhere else. library.js, in turn, is pulled in by the cms/templates/library.html template for library pages, and is also not referenced by any other JS modules that implement client-side functionality for Studio (as you would expect). That should mean that the code in pages/paged_container.js is only used on library pages.
(It was introduced as part of the main content libraries implementation, #6459.)
There was a problem hiding this comment.
@itsjeyd paged_container is currently only used by libraries, but the intention of the code is to be a general paging container. Fortunately there is an existing extension of paged_container called library_container for example the purpose of putting library-specific code. Can you move the disabling of visibility settings to that class?
There was a problem hiding this comment.
@cahrens That might be possible, but I think it would require a different (possibly more involved) approach: The view defined in library_container (LibraryContainerView) extends the view defined in views/paged_container (PagedContainerView), not the one defined in this file. So it's not a matter of just overriding the refreshXBlock function in LibraryContainerView.
Additionally, the code in PagedContainerView is not (directly) involved in rendering a newly created XBlock; this part of the process is handled by pages/container (XBlockContainerPage) and this file (PagedXBlockContainerPage), as well as the generic XBlockView. Control only moves to PagedContainerView after the new XBlock has been rendered, to update the current page if necessary.
So if we wanted to handle disabling of visibility settings in LibraryContainerView we wouldn't be able to stick with the current approach; that step would have to be handled entirely on the client somehow. I'm not sure if it would it make sense for LibraryContainerView to be responsible for that.
91d221b to
a239786
Compare
|
@itsjeyd Can this PR be closed? I'm shutting down the sandobx because it's broken. |
|
@smarnach Yes, it should be fine to close this PR. |
This PR fixes a bug where components added to a content library would incorrectly display a button for editing visibility settings (that button should be hidden on library pages).
JIRA tickets:
Discussions:
See TNL-5947.
Dependencies:
None
Screenshots:
Content library after adding HTML block (before):
Content library after adding HTMl block (after):
Sandbox URLs:
Deployment targets:
Merge deadline:
ASAP
Testing instructions:
Reviewers