Merge pull request #23360 from edx/dcs/studio-nav

Fixed the studio breadcrumbs to show the current chapter/section name.
This commit is contained in:
Dave St.Germain
2020-03-11 09:32:03 -04:00
committed by GitHub
3 changed files with 13 additions and 17 deletions

View File

@@ -121,23 +121,10 @@ def container_handler(request, usage_key_string):
component_templates = get_component_templates(course)
ancestor_xblocks = []
parent = get_parent_xblock(xblock)
action = request.GET.get('action', 'view')
is_unit_page = is_unit(xblock)
unit = xblock if is_unit_page else None
is_first = True
while parent:
if unit is None and is_unit(parent):
unit = parent
elif parent.category != 'sequential':
current_block = {'block': parent, 'children': parent.get_children(), 'is_last': is_first}
is_first = False
ancestor_xblocks.append(current_block)
parent = get_parent_xblock(parent)
ancestor_xblocks.reverse()
unit = xblock if is_unit_page else get_parent_xblock(xblock)
assert unit is not None, "Could not determine unit page"
subsection = get_parent_xblock(unit)
@@ -146,6 +133,15 @@ def container_handler(request, usage_key_string):
section = get_parent_xblock(subsection)
assert section is not None, "Could not determine ancestor section from unit " + six.text_type(unit.location)
# build the breadcrumbs
for block in (section, subsection):
parent = get_parent_xblock(block)
ancestor_xblocks.append({
'title': block.display_name_with_default,
'children': parent.get_children(),
'is_last': block.category == 'sequential'
})
# for the sequence navigator
prev_url, next_url = get_sibling_urls(subsection)
# these are quoted here because they'll end up in a query string on the page,

View File

@@ -88,11 +88,11 @@ class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase):
u'data-locator="{0}" data-course-key="{0.course_key}">'.format(draft_container.location)
),
expected_breadcrumbs=(
u'<a href="/course/{course}{section_parameters}">Week 1</a>.*'
u'<a href="/course/{course}{subsection_parameters}">Lesson 1</a>.*'
u'<a href="/container/{unit_parameters}">Unit</a>.*'
).format(
course=re.escape(six.text_type(self.course.id)),
section_parameters=re.escape(u'?show={}'.format(http.urlquote(self.chapter.location))),
unit_parameters=re.escape(str(self.vertical.location)),
subsection_parameters=re.escape(u'?show={}'.format(http.urlquote(self.sequential.location))),
),
)

View File

@@ -90,7 +90,7 @@ from openedx.core.djangolib.markup import HTML, Text
<ol>
% for block in ancestor_xblocks:
<li class="nav-item">
<span class="title label">${block['block'].display_name_with_default}
<span class="title label">${block['title']}
<span class="icon fa fa-caret-down ui-toggle-dd" aria-hidden="true"></span>
</span>
% if not block['is_last']: