Closed joomlapl-bot closed 2 years ago
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/37911 Poniżej zmiany w oryginale:
Ple COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSIONS_SHOW_LESS_COMPATIBILITY_INFORMATION="Less Details" COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSIONS_SHOW_MORE_COMPATIBILITY_INFORMATION="More Details" COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSIONS_UPDATE_SERVER_OFFERS_NO_COMPATIBLE_VERSION="Update Information Unavailable" -COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSIONS_UPDATE_SERVER_OFFERS_NO_COMPATIBLE_VERSION_NOTES="Extension does not offer a compatible version for the selected target version of Joomla. This could mean the extension does not use the Joomla update system or the developer has not provided compatibility information for this Joomla version yet." +COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSIONS_UPDATE_SERVER_OFFERS_NO_COMPATIBLE_VERSION_NOTES="Joomla cannot detect the extension's compatibility with the target version of Joomla." COM_JOOMLAUPDATE_VIEW_DEFAULT_NON_CORE_BACKEND_TEMPLATE_USED_NOTICE="We detected that you are not using a core admin template. You might find the upgrade process smoother if you switch to use the %s template." COM_JOOMLAUPDATE_VIEW_DEFAULT_HELP="More Information" COM_JOOMLAUPDATE_VIEW_DEFAULT_INFOURL="Additional Information" diff --git a/build/media_source/com_joomlaupdate/js/default.es6.js b/build/media_source/com_joomlaupdate/js/default.es6.js index 09072232968e..f8b54dfa634d 100644 --- a/build/media_source/com_joomlaupdate/js/default.es6.js +++ b/build/media_source/com_joomlaupdate/js/default.es6.js @@ -53,6 +53,7 @@ Joomla = window.Joomla || {}; const form = installButton ? installButton.closest('form') : null; const task = form ? form.querySelector('[name=task]', form) : null; if (uploadButton) { + uploadButton.disabled = !updateCheck.checked; uploadButton.addEventListener('click', Joomla.submitbuttonUpload); updateCheck.addEventListener('change', () => { uploadButton.disabled = !updateCheck.checked; @@ -80,11 +81,11 @@ Joomla = window.Joomla || {}; } else if (fileSize <= allowedSize && !updateCheck.disabled && !updateCheck.checked) { updateCheck.disabled = false; } else if (fileSize <= allowedSize && updateCheck.checked) { - updateCheck.checked = false; + updateCheck.checked = updateCheck.classList.contains('d-none'); uploadButton.disabled = true; } else if (fileSize > allowedSize && !updateCheck.disabled) { updateCheck.disabled = !updateCheck.disabled; - updateCheck.checked = false; + updateCheck.checked = updateCheck.classList.contains('d-none'); uploadButton.disabled = true; } }); @@ -118,6 +119,7 @@ Joomla = window.Joomla || {}; */ PreUpdateChecker.config = { serverUrl: 'index.php?option=com_joomlaupdate&task=update.fetchextensioncompatibility', + batchUrl: 'index.php?option=com_joomlaupdate&task=update.batchextensioncompatibility', selector: '.extension-check', }; @@ -249,12 +251,130 @@ Joomla = window.Joomla || {}; }); // Grab all extensions based on the selector set in the config object + const extensionsInformation = []; + [].slice.call(extensions) .forEach((extension) => { - // Check compatibility for each extension, pass an object and a callback - // function after completing the request - PreUpdateChecker.checkCompatibility(extension, PreUpdateChecker.setResultView); + const thisInfo = { + eid: extension.getAttribute('data-extension-id'), + version: extension.getAttribute('data-extension-current-version'), + }; + extensionsInformation.push(thisInfo); }); + + PreUpdateChecker.checkNextChunk(extensionsInformation); + }; + + /** + * Converts a simple object containing query string parameters to a single, escaped query string + * + * @param data {object|string} A plain object containing the query parameters to pass + * @param prefix {string} Prefix for array-type parameters + * + * @returns {string} + */ + PreUpdateChecker.interpolateParameters = (data, prefix) => { + let encodedString = ''; + + if (typeof data !== 'object' || data === null || !data) { + return ''; + } + + Object.keys(data).forEach((prop) => { + const item = data[prop]; + + if (encodedString.length > 0) { + encodedString += '&'; + } + + // Scalar values + if (typeof item === 'object') { + const newPrefix = prefix.length ? `${prefix}[${prop}]` : prop; + + encodedString += PreUpdateChecker.interpolateParameters(item, newPrefix); + + return; + } + + if (prefix === '') { + encodedString += `${encodeURIComponent(prop)}=${encodeURIComponent(item)}`; + + return; + } + + encodedString += `${encodeURIComponent(prefix)}[${encodeURIComponent(prop)}]=${encodeURIComponent(item)}`; + }); + + return encodedString; + }; + + /** + * Check the compatibility of several extensions. + * + * Asks the server to check the compatibility of as many extensions as possible. The server + * returns these results and the remainder of the extensions not already checked. + * + * @param {Array} extensionsArray + */ + PreUpdateChecker.checkNextChunk = (extensionsArray) => { + if (extensionsArray.length === 0) { + return; + } + + Joomla.request({ + url: PreUpdateChecker.config.batchUrl, + method: 'POST', + data: PreUpdateChecker.interpolateParameters({ + 'joomla-target-version': PreUpdateChecker.joomlaTargetVersion, + 'joomla-current-version': PreUpdateChecker.joomlaCurrentVersion, + extensions: extensionsArray, + }, ''), + onSuccess(data) { + const response = JSON.parse(data); + + if (response.messages) { + Joomla.renderMessages(response.messages); + } + + const extensions = response.data.extensions || []; + + response.data.compatibility.forEach((record) => { + const node = document.getElementById(`preUpdateCheck_${record.id}`); + + if (!node) { + return; + } + + PreUpdateChecker.setResultView({ + element: node, + compatibleVersion: 0, + serverError: 0, + compatibilityData: record, + }); + }); + + PreUpdateChecker.checkNextChunk(extensions); + }, + onError(xhr) { + // Report the XHR error + Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr)); + + // Mark all pending extensions as errored out on the server side + extensionsArray.forEach((info) => { + const node = document.getElementById(`preUpdateCheck_${info.eid}`); + + if (!node) { + return; + } + + PreUpdateChecker.setResultView({ + element: node, + compatibleVersion: 0, + serverError: 1, + }); + }); + }, + }); }; /** @@ -263,9 +383,8 @@ Joomla = window.Joomla || {}; * on the data set in the element's data attributes. * * @param {Object} extension - * @param {callable} callback */ - PreUpdateChecker.checkCompatibility = (node, callback) => { + PreUpdateChecker.checkCompatibility = (node) => { // Result object passed to the callback // Set to server error by default const extension = { @@ -287,12 +406,12 @@ Joomla = window.Joomla || {}; extension.serverError = 0; extension.compatibilityData = response.data; // Pass the retrieved data to the callback - callback(extension); + PreUpdateChecker.setResultView(extension); }, onError() { extension.serverError = 1; // Pass the retrieved data to the callback - callback(extension); + PreUpdateChecker.setResultView(extension); }, }); }; ```
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/37911 Poniżej zmiany w oryginale:
Click to expand the diff!
```diff diff --git a/administrator/components/com_joomlaupdate/config.xml b/administrator/components/com_joomlaupdate/config.xml index 18fea2ce567e..938aed8bde57 100644 --- a/administrator/components/com_joomlaupdate/config.xml +++ b/administrator/components/com_joomlaupdate/config.xml @@ -49,5 +49,29 @@ showon="updatesource:custom" /> +