MDL-73646 navigation: Fix breadcrumbs for site admin

Fix the breadcrumbs for site administration page.
Created a new public method get_active_method for the same.
This commit is contained in:
Sujith Haridasan 2022-02-01 19:48:16 +05:30
parent c352b70022
commit 3eda637c44
4 changed files with 40 additions and 4 deletions

View File

@ -106,7 +106,7 @@ class primary extends view {
} else if (in_array($this->context->contextlevel, [CONTEXT_COURSE, CONTEXT_MODULE])) {
$activekey = 'courses';
} else if (in_array('siteadminnode', $children) && $node = $this->get_site_admin_node()) {
if ($this->context->contextlevel == CONTEXT_COURSECAT || $node->search_for_active_node()) {
if ($this->context->contextlevel == CONTEXT_COURSECAT || $node->search_for_active_node(URL_MATCH_EXACT)) {
$activekey = 'siteadminnode';
}
}

View File

@ -645,14 +645,15 @@ class navigation_node implements renderable {
/**
* Searches all children for the best matching active node
* @param int $strength The url match to be made.
* @return navigation_node|false
*/
public function search_for_active_node() {
if ($this->check_if_active(URL_MATCH_BASE)) {
public function search_for_active_node($strength = URL_MATCH_BASE) {
if ($this->check_if_active($strength)) {
return $this;
} else {
foreach ($this->children as &$child) {
$outcome = $child->search_for_active_node();
$outcome = $child->search_for_active_node($strength);
if ($outcome !== false) {
return $outcome;
}

View File

@ -171,6 +171,8 @@ value to get the list of blocks that won't be displayed for a theme.
MESSAGE_DEFAULT_PERMITTED also deprecated.
core_message_get_user_notification_preferences and core_message_get_user_message_preferences Webservice are now returning enabled boolean on
components > notifications > processors. loggedin and loggedoff are deprecated but present for backward compatibility.
* A new parameter $strength of type int is added to method search_for_active_node. This parameter would help us to search for the active nodes based on the
$strength passed to it.
=== 3.11.4 ===
* A new option dontforcesvgdownload has been added to the $options parameter of the send_file() function.

View File

@ -0,0 +1,33 @@
@javascript @theme_boost
Feature: Breadcrumbs navigation
To navigate in boost theme
As an admin user
I should see breadcrumbs
Scenario: Admin user navigates to site administrations plugins assignment settings
Given I log in as "admin"
When I navigate to "Plugins > Activity modules > Assignment > Assignment settings" in site administration
Then I should see "Activity modules" in the ".breadcrumb" "css_element"
And I should see "Assignment" in the ".breadcrumb" "css_element"
And I should see "Assignment settings" in the ".breadcrumb" "css_element"
Scenario: Admin user navigates to site adminsitrations plugins assignment feedback offline grading worksheet
Given I log in as "admin"
When I navigate to "Plugins > Activity modules > Assignment > Feedback plugins > Offline grading worksheet" in site administration
Then I should see "Activity modules" in the ".breadcrumb" "css_element"
And I should see "Assignment" in the ".breadcrumb" "css_element"
And I should see "Feedback plugins" in the ".breadcrumb" "css_element"
And I should see "Offline grading worksheet" in the ".breadcrumb" "css_element"
Scenario: Admin user navigates to site adminsitrations plugins badges manage backpacks page
Given I log in as "admin"
When I navigate to "Badges > Manage backpacks" in site administration
Then I should see "Badges" in the ".breadcrumb" "css_element"
And I should see "Manage backpacks" in the ".breadcrumb" "css_element"
Scenario: Admin user navigates to site adminsitrations plugins caching memcached page
Given I log in as "admin"
When I navigate to "Plugins > Caching > Cache stores > Memcached" in site administration
Then I should see "Caching" in the ".breadcrumb" "css_element"
Then I should see "Cache stores" in the ".breadcrumb" "css_element"
And I should see "Memcached" in the ".breadcrumb" "css_element"