Skip to content

Commit

Permalink
MDL-67577 core_message: navbar_output order
Browse files Browse the repository at this point in the history
* moved the logic from core_message_popup_render_navbar_output to
message_popup_render_navbar_output in message/output/popup/lib.php

* using float: left instead of float: right in theme
  • Loading branch information
Bas Brands committed Jan 27, 2020
1 parent 77a359c commit f18444a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 42 deletions.
33 changes: 0 additions & 33 deletions message/lib.php
Expand Up @@ -783,39 +783,6 @@ function core_message_user_preferences() {
return $preferences;
}

/**
* Renders the popup.
*
* @param renderer_base $renderer
* @return string The HTML
*/
function core_message_render_navbar_output(\renderer_base $renderer) {
global $USER, $CFG;

// Early bail out conditions.
if (!isloggedin() || isguestuser() || user_not_fully_set_up($USER) ||
get_user_preferences('auth_forcepasswordchange') ||
(!$USER->policyagreed && !is_siteadmin() &&
($manager = new \core_privacy\local\sitepolicy\manager()) && $manager->is_defined())) {
return '';
}

$output = '';

// Add the messages popover.
if (!empty($CFG->messaging)) {
$unreadcount = \core_message\api::count_unread_conversations($USER);
$requestcount = \core_message\api::get_received_contact_requests_count($USER->id);
$context = [
'userid' => $USER->id,
'unreadcount' => $unreadcount + $requestcount
];
$output .= $renderer->render_from_template('core_message/message_popover', $context);
}

return $output;
}

/**
* Render the message drawer to be included in the top of the body of each page.
*
Expand Down
11 changes: 11 additions & 0 deletions message/output/popup/lib.php
Expand Up @@ -58,5 +58,16 @@ function message_popup_render_navbar_output(\renderer_base $renderer) {
$output .= $renderer->render_from_template('message_popup/notification_popover', $context);
}

// Add the messages popover.
if (!empty($CFG->messaging)) {
$unreadcount = \core_message\api::count_unread_conversations($USER);
$requestcount = \core_message\api::get_received_contact_requests_count($USER->id);
$context = [
'userid' => $USER->id,
'unreadcount' => $unreadcount + $requestcount
];
$output .= $renderer->render_from_template('core_message/message_popover', $context);
}

return $output;
}
2 changes: 1 addition & 1 deletion message/templates/message_popover.mustache
Expand Up @@ -35,7 +35,7 @@
}

}}
<div class="float-right popover-region collapsed">
<div class="popover-region collapsed" data-region="popover-region-messages">
<a id="message-drawer-toggle-{{uniqid}}" class="nav-link d-inline-block popover-region-toggle position-relative" href="#"
role="button">
{{#pix}} t/message, core, {{#str}} togglemessagemenu, message {{/str}} {{/pix}}
Expand Down
4 changes: 2 additions & 2 deletions message/tests/behat/message_drawer_manage_contacts.feature
Expand Up @@ -44,7 +44,7 @@ Feature: Manage contacts
And I should see "Contact request sent"
And I log out
And I log in as "student4"
Then I should see "2" in the "//*[@data-region='count-container']" "xpath_element"
Then I should see "2" in the "//div[@data-region='popover-region-messages']//*[@data-region='count-container']" "xpath_element"
And I open messaging
And I click on "Contacts" "link"
Then I should see "2" in the "//div[@data-region='view-contacts']//*[@data-region='contact-request-count']" "xpath_element"
Expand All @@ -69,7 +69,7 @@ Feature: Manage contacts
And I should see "Contact request sent"
And I log out
And I log in as "student3"
Then I should see "1" in the "//*[@data-region='count-container']" "xpath_element"
Then I should see "1" in the "//div[@data-region='popover-region-messages']//*[@data-region='count-container']" "xpath_element"
And I open messaging
And I click on "Contacts" "link"
Then I should see "1" in the "//div[@data-region='view-contacts']//*[@data-region='contact-request-count']" "xpath_element"
Expand Down
3 changes: 1 addition & 2 deletions theme/boost/scss/moodle/popover-region.scss
Expand Up @@ -22,7 +22,6 @@ $content-header-footer-height: $region-header-height + $region-footer-height;
}

.popover-region {
float: right;
position: relative;

&.collapsed {
Expand Down Expand Up @@ -177,7 +176,7 @@ $content-header-footer-height: $region-header-height + $region-footer-height;

.navbar {
.popover-region {
float: right;
float: left;
margin-right: 10px;

&.collapsed {
Expand Down
3 changes: 1 addition & 2 deletions theme/boost/style/moodle.css
Expand Up @@ -16265,7 +16265,6 @@ body {
flex-shrink: 0; }

.popover-region {
float: right;
position: relative; }
.popover-region.collapsed .popover-region-toggle:before, .popover-region.collapsed .popover-region-toggle:after {
display: none; }
Expand Down Expand Up @@ -16380,7 +16379,7 @@ body {
display: none; }

.navbar .popover-region {
float: right;
float: left;
margin-right: 10px; }
.navbar .popover-region.collapsed .popover-region-container {
opacity: 0;
Expand Down
3 changes: 1 addition & 2 deletions theme/classic/style/moodle.css
Expand Up @@ -16527,7 +16527,6 @@ body {
flex-shrink: 0; }

.popover-region {
float: right;
position: relative; }
.popover-region.collapsed .popover-region-toggle:before, .popover-region.collapsed .popover-region-toggle:after {
display: none; }
Expand Down Expand Up @@ -16642,7 +16641,7 @@ body {
display: none; }

.navbar .popover-region {
float: right;
float: left;
margin-right: 10px; }
.navbar .popover-region.collapsed .popover-region-container {
opacity: 0;
Expand Down

0 comments on commit f18444a

Please sign in to comment.