Skip to content

Commit

Permalink
Upgrade: Boost Union settings were moved to an admin settings categor…
Browse files Browse the repository at this point in the history
…y of its own to support the new theme chooser on Moodle 4.4, resolves #482. (#609)
  • Loading branch information
abias authored Mar 27, 2024
1 parent 912b60d commit c19c1fe
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 61 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changes

### Unreleased

* 2024-03-25 - Upgrade: Boost Union settings were moved to an admin settings category of its own to support the new theme chooser on Moodle 4.4, resolves #482.
Please note: This change is backported to Moodle 4.3 to 4.1.
* 2024-03-22 - Upgrade: Migrate the before_standard_html_head() function to the new hook callback on Moodle 4.4, resolves #604.

### v4.3-r10
Expand Down
16 changes: 9 additions & 7 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@
// stupid "Too much data passed as arguments to js_call_amd..." debugging message if we would
// pack all settings onto just one settings page.
// To achieve this goal, we create a custom admin settings category and fill it with several settings pages.
// However, there is still the $settings variable which is expected by Moodle coreto be filled with the theme
// settings and which is automatically added to the admin settings tree in one settings page.
// To avoid that there appears an empty "Boost Union" settings page near our own custom settings category,
// we set $settings to null.

// Avoid that the theme settings page is auto-created.
$settings = null;
// However, there is still the $settings variable which is expected by Moodle core to be filled with the theme
// settings and which is automatically linked from the theme selector page.
// To avoid that there appears a broken "Boost Union" settings page, we redirect the user to the settings
// category if he opens this page.
$mainsettingspageurl = new moodle_url('/admin/settings.php', ['section' => 'themesettingboost_union']);
if ($ADMIN->fulltree && $PAGE->has_set_url() && $PAGE->url->compare($mainsettingspageurl)) {
redirect(new moodle_url('/admin/category.php', ['category' => 'theme_boost_union']));
}

// Create custom admin settings category.
$ADMIN->add('themes', new admin_category('theme_boost_union',
$ADMIN->add('appearance', new admin_category('theme_boost_union',
get_string('pluginname', 'theme_boost_union', null, true)));

// Create empty settings page structure to make the site administration work on non-admin pages.
Expand Down
8 changes: 4 additions & 4 deletions tests/behat/behat_theme_boost_union_base_smartmenus.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class behat_theme_boost_union_base_smartmenus extends behat_base {
*/
public function i_navigate_to_smartmenus() {
$this->execute('behat_navigation::i_navigate_to_in_site_administration',
['Appearance > Themes > Boost Union > Smart menus']);
['Appearance > Boost Union > Smart menus']);
}

/**
Expand All @@ -53,7 +53,7 @@ public function i_navigate_to_smartmenus() {
*/
public function i_navigate_to_smartmenu_item($menu) {
$this->execute('behat_navigation::i_navigate_to_in_site_administration',
['Appearance > Themes > Boost Union > Smart menus']);
['Appearance > Boost Union > Smart menus']);
$this->execute('behat_general::i_click_on_in_the', ['.action-list-items', 'css_element', $menu, 'table_row']);
}

Expand All @@ -66,7 +66,7 @@ public function i_navigate_to_smartmenu_item($menu) {
*/
public function i_create_smartmenu_with_the_following_fields_to_these_values(TableNode $data) {
$this->execute('behat_navigation::i_navigate_to_in_site_administration',
['Appearance > Themes > Boost Union > Smart menus']);
['Appearance > Boost Union > Smart menus']);
$this->execute('behat_general::i_click_on', ['Create menu', 'button']);
$this->execute('behat_forms::i_set_the_following_fields_to_these_values', [$data]);
$this->execute('behat_general::i_click_on', ['Save and return', 'button']);
Expand All @@ -82,7 +82,7 @@ public function i_create_smartmenu_with_the_following_fields_to_these_values(Tab
*/
public function i_create_smartmenus_with_the_following_fields_to_these_values($menu, TableNode $data) {
$this->execute('behat_navigation::i_navigate_to_in_site_administration',
['Appearance > Themes > Boost Union > Smart menus']);
['Appearance > Boost Union > Smart menus']);
$this->execute('behat_general::i_click_on_in_the', ['.action-list-items', 'css_element', $menu, 'table_row']);
$this->execute('behat_general::i_click_on', ['Add menu item', 'button']);
$this->execute('behat_forms::i_set_the_following_fields_to_these_values', [$data]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi

Scenario: Flavours: Application - Flavour ID is added as body class attribute
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I set the field "Title" to "My shiny new flavour"
Expand All @@ -48,7 +48,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript
Scenario: Flavours: Application - Apply a flavour to a particular category without subcategories (and show this fact in the overview table and make sure that other categories are not affected)
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand Down Expand Up @@ -87,7 +87,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript
Scenario: Flavours: Application - Apply a flavour to a particular category with subcategories (and show this fact in the overview table and make sure that other categories are not affected)
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand Down Expand Up @@ -126,7 +126,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript
Scenario: Flavours: Application - Do not apply a flavour to categories anymore
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand Down Expand Up @@ -162,7 +162,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript
Scenario: Flavours: Application - Apply a flavour to a particular cohort (and show this fact in the overview table and make sure that other cohorts are not affected)
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand Down Expand Up @@ -192,7 +192,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript
Scenario: Flavours: Application - Do not apply a flavour to cohorts anymore
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand Down Expand Up @@ -224,7 +224,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, applyi
@javascript
Scenario: Flavours: Application - Stop after the first matching flavour
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand Down
34 changes: 17 additions & 17 deletions tests/behat/theme_boost_union_flavourssettings_caching.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
@javascript
Scenario: Flavours: Caching - After creating an additional flavour (and thereby changing the flavour which applies to a particular user), the flavour which applies now should take direct effect (i.e. the flavours cache is properly purged)
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -26,7 +26,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I should not see "Course categories" in the "Non-effective flavour" "table_row"
And I am on "Course 1" course homepage
And I should see "Course 1" in the "#page-header .page-header-headings" "css_element"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -51,7 +51,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
@javascript
Scenario: Flavours: Caching - After editing a flavour (and thereby changing the flavour which applies to a particular user), the flavour which applies now should take direct effect (i.e. the flavours cache is properly purged)
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -70,7 +70,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I click on "Save changes" "button"
And I should see "Flavours" in the "#region-main h2" "css_element"
And I should see "Course categories" in the "Effective flavour" "table_row"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -91,7 +91,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I should see "Course categories" in the "Non-effective flavour" "table_row"
And I am on "Course 1" course homepage
And I should not see "Course 1" in the "#page-header .page-header-headings" "css_element"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on ".action-edit" "css_element" in the "Effective flavour" "table_row"
And I click on "span.badge" "css_element" in the "#fitem_id_applytocategories_ids .form-autocomplete-selection" "css_element"
And I click on ".form-autocomplete-downarrow" "css_element" in the "#fitem_id_applytocategories_ids" "css_element"
Expand All @@ -106,7 +106,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
@javascript
Scenario: Flavours: Caching - After deleting a flavour (and thereby changing the flavour which applies to a particular user), the flavour which applies now should take direct effect (i.e. the flavours cache is properly purged)
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -125,7 +125,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I click on "Save changes" "button"
And I should see "Flavours" in the "#region-main h2" "css_element"
And I should see "Course categories" in the "Effective flavour" "table_row"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -146,7 +146,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I should see "Course categories" in the "Non-effective flavour" "table_row"
And I am on "Course 1" course homepage
And I should not see "Course 1" in the "#page-header .page-header-headings" "css_element"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on ".action-delete" "css_element" in the "Effective flavour" "table_row"
And I click on "Delete" "button"
And I am on "Course 1" course homepage
Expand All @@ -155,7 +155,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
@javascript
Scenario Outline: Flavours: Caching - After sorting a flavour (and thereby changing the flavour which applies to a particular user), the flavour which applies now should take direct effect (i.e. the flavours cache is properly purged)
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -173,7 +173,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I set the field "Include subcategories" to "0"
And I click on "Save changes" "button"
And I should see "Flavours" in the "#region-main h2" "css_element"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -193,7 +193,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I should see "Flavours" in the "#region-main h2" "css_element"
And I am on "Course 1" course homepage
And I should not see "Course 1" in the "#page-header .page-header-headings" "css_element"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on ".sort-flavour-<action>-action" "css_element" in the "<flavourtosort> flavour" "table_row"
And I am on "Course 1" course homepage
Then I should see "Course 1" in the "#page-header .page-header-headings" "css_element"
Expand All @@ -214,7 +214,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
| admin | CH1 |
| admin | CH2 |
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -232,7 +232,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I click on "Save changes" "button"
And I should see "Flavours" in the "#region-main h2" "css_element"
And I should see "Cohorts" in the "Effective flavour" "table_row"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand Down Expand Up @@ -269,7 +269,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
| user | cohort |
| admin | CH2 |
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -287,7 +287,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I click on "Save changes" "button"
And I should see "Flavours" in the "#region-main h2" "css_element"
And I should see "Cohorts" in the "Effective flavour" "table_row"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand Down Expand Up @@ -327,7 +327,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
| admin | CH1 |
| admin | CH2 |
When I log in as "admin"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand All @@ -345,7 +345,7 @@ Feature: Configuring the theme_boost_union plugin on the "Flavours" page, cachin
And I click on "Save changes" "button"
And I should see "Flavours" in the "#region-main h2" "css_element"
And I should see "Cohorts" in the "Effective flavour" "table_row"
And I navigate to "Appearance > Themes > Boost Union > Flavours" in site administration
And I navigate to "Appearance > Boost Union > Flavours" in site administration
And I click on "Create flavour" "button"
And I should see "Create flavour" in the "#page-header h1" "css_element"
And I expand all fieldsets
Expand Down
Loading

0 comments on commit c19c1fe

Please sign in to comment.