mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
Merge branch 'main_MDL-82141' of https://github.com/mattporritt/moodle
This commit is contained in:
commit
8dc76d79e5
@ -303,28 +303,29 @@ abstract class plugin_management_table extends flexible_table implements dynamic
|
||||
global $OUTPUT;
|
||||
|
||||
$enabled = $row->plugininfo->is_enabled();
|
||||
$params = [
|
||||
'sesskey' => sesskey(),
|
||||
'plugin' => $row->plugininfo->name,
|
||||
'action' => $enabled ? 'disable' : 'enable',
|
||||
];
|
||||
|
||||
if ($enabled) {
|
||||
$icon = $OUTPUT->pix_icon('t/hide', get_string('disableplugin', 'core_admin', $row->plugininfo->displayname));
|
||||
$labelstr = get_string('disableplugin', 'core_admin', $row->plugininfo->displayname);
|
||||
} else {
|
||||
$icon = $OUTPUT->pix_icon('t/show', get_string('enableplugin', 'core_admin', $row->plugininfo->displayname));
|
||||
$labelstr = get_string('enableplugin', 'core_admin', $row->plugininfo->displayname);
|
||||
}
|
||||
|
||||
return html_writer::link(
|
||||
$this->get_action_url($params),
|
||||
$icon,
|
||||
[
|
||||
'data-toggle-method' => $this->get_toggle_service(),
|
||||
'data-action' => 'togglestate',
|
||||
'data-plugin' => $row->plugin,
|
||||
'data-state' => $enabled ? 1 : 0,
|
||||
$params = [
|
||||
'id' => 'admin-toggle-' . $row->plugininfo->name,
|
||||
'checked' => $enabled,
|
||||
'dataattributes' => [
|
||||
'name' => 'id',
|
||||
'value' => $row->plugininfo->name,
|
||||
'toggle-method' => $this->get_toggle_service(),
|
||||
'action' => 'togglestate',
|
||||
'plugin' => $row->plugin,
|
||||
'state' => $enabled ? 1 : 0,
|
||||
],
|
||||
);
|
||||
'title' => $labelstr,
|
||||
'label' => $labelstr,
|
||||
'labelclasses' => 'sr-only',
|
||||
];
|
||||
|
||||
return $OUTPUT->render_from_template('core_admin/setting_configtoggle', $params);
|
||||
}
|
||||
|
||||
protected function col_order(stdClass $row): string {
|
||||
|
57
admin/templates/setting_configtoggle.mustache
Normal file
57
admin/templates/setting_configtoggle.mustache
Normal file
@ -0,0 +1,57 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_admin/setting_configtoggle
|
||||
|
||||
Template for toggle element in admin settings.
|
||||
|
||||
Context variables required for this template:
|
||||
* id - element id
|
||||
* checked - bool, true if the toggle is enabled
|
||||
* name - form element name
|
||||
* value - form for name field
|
||||
* action - action to be performed when the toggle is clicked
|
||||
* plugin - plugin name
|
||||
* state - state of the toggle
|
||||
* title - title of the toggle tooltip
|
||||
* label - label of the toggle
|
||||
* labelclasses - classes for the label (sr-only for screen readers)
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"id": "reality-toggle-3",
|
||||
"checked": true,
|
||||
"dataattributes": [{
|
||||
"name": "id",
|
||||
"value": "toggle-reality",
|
||||
"action": "togglestate",
|
||||
"plugin": "tool_reality",
|
||||
"state": 1
|
||||
}],
|
||||
"title": "Title example",
|
||||
"label": "Enable/disable reality",
|
||||
"labelclasses": "sr-only"
|
||||
}
|
||||
}}
|
||||
<div id="container-{{id}}"
|
||||
data-toggle-method="{{dataattributes.toggle-method}}"
|
||||
data-action="{{dataattributes.action}}"
|
||||
data-plugin="{{dataattributes.plugin}}"
|
||||
data-state="{{dataattributes.state}}">
|
||||
{{> core/toggle }}
|
||||
</div>
|
||||
|
@ -8,26 +8,14 @@ Feature: An administrator can manage Block plugins
|
||||
Scenario: An administrator can control the enabled state of block plugins using JavaScript
|
||||
Given I am logged in as "admin"
|
||||
And I navigate to "Plugins > Blocks > Manage blocks" in site administration
|
||||
When I click on "Disable Latest badges" "link"
|
||||
Then I should see "Latest badges disabled."
|
||||
And "Disable Latest badges" "link" should not exist
|
||||
But "Enable Latest badges" "link" should exist
|
||||
When I click on "Enable Latest badges" "link"
|
||||
Then I should see "Latest badges enabled."
|
||||
And "Enable Latest badges" "link" should not exist
|
||||
But "Disable Latest badges" "link" should exist
|
||||
|
||||
Scenario: An administrator can control the enabled state of block plugins without JavaScript
|
||||
Given I am logged in as "admin"
|
||||
And I navigate to "Plugins > Blocks > Manage blocks" in site administration
|
||||
When I click on "Disable Latest badges" "link"
|
||||
Then I should see "Latest badges disabled."
|
||||
And "Disable Latest badges" "link" should not exist
|
||||
But "Enable Latest badges" "link" should exist
|
||||
When I click on "Enable Latest badges" "link"
|
||||
Then I should see "Latest badges enabled."
|
||||
And "Enable Latest badges" "link" should not exist
|
||||
But "Disable Latest badges" "link" should exist
|
||||
When I toggle the "Disable Latest badges" admin switch "off"
|
||||
And I should see "Latest badges disabled."
|
||||
And I reload the page
|
||||
Then I should see "Enable Latest badges"
|
||||
And I toggle the "Enable Latest badges" admin switch "on"
|
||||
And I should see "Latest badges enabled."
|
||||
And I reload the page
|
||||
Then I should see "Disable Latest badges"
|
||||
|
||||
@javascript
|
||||
Scenario: An administrator can control the protected state of block plugins using JavaScript
|
||||
|
@ -6,25 +6,14 @@ Feature: An administrator can manage Media plugins
|
||||
|
||||
@javascript
|
||||
Scenario: An administrator can control the enabled state of media plugins using JavaScript
|
||||
The state change should be reflected in the UI and persist across page reloads
|
||||
Given I am logged in as "admin"
|
||||
And I navigate to "Plugins > Media players > Manage media players" in site administration
|
||||
When I click on "Disable YouTube" "link"
|
||||
Then I should see "YouTube disabled."
|
||||
And "Disable YouTube" "link" should not exist
|
||||
But "Enable YouTube" "link" should exist
|
||||
When I click on "Enable YouTube" "link"
|
||||
Then I should see "YouTube enabled."
|
||||
And "Enable YouTube" "link" should not exist
|
||||
But "Disable YouTube" "link" should exist
|
||||
|
||||
Scenario: An administrator can control the enabled state of media plugins without JavaScript
|
||||
Given I am logged in as "admin"
|
||||
And I navigate to "Plugins > Media players > Manage media players" in site administration
|
||||
When I click on "Disable YouTube" "link"
|
||||
Then I should see "YouTube disabled."
|
||||
And "Disable YouTube" "link" should not exist
|
||||
But "Enable YouTube" "link" should exist
|
||||
When I click on "Enable YouTube" "link"
|
||||
Then I should see "YouTube enabled."
|
||||
And "Enable YouTube" "link" should not exist
|
||||
But "Disable YouTube" "link" should exist
|
||||
When I toggle the "Disable YouTube" admin switch "off"
|
||||
And I should see "YouTube disabled."
|
||||
And I reload the page
|
||||
Then I should see "Enable YouTube"
|
||||
And I toggle the "Enable YouTube" admin switch "on"
|
||||
And I should see "YouTube enabled."
|
||||
And I reload the page
|
||||
Then I should see "Disable YouTube"
|
||||
|
@ -12,11 +12,11 @@ Feature: I can apply presets
|
||||
Scenario: Applying Starter Moodle preset changes status and settings
|
||||
# Checking the settings before applying Full Moodle preset (we're only testing one of each type).
|
||||
Given I navigate to "Plugins > Activity modules > Manage activities" in site administration
|
||||
And "Disable Database" "icon" should exist in the "Database" "table_row"
|
||||
And I should see "Disable Database"
|
||||
And I navigate to "Plugins > Availability restrictions > Manage restrictions" in site administration
|
||||
And "Hide" "icon" should exist in the "Restriction by grouping" "table_row"
|
||||
And I navigate to "Plugins > Blocks > Manage blocks" in site administration
|
||||
And "Disable Logged in user" "icon" should exist in the "Logged in user" "table_row"
|
||||
And I should see "Disable Logged in user"
|
||||
And I navigate to "Plugins > Course formats > Manage course formats" in site administration
|
||||
And "Disable" "icon" should exist in the "Social" "table_row"
|
||||
And I navigate to "Plugins > Question behaviours > Manage question behaviours" in site administration
|
||||
@ -105,11 +105,11 @@ Feature: I can apply presets
|
||||
And the field "Enable badges" matches value "0"
|
||||
And the field "Enable competencies" matches value "0"
|
||||
And I navigate to "Plugins > Activity modules > Manage activities" in site administration
|
||||
And "Disable Database" "icon" should not exist in the "Database" "table_row"
|
||||
And I should see "Enable Database"
|
||||
And I navigate to "Plugins > Availability restrictions > Manage restrictions" in site administration
|
||||
And "Hide" "icon" should not exist in the "Restriction by grouping" "table_row"
|
||||
And I navigate to "Plugins > Blocks > Manage blocks" in site administration
|
||||
And "Disable Logged in user" "icon" should not exist in the "Logged in user" "table_row"
|
||||
And I should see "Enable Logged in user"
|
||||
And I navigate to "Plugins > Course formats > Manage course formats" in site administration
|
||||
And "Disable" "icon" should not exist in the "Social" "table_row"
|
||||
And I navigate to "Plugins > Question behaviours > Manage question behaviours" in site administration
|
||||
|
@ -19,7 +19,7 @@ Feature: I can revert changes after a load
|
||||
And the field "Enable badges" matches value "0"
|
||||
And the field "Enable competencies" matches value "0"
|
||||
And I navigate to "Plugins > Activity modules > Manage activities" in site administration
|
||||
And "Disable Database" "icon" should not exist in the "Database" "table_row"
|
||||
And I should see "Enable Database"
|
||||
And I navigate to "Plugins > Availability restrictions > Manage restrictions" in site administration
|
||||
And "Hide" "icon" should not exist in the "Restriction by grouping" "table_row"
|
||||
And I navigate to "Plugins > Blocks > Manage blocks" in site administration
|
||||
@ -37,11 +37,11 @@ Feature: I can revert changes after a load
|
||||
Then the field "Enable badges" matches value "1"
|
||||
And the field "Enable competencies" matches value "1"
|
||||
And I navigate to "Plugins > Activity modules > Manage activities" in site administration
|
||||
And "Disable Database" "icon" should exist in the "Database" "table_row"
|
||||
And I should see "Disable Database"
|
||||
And I navigate to "Plugins > Availability restrictions > Manage restrictions" in site administration
|
||||
And "Hide" "icon" should exist in the "Restriction by grouping" "table_row"
|
||||
And I navigate to "Plugins > Blocks > Manage blocks" in site administration
|
||||
And "Disable Logged in user" "icon" should exist in the "Logged in user" "table_row"
|
||||
And I should see "Disable Logged in user"
|
||||
And I navigate to "Plugins > Course formats > Manage course formats" in site administration
|
||||
And "Disable" "icon" should exist in the "Social" "table_row"
|
||||
And I navigate to "Plugins > Question behaviours > Manage question behaviours" in site administration
|
||||
|
@ -17,7 +17,7 @@ Feature: Add the glossary random block when main feature is enabled
|
||||
|
||||
Scenario: The glossary random block cannot be added when glossary module is disabled
|
||||
Given I navigate to "Plugins > Activity modules > Manage activities" in site administration
|
||||
And I click on "Disable Glossary" "icon" in the "Glossary" "table_row"
|
||||
And I toggle the "Disable Glossary" admin switch "off"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I click on "Add a block" "link"
|
||||
Then I should not see "Random glossary entry"
|
||||
|
@ -15,7 +15,7 @@ Feature: Add the glossary random block when main feature is disabled
|
||||
Scenario: The glossary random block is displayed even when glossary module is disabled
|
||||
When I log in as "admin"
|
||||
And I navigate to "Plugins > Activity modules > Manage activities" in site administration
|
||||
And I click on "Disable Glossary" "icon" in the "Glossary" "table_row"
|
||||
And I toggle the "Disable Glossary" admin switch "off"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
Then "Random glossary entry" "block" should exist
|
||||
|
||||
@ -28,7 +28,7 @@ Feature: Add the glossary random block when main feature is disabled
|
||||
And I click on "Cancel" "button" in the "Delete block?" "dialogue"
|
||||
And "Random glossary entry" "block" should exist
|
||||
When I navigate to "Plugins > Activity modules > Manage activities" in site administration
|
||||
And I click on "Disable Glossary" "icon" in the "Glossary" "table_row"
|
||||
And I toggle the "Disable Glossary" admin switch "off"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I open the "Random glossary entry" blocks action menu
|
||||
And I click on "Delete Random glossary entry block" "link" in the "Random glossary entry" "block"
|
||||
|
@ -7,7 +7,7 @@ Feature: Adding and configuring YouTube block
|
||||
Background:
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Plugins > Blocks > Manage blocks" in site administration
|
||||
And I click on "Enable YouTube" "icon" in the "YouTube" "table_row"
|
||||
And I toggle the "Enable YouTube" admin switch "on"
|
||||
|
||||
@javascript
|
||||
Scenario: Category options are not available (except default) in the block settings if the YouTube API key is not set.
|
||||
|
@ -7,7 +7,9 @@ Feature: Tiny noautolink
|
||||
Background:
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Plugins > Text editors > TinyMCE editor > General settings" in site administration
|
||||
And I click on "Enable No auto-link" "link"
|
||||
And I toggle the "Enable No auto-link" admin switch "on"
|
||||
When I open my profile in edit mode
|
||||
And I set the field "Description" to "<p>https://moodle.org</p>"
|
||||
|
||||
@javascript
|
||||
Scenario: Add and remove auto-link prevention to URLs
|
||||
|
@ -8,23 +8,11 @@ Feature: An administrator can manage TinyMCE subplugins
|
||||
Scenario: An administrator can control the enabled state of TinyMCE subplugins using JavaScript
|
||||
Given I am logged in as "admin"
|
||||
And I navigate to "Plugins > Text editors > TinyMCE editor > General settings" in site administration
|
||||
When I click on "Disable Equation editor" "link"
|
||||
Then I should see "Equation editor disabled."
|
||||
And "Disable Equation editor" "link" should not exist
|
||||
But "Enable Equation editor" "link" should exist
|
||||
When I click on "Enable Equation editor" "link"
|
||||
Then I should see "Equation editor enabled."
|
||||
And "Enable Equation editor" "link" should not exist
|
||||
But "Disable Equation editor" "link" should exist
|
||||
|
||||
Scenario: An administrator can control the enabled state of TinyMCE subplugins without JavaScript
|
||||
Given I am logged in as "admin"
|
||||
And I navigate to "Plugins > Text editors > TinyMCE editor > General settings" in site administration
|
||||
When I click on "Disable Equation editor" "link"
|
||||
Then I should see "Equation editor disabled."
|
||||
And "Disable Equation editor" "link" should not exist
|
||||
But "Enable Equation editor" "link" should exist
|
||||
When I click on "Enable Equation editor" "link"
|
||||
Then I should see "Equation editor enabled."
|
||||
And "Enable Equation editor" "link" should not exist
|
||||
But "Disable Equation editor" "link" should exist
|
||||
When I toggle the "Disable Equation editor" admin switch "off"
|
||||
And I should see "Equation editor disabled."
|
||||
And I reload the page
|
||||
Then I should see "Enable Equation editor"
|
||||
And I toggle the "Enable Equation editor" admin switch "on"
|
||||
And I should see "Equation editor enabled."
|
||||
And I reload the page
|
||||
Then I should see "Disable Equation editor"
|
||||
|
@ -2401,4 +2401,33 @@ EOF;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the specified admin switch.
|
||||
*
|
||||
* @When /^I toggle the "(?P<element_string>(?:[^"]|\\")*)" admin switch "(?P<state_string>on|off)"$/
|
||||
* @param string $element Element we look for
|
||||
* @param string $state The state of the switch
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
*/
|
||||
public function i_toggle_admin_switch($element, $state) {
|
||||
// First check we are running Javascript, otherwise explode.
|
||||
if (!$this->running_javascript()) {
|
||||
throw new \Behat\Mink\Exception\DriverException('Switches are only available with JavaScript enabled');
|
||||
}
|
||||
|
||||
// Next check that the node is available.
|
||||
$node = $this->get_selected_node('checkbox', $element);
|
||||
$this->ensure_node_is_visible($node);
|
||||
|
||||
// Update the state of the switch.
|
||||
$field = $node->getAttribute('id');
|
||||
if ($state == "on") {
|
||||
$this->execute('behat_forms::i_set_the_field_to', [$field, 1]);
|
||||
} else if ($state == "off") {
|
||||
$this->execute('behat_forms::i_set_the_field_to', [$field, 0]);
|
||||
} else {
|
||||
throw new \Behat\Mink\Exception\ExpectationException('Invalid state for switch: ' . $state, $this->getSession());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user