Course unit page - Three dots menu permissions

Use case

Transfer to xblock API view Three dots menu Action fields, so it’s possible to conditionally display those actions in the frontend-course-authoring based on user’s role.

  • expand of already existed container children API with actions(can_copy, can_duplicate, can_move, can_manage_access, can_delete)

PR with initial endpoint implementation - https://github.com/openedx/edx-platform/pull/34036

Problem statement

We are currently working with rendering unit’s children.
For each xblock need to have actions which are responsible for displaying the availability of an action.
We wanted to use JSON structure below:

{ "children": [ { "name": "Drag and Drop", "block_id": "block-v1:org+101+101+type@drag-and-drop-v2+block@7599275ace6b46f5a482078a2954ca16", "block_type": "drag-and-drop-v2", "actions": { "can_copy": true, "can_duplicate": true, "can_move": true, "can_manage_access": true, "can_delete": true } }, ... ] }

 

But we faced with problem getting condition for displaying these actions.
The required condition placed in _studio_wrap_xblock where runtime wraps the block with template studio_xblock_wrapper.html and collects context on previous function calls.

def xblock_view_handler -> get_preview_fragment -> -> _load_preview_block -> -> -> _prepare_runtime_for_preview -> -> -> -> _studio_wrap_xblock:

Right now it is problematic to get the context from there because of the nesting, so can we use other conditions to display?

The main question: what is the best approach to add those actions without refactoring the code around _studio_wrap_xblock

The mocked actions (always set to True) were added in the PR: https://github.com/raccoongang/edx-platform/pull/2494/files#diff-fcd65c5bab25478ab25e92d58b53a090ec0141ef462e24bd88052917dba52cafR105

Additional context

Existing implementation (legacy studio) notes

Below you can see the list of three dots menu actions with references to places in which the action context field is populated.


COPY from _studio_wrap_xblockis_course

python

POST http://localhost:18010/api/content-staging/v1/clipboard/{ usage_key: xblock_id}action: save in store

DUPLICATE from _studio_wrap_xblockcan_add

python


MOVE from _studio_wrap_xblockcan_move

python


MANAGE ACCESS from _studio_wrap_xblockcan_edit_visibility

send metadata with user_partition_info


DELETE from _studio_wrap_xblockcan_add

python


Label Text from _studio_wrap_xblock -> selected_groups_label

image-20240207-165223.png

Manage tags use_tagging = use_tagging_taxonomy_list_page()

 

References

 

Copy/paste extension for Action fields in legacy interface: PR: https://github.com/openedx/edx-platform/pull/31853/ "