From 5e8b258caca47de8a8002f62ccc943f8a7f8c198 Mon Sep 17 00:00:00 2001 From: Bas Brands Date: Wed, 24 Nov 2021 11:27:33 +0100 Subject: [PATCH] MDL-73114 theme_boost: show page title on Dashboard page replace the page title when the welcome message is shown --- lib/outputrenderers.php | 4 +-- lib/templates/full_header.mustache | 17 ++++----- my/index.php | 2 +- theme/boost/classes/output/core_renderer.php | 8 +---- theme/boost/config.php | 5 +-- .../tests/behat/welcome_to_moodle.feature | 35 +++++++++++++++++++ theme/classic/config.php | 2 +- .../behat/welcome_to_classicmoodle.feature | 32 +++++++++++++++++ 8 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 theme/boost/tests/behat/welcome_to_moodle.feature create mode 100644 theme/classic/tests/behat/welcome_to_classicmoodle.feature diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 6165d02ff4bbc..32a5eb2559673 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -4255,7 +4255,7 @@ public function context_header($headerinfo = null, $headinglevel = 1) { } // The user context currently has images and buttons. Other contexts may follow. - if (isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) { + if ((isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) && $this->page->pagetype !== 'my-index') { if (isset($headerinfo['user'])) { $user = $headerinfo['user']; } else { @@ -4420,7 +4420,7 @@ public function full_header() { $homepage = get_home_page(); $homepagetype = null; // Add a special case since /my/courses is a part of the /my subsystem. - if ($homepage == HOMEPAGE_MY && $this->page->title !== get_string('mycourses')) { + if ($homepage == HOMEPAGE_MY || $homepage == HOMEPAGE_MYCOURSES) { $homepagetype = 'my-index'; } else if ($homepage == HOMEPAGE_SITE) { $homepagetype = 'site-index'; diff --git a/lib/templates/full_header.mustache b/lib/templates/full_header.mustache index 05eec0964abe9..f05a085ac4043 100644 --- a/lib/templates/full_header.mustache +++ b/lib/templates/full_header.mustache @@ -45,18 +45,19 @@
- {{#contextheader}} -
- {{{contextheader}}} -
- {{/contextheader}} -
+ {{^welcomemessage}} + {{#contextheader}} +
+ {{{contextheader}}} +
+ {{/contextheader}} + {{/welcomemessage}} + {{> core/welcome }} +
{{#headeractions}}
{{{.}}}
{{/headeractions}}
- - {{> core/welcome }}
diff --git a/my/index.php b/my/index.php index c3d3e303d256d..b29b0fe16e44a 100644 --- a/my/index.php +++ b/my/index.php @@ -89,7 +89,7 @@ $PAGE->blocks->add_region('content'); $PAGE->set_subpage($currentpage->id); $PAGE->set_title($pagetitle); -$PAGE->set_heading($header); +$PAGE->set_heading($pagetitle); $PAGE->has_secondary_navigation_setter(false); if (!isguestuser()) { // Skip default home page for guests diff --git a/theme/boost/classes/output/core_renderer.php b/theme/boost/classes/output/core_renderer.php index bcbbde013c59e..e207ae391def2 100644 --- a/theme/boost/classes/output/core_renderer.php +++ b/theme/boost/classes/output/core_renderer.php @@ -81,7 +81,7 @@ public function context_header($headerinfo = null, $headinglevel = 1): string { } // The user context currently has images and buttons. Other contexts may follow. - if (isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) { + if ((isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) && $this->page->pagetype !== 'my-index') { if (isset($headerinfo['user'])) { $user = $headerinfo['user']; } else { @@ -179,12 +179,6 @@ protected function render_context_header(\context_header $contextheader) { $heading = $this->heading($contextheader->heading, $contextheader->headinglevel, 'h2'); } - $showheader = empty($this->page->layout_options['nocontextheader']); - if (!$showheader) { - // Return the heading wrapped in an sr-only element so it is only visible to screen-readers. - return html_writer::div($heading, 'sr-only'); - } - // All the html stuff goes here. $html = html_writer::start_div('page-context-header'); diff --git a/theme/boost/config.php b/theme/boost/config.php index bf76d27f7b02a..9d74e8167b0ef 100644 --- a/theme/boost/config.php +++ b/theme/boost/config.php @@ -81,14 +81,15 @@ // My courses page. 'mycourses' => array( 'file' => 'drawers.php', - 'regions' => array() + 'regions' => array(), + 'options' => array('nonavbar' => true), ), // My dashboard page. 'mydashboard' => array( 'file' => 'drawers.php', 'regions' => array('side-pre'), 'defaultregion' => 'side-pre', - 'options' => array('nonavbar' => true, 'langmenu' => true, 'nocontextheader' => true), + 'options' => array('nonavbar' => true, 'langmenu' => true), ), // My public page. 'mypublic' => array( diff --git a/theme/boost/tests/behat/welcome_to_moodle.feature b/theme/boost/tests/behat/welcome_to_moodle.feature new file mode 100644 index 0000000000000..e95698a58db6b --- /dev/null +++ b/theme/boost/tests/behat/welcome_to_moodle.feature @@ -0,0 +1,35 @@ +@javascript @theme_boost +Feature: Welcome message on boost + To be welcome in moodle + As a User + I need to see a welcome message on the first page + + Scenario: Login and be welcomed on the homepage + Given the following config values are set as admin: + | defaulthomepage | 0 | + When I log in as "admin" + Then I should not see "Acceptance test site" in the "page-header" "region" + And I should see "Welcome, Admin!" in the "page-header" "region" + And I reload the page + And I should not see "Welcome, Admin!" in the "page-header" "region" + And I should see "Acceptance test site" in the "page-header" "region" + + Scenario: Login and be welcomed on the dashboard + Given the following config values are set as admin: + | defaulthomepage | 1 | + When I log in as "admin" + Then I should not see "Dashboard" in the "page-header" "region" + And I should see "Welcome, Admin!" in the "page-header" "region" + And I reload the page + And I should not see "Welcome, Admin!" in the "page-header" "region" + And I should see "Dashboard" in the "page-header" "region" + + Scenario: Login and be welcomed on the my courses page + Given the following config values are set as admin: + | defaulthomepage | 3 | + When I log in as "admin" + Then I should not see "My courses" in the "page-header" "region" + And I should see "Welcome, Admin!" in the "page-header" "region" + And I reload the page + And I should not see "Welcome, Admin!" in the "page-header" "region" + And I should see "My courses" in the "page-header" "region" diff --git a/theme/classic/config.php b/theme/classic/config.php index 0f6aff0fd3bff..0094b03980362 100644 --- a/theme/classic/config.php +++ b/theme/classic/config.php @@ -82,7 +82,7 @@ 'file' => 'columns.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-pre', - 'options' => array('nonavbar' => true, 'langmenu' => true, 'nocontextheader' => true), + 'options' => array('langmenu' => true), ), // My public page. 'mypublic' => array( diff --git a/theme/classic/tests/behat/welcome_to_classicmoodle.feature b/theme/classic/tests/behat/welcome_to_classicmoodle.feature new file mode 100644 index 0000000000000..ad6eac7cb0bf7 --- /dev/null +++ b/theme/classic/tests/behat/welcome_to_classicmoodle.feature @@ -0,0 +1,32 @@ +@javascript @theme_classic +Feature: Welcome message on classic + To be welcome in moodle + As a User + I need to see a welcome message on the first page + + Scenario: Login and be welcomed on the homepage + Given the following config values are set as admin: + | defaulthomepage | 0 | + When I log in as "admin" + Then I should see "Acceptance test site" in the "page-header" "region" + And I should see "Welcome, Admin!" in the "page-header" "region" + And I reload the page + And I should not see "Welcome, Admin!" in the "page-header" "region" + + Scenario: Login and be welcomed on the dashboard + Given the following config values are set as admin: + | defaulthomepage | 1 | + When I log in as "admin" + Then I should see "Dashboard" in the "page-header" "region" + And I should see "Welcome, Admin!" in the "page-header" "region" + And I reload the page + And I should not see "Welcome, Admin!" in the "page-header" "region" + + Scenario: Login and be welcomed on the my courses page + Given the following config values are set as admin: + | defaulthomepage | 3 | + When I log in as "admin" + Then I should see "My courses" in the "page-header" "region" + And I should see "Welcome, Admin!" in the "page-header" "region" + And I reload the page + And I should not see "Welcome, Admin!" in the "page-header" "region"