diff --git a/media_source/plg_installer_webinstaller/js/client.es6.js b/media_source/plg_installer_webinstaller/js/client.es6.js index 89cb8e032b8e2..68fb502778c8e 100644 --- a/media_source/plg_installer_webinstaller/js/client.es6.js +++ b/media_source/plg_installer_webinstaller/js/client.es6.js @@ -3,6 +3,8 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +import JoomlaDialog from 'joomla.dialog'; + if (!Joomla) { throw new Error('Joomla API is not properly initialised'); } @@ -29,24 +31,6 @@ class WebInstaller { initialise() { webInstallerOptions.loaded = 1; - const cancelButton = document.getElementById('uploadform-web-cancel'); - cancelButton.addEventListener('click', () => { - document.getElementById('uploadform-web').classList.add('hidden'); - - if (webInstallerOptions.list && document.querySelector('.list-view')) { - document.querySelector('.list-view').click(); - } - }); - - const installButton = document.getElementById('uploadform-web-install'); - installButton.addEventListener('click', () => { - if (webInstallerOptions.options.installFrom === 4) { - this.submitButtonUrl(); - } else { - this.submitButtonWeb(); - } - }); - this.loadweb(`${webInstallerOptions.options.base_url}index.php?format=json&option=com_apps&view=dashboard`); this.clickforlinks(); @@ -197,8 +181,10 @@ class WebInstaller { if (installExtensionButton) { installExtensionButton.addEventListener('click', () => { - WebInstaller.installfromweb(installExtensionButton.getAttribute('data-downloadurl'), installExtensionButton.getAttribute('data-name')); - document.getElementById('uploadform-web-install').scrollIntoView({ behavior: 'smooth', block: 'start' }); + WebInstaller.installfromweb( + installExtensionButton.getAttribute('data-downloadurl'), + installExtensionButton.getAttribute('data-name'), + ); }); } @@ -358,7 +344,52 @@ class WebInstaller { document.getElementById('uploadform-web-name-label').classList.add('hidden'); } - document.getElementById('uploadform-web').classList.remove('hidden'); + const confirmation = document.getElementById('uploadform-web'); + + confirmation.classList.remove('hidden'); + + let dialog; + + dialog = new JoomlaDialog({ + className: 'joomla-dialog-confirm', + textHeader: Joomla.Text._('PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM'), + popupContent: confirmation, + popupButtons: [ + { + label: Joomla.Text._('COM_INSTALLER_INSTALL_BUTTON'), + className: 'button button-success btn btn-success', + onClick: () => { + dialog.close(); + + if (webInstallerOptions.options.installFrom === 4) { + instance.submitButtonUrl(); + } else { + instance.submitButtonWeb(); + } + }, + }, + { + label: Joomla.Text._('JCANCEL'), + className: 'button button-secondary btn btn-secondary', + onClick: () => { + dialog.close(); + + if (webInstallerOptions.list && document.querySelector('.list-view')) { + document.querySelector('.list-view').click(); + } + }, + }, + ], + }); + + dialog.addEventListener('joomla-dialog:close', () => { + Joomla.Modal.setCurrent(null); + dialog.destroy(); + confirmation.classList.add('hidden'); + }); + + Joomla.Modal.setCurrent(dialog); + dialog.show(); return true; } @@ -384,7 +415,7 @@ class WebInstaller { const form = document.getElementById('adminForm'); // do field validation - if (form.install_url.value !== '' || form.install_url.value !== 'http://' || form.install_url.value !== 'https://') { + if (form.install_url.value !== '' && form.install_url.value !== 'http://' && form.install_url.value !== 'https://') { this.submitButtonUrl(); } else if (form.install_url.value === '') { Joomla.renderMessages({ warning: [Joomla.apps.options.btntxt] }); diff --git a/plugins/installer/webinstaller/src/Extension/WebInstaller.php b/plugins/installer/webinstaller/src/Extension/WebInstaller.php index 8e084eb11ea76..b14c68398e575 100644 --- a/plugins/installer/webinstaller/src/Extension/WebInstaller.php +++ b/plugins/installer/webinstaller/src/Extension/WebInstaller.php @@ -88,6 +88,11 @@ public function onInstallerAddInstallationTab(AddInstallationTabEvent $event) // Push language strings to the JavaScript store Text::script('PLG_INSTALLER_WEBINSTALLER_CANNOT_INSTALL_EXTENSION_IN_PLUGIN'); Text::script('PLG_INSTALLER_WEBINSTALLER_REDIRECT_TO_EXTERNAL_SITE_TO_INSTALL'); + Text::script('PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM'); + Text::script('PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM_NAME'); + Text::script('PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_CONFIRM_URL'); + Text::script('COM_INSTALLER_INSTALL_BUTTON'); + Text::script('JCANCEL'); $doc->getWebAssetManager() ->registerAndUseStyle('plg_installer_webinstaller.client', 'plg_installer_webinstaller/client.min.css') @@ -96,7 +101,7 @@ public function onInstallerAddInstallationTab(AddInstallationTabEvent $event) 'plg_installer_webinstaller/client.min.js', [], ['type' => 'module'], - ['core'] + ['core', 'joomla.dialog'] ); $devLevel = Version::PATCH_VERSION; diff --git a/plugins/installer/webinstaller/tmpl/default.php b/plugins/installer/webinstaller/tmpl/default.php index 021b89a5bfdc7..e99c8a3dc1b18 100644 --- a/plugins/installer/webinstaller/tmpl/default.php +++ b/plugins/installer/webinstaller/tmpl/default.php @@ -30,20 +30,11 @@ - +