From b3fed61aee7f361a45e6b689ffeb5bc214353594 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Mon, 27 Jan 2025 15:49:47 +0000 Subject: [PATCH] MDL-84337 ai: revert external set_action parameter renaming. This preserves backwards compatibility pre 368114c7 and fixes the placement table. --- .../build/aiprovider_action_management_table.min.js | 2 +- .../aiprovider_action_management_table.min.js.map | 2 +- ai/amd/src/aiprovider_action_management_table.js | 6 +++--- ai/classes/external/set_action.php | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ai/amd/build/aiprovider_action_management_table.min.js b/ai/amd/build/aiprovider_action_management_table.min.js index 0d7470b9710..555e36dd934 100644 --- a/ai/amd/build/aiprovider_action_management_table.min.js +++ b/ai/amd/build/aiprovider_action_management_table.min.js @@ -5,6 +5,6 @@ define("core_ai/aiprovider_action_management_table",["exports","core_admin/plugi * @module core_ai/aiprovider_action_management_table * @copyright 2024 Matt Porritt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */class _default extends _plugin_management_table.default{constructor(providerid){super(),this.providerid=providerid}static init(providerid){watching||(watching=!0,new this(providerid))}setPluginState(methodname,pluginaction,state){const providerid=this.providerid;return(0,_ajax.call)([{methodname:methodname,args:{pluginaction:pluginaction,state:state,providerid:providerid}}])[0]}}return _exports.default=_default,_exports.default})); + */class _default extends _plugin_management_table.default{constructor(providerid){super(),this.providerid=providerid}static init(providerid){watching||(watching=!0,new this(providerid))}setPluginState(methodname,plugin,state){const providerid=this.providerid;return(0,_ajax.call)([{methodname:methodname,args:{plugin:plugin,state:state,providerid:providerid}}])[0]}}return _exports.default=_default,_exports.default})); //# sourceMappingURL=aiprovider_action_management_table.min.js.map \ No newline at end of file diff --git a/ai/amd/build/aiprovider_action_management_table.min.js.map b/ai/amd/build/aiprovider_action_management_table.min.js.map index 38f572aa8b8..cf86b5d803b 100644 --- a/ai/amd/build/aiprovider_action_management_table.min.js.map +++ b/ai/amd/build/aiprovider_action_management_table.min.js.map @@ -1 +1 @@ -{"version":3,"file":"aiprovider_action_management_table.min.js","sources":["../src/aiprovider_action_management_table.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/ //\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\nimport PluginManagementTable from 'core_admin/plugin_management_table';\nimport {call as fetchMany} from 'core/ajax';\n\nlet watching = false;\n\n/**\n * Handles setting plugin state for the AI provider management table.\n *\n * @module core_ai/aiprovider_action_management_table\n * @copyright 2024 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default class extends PluginManagementTable {\n\n /**\n * Constructor for the class.\n *\n * @param {int} providerid The provider id.\n */\n constructor(providerid) {\n super(); // Call the parent constructor, so inherited properties and methods initialize properly.\n this.providerid = providerid; // Store provider id as an instance field.\n }\n\n /**\n * Initialise an instance of the class.\n *\n * @param {int} providerid The provider id.\n */\n static init(providerid) {\n if (watching) {\n return;\n }\n watching = true;\n new this(providerid);\n }\n\n /**\n * Set the plugin state (enabled or disabled).\n *\n * @param {string} methodname The web service to call.\n * @param {string} pluginaction The name of the plugin and action to set the state for.\n * @param {number} state The state to set.\n * @returns {Promise}\n */\n setPluginState(methodname, pluginaction, state) {\n const providerid = this.providerid;\n return fetchMany([{\n methodname,\n args: {\n pluginaction,\n state,\n providerid,\n },\n }])[0];\n }\n\n}\n"],"names":["watching","PluginManagementTable","constructor","providerid","this","setPluginState","methodname","pluginaction","state","args"],"mappings":"0VAiBIA,UAAW;;;;;;;4BAScC,iCAOzBC,YAAYC,yBAEHA,WAAaA,uBAQVA,YACJH,WAGJA,UAAW,MACPI,KAAKD,aAWbE,eAAeC,WAAYC,aAAcC,aAC/BL,WAAaC,KAAKD,kBACjB,cAAU,CAAC,CACdG,WAAAA,WACAG,KAAM,CACFF,aAAAA,aACAC,MAAAA,MACAL,WAAAA,eAEJ"} \ No newline at end of file +{"version":3,"file":"aiprovider_action_management_table.min.js","sources":["../src/aiprovider_action_management_table.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/ //\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\nimport PluginManagementTable from 'core_admin/plugin_management_table';\nimport {call as fetchMany} from 'core/ajax';\n\nlet watching = false;\n\n/**\n * Handles setting plugin state for the AI provider management table.\n *\n * @module core_ai/aiprovider_action_management_table\n * @copyright 2024 Matt Porritt \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default class extends PluginManagementTable {\n\n /**\n * Constructor for the class.\n *\n * @param {int} providerid The provider id.\n */\n constructor(providerid) {\n super(); // Call the parent constructor, so inherited properties and methods initialize properly.\n this.providerid = providerid; // Store provider id as an instance field.\n }\n\n /**\n * Initialise an instance of the class.\n *\n * @param {int} providerid The provider id.\n */\n static init(providerid) {\n if (watching) {\n return;\n }\n watching = true;\n new this(providerid);\n }\n\n /**\n * Set the plugin state (enabled or disabled).\n *\n * @param {string} methodname The web service to call.\n * @param {string} plugin The name of the plugin and action to set the state for.\n * @param {number} state The state to set.\n * @returns {Promise}\n */\n setPluginState(methodname, plugin, state) {\n const providerid = this.providerid;\n return fetchMany([{\n methodname,\n args: {\n plugin,\n state,\n providerid,\n },\n }])[0];\n }\n\n}\n"],"names":["watching","PluginManagementTable","constructor","providerid","this","setPluginState","methodname","plugin","state","args"],"mappings":"0VAiBIA,UAAW;;;;;;;4BAScC,iCAOzBC,YAAYC,yBAEHA,WAAaA,uBAQVA,YACJH,WAGJA,UAAW,MACPI,KAAKD,aAWbE,eAAeC,WAAYC,OAAQC,aACzBL,WAAaC,KAAKD,kBACjB,cAAU,CAAC,CACdG,WAAAA,WACAG,KAAM,CACFF,OAAAA,OACAC,MAAAA,MACAL,WAAAA,eAEJ"} \ No newline at end of file diff --git a/ai/amd/src/aiprovider_action_management_table.js b/ai/amd/src/aiprovider_action_management_table.js index d6a325f8e31..2e962054c32 100644 --- a/ai/amd/src/aiprovider_action_management_table.js +++ b/ai/amd/src/aiprovider_action_management_table.js @@ -53,16 +53,16 @@ export default class extends PluginManagementTable { * Set the plugin state (enabled or disabled). * * @param {string} methodname The web service to call. - * @param {string} pluginaction The name of the plugin and action to set the state for. + * @param {string} plugin The name of the plugin and action to set the state for. * @param {number} state The state to set. * @returns {Promise} */ - setPluginState(methodname, pluginaction, state) { + setPluginState(methodname, plugin, state) { const providerid = this.providerid; return fetchMany([{ methodname, args: { - pluginaction, + plugin, state, providerid, }, diff --git a/ai/classes/external/set_action.php b/ai/classes/external/set_action.php index 47a3cea0b6d..8e2edcd3d7c 100644 --- a/ai/classes/external/set_action.php +++ b/ai/classes/external/set_action.php @@ -37,7 +37,7 @@ class set_action extends external_api { */ public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ - 'pluginaction' => new external_value( + 'plugin' => new external_value( PARAM_TEXT, 'The name of the plugin and the action to change state for', VALUE_REQUIRED, @@ -59,23 +59,23 @@ class set_action extends external_api { /** * Set the providers action state. * - * @param string $pluginaction The name of the plugin and the action to change state for. + * @param string $plugin The name of the plugin and the action to change state for. * @param int $state The target state. * @param int $providerid The provider id. * @return array */ public static function execute( - string $pluginaction, + string $plugin, int $state, int $providerid = 0 ): array { // Parameter validation. [ - 'pluginaction' => $pluginaction, + 'plugin' => $plugin, 'state' => $state, 'providerid' => $providerid, ] = self::validate_parameters(self::execute_parameters(), [ - 'pluginaction' => $pluginaction, + 'plugin' => $plugin, 'state' => $state, 'providerid' => $providerid, ]); @@ -84,7 +84,7 @@ class set_action extends external_api { self::validate_context($context); require_capability('moodle/site:config', $context); - [$plugin, $action] = explode('-', $pluginaction); + [$plugin, $action] = explode('-', $plugin); $actionname = get_string("action_$action", 'core_ai'); if (!empty($state)) {