diff --git a/themes/grav/app/plugins/index.js b/themes/grav/app/plugins/index.js index f6ec8518..6d691daa 100644 --- a/themes/grav/app/plugins/index.js +++ b/themes/grav/app/plugins/index.js @@ -43,38 +43,41 @@ $(document).on('click', '[data-plugin-action="remove-plugin"]', (event) => { } }, (response) => { if (response.status == 'success') { - // Go to Step 2 - loadPluginDependencies(slug, function(dependencies) { - $('.remove-plugin-step-1').addClass('hidden'); + $('.remove-plugin-confirm').addClass('hidden'); - if (dependencies.length > 0) { - addDependenciesToList(dependencies); - $('.remove-plugin-step-2').removeClass('hidden'); - } else { - $('.remove-plugin-done').removeClass('hidden'); - } + if (response.dependencies.length > 0) { + addDependenciesToList(response.dependencies); + $('.remove-plugin-dependencies').removeClass('hidden'); + } else { + $('.remove-plugin-done').removeClass('hidden'); + getBackToPluginsList(); + } + + //The plugin was removed. When the modal closes, move to the plugins list + $(document).on('closing', '[data-remodal-id="delete-plugin"]', function (e) { + getBackToPluginsList(); }); } }); }); -var loadPluginDependencies = function loadPluginDependencies(plugin, callback) { - let url = `${config.base_url_relative}/plugins.json/task${config.param_sep}getPluginDependencies/plugin:${plugin}/admin-nonce${config.param_sep}${config.admin_nonce}`; - request(url, { - method: 'get', - }, (response) => { - callback(response.dependencies); - }); -} - -var addDependencyToList = function addDependencyToList(dependency) { - var container = $('.plugin-dependencies-container'); - container.append(`