From 1ceebec29fefcca1d96d8bd861e2a579531dcee7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 5 May 2021 12:53:07 -0600 Subject: [PATCH] improve plugin enabled logic --- classes/plugin/AdminController.php | 3 ++ .../partials/plugins-details.html.twig | 32 +++++++++++++------ .../templates/partials/plugins-list.html.twig | 2 +- .../partials/themes-details.html.twig | 2 +- themes/grav/templates/plugins.html.twig | 5 +++ themes/grav/templates/themes.html.twig | 4 +++ 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/classes/plugin/AdminController.php b/classes/plugin/AdminController.php index 72cb8b0e..b60c68c6 100644 --- a/classes/plugin/AdminController.php +++ b/classes/plugin/AdminController.php @@ -624,6 +624,9 @@ class AdminController extends AdminBaseController $obj->save(); $this->post = ['_redirect' => 'plugins']; + if ($this->grav['uri']->param('redirect')) { + $this->post = ['_redirect' => 'plugins/' . $this->route]; + } $this->admin->setMessage($this->admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_ENABLED_PLUGIN'), 'info'); Cache::clearCache('invalidate'); diff --git a/themes/grav/templates/partials/plugins-details.html.twig b/themes/grav/templates/partials/plugins-details.html.twig index f2962c3c..b209de9c 100644 --- a/themes/grav/templates/partials/plugins-details.html.twig +++ b/themes/grav/templates/partials/plugins-details.html.twig @@ -29,18 +29,32 @@ {% if (installed) %} {% set data = admin.data('plugins/' ~ admin.route) %} - {% include 'partials/blueprints.html.twig' with { data: data, blueprints: data.blueprints } %} + {% if data.get('enabled') %} + {% include 'partials/blueprints.html.twig' with { data: data, blueprints: data.blueprints } %} - {% if (plugin.form.fields.enabled.type != 'hidden' and plugin.form.fields.tabs.fields.login.fields.enabled.type != 'hidden') %} -
- - {% if not plugin.symlink %} - - {% endif %} - {{ "PLUGIN_ADMIN.REMOVE_PLUGIN"|tu }} + {% if (plugin.form.fields.enabled.type != 'hidden' and plugin.form.fields.tabs.fields.login.fields.enabled.type != 'hidden') %} +
+ + {% if not plugin.symlink %} + + {% endif %} + {{ "PLUGIN_ADMIN.REMOVE_PLUGIN"|tu }} +
+ {% endif %} + {% else %} +
+
+
+ +
+
+
{% endif %} - {% else %}
{% if (plugin.premium and not admin.license(plugin.slug)) %} diff --git a/themes/grav/templates/partials/plugins-list.html.twig b/themes/grav/templates/partials/plugins-list.html.twig index 3d929657..4b4b9c95 100644 --- a/themes/grav/templates/partials/plugins-list.html.twig +++ b/themes/grav/templates/partials/plugins-list.html.twig @@ -54,7 +54,7 @@ {% endif %} {{ plugin.premium.button|default('Purchase') }} {% else %} - {{ "PLUGIN_ADMIN.INSTALL"|tu }} + {{ "PLUGIN_ADMIN.INSTALL"|tu }} {% endif %} {% endif %} diff --git a/themes/grav/templates/partials/themes-details.html.twig b/themes/grav/templates/partials/themes-details.html.twig index d2d3d54b..af024482 100644 --- a/themes/grav/templates/partials/themes-details.html.twig +++ b/themes/grav/templates/partials/themes-details.html.twig @@ -132,7 +132,7 @@
diff --git a/themes/grav/templates/plugins.html.twig b/themes/grav/templates/plugins.html.twig index 96a34132..c4a35422 100644 --- a/themes/grav/templates/plugins.html.twig +++ b/themes/grav/templates/plugins.html.twig @@ -1,6 +1,7 @@ {% extends 'partials/base.html.twig' %} {% set plugin_slug = admin.route %} +{% set enabled = true %} {% if plugin_slug %} {% set installing = plugin_slug starts with 'install' %} @@ -19,6 +20,8 @@ {% set plugin = package.toArray() %} {% set title = "PLUGIN_ADMIN.PLUGIN"|tu ~ ": " ~ plugin.name|e %} + {% set data = admin.data('plugins/' ~ admin.route) %} + {% set enabled = data.get('enabled') %} {% endif %} {% else %} {% set title = "PLUGIN_ADMIN.PLUGINS"|tu %} @@ -55,7 +58,9 @@ {{ "PLUGIN_ADMIN.BACK_TO_PLUGINS"|tu }} {{ "PLUGIN_ADMIN.ADD"|tu }} {% include 'plugins/'~admin.route~'-buttons.html.twig' ignore missing %} + {% if enabled %} + {% endif %}
{% else %}
diff --git a/themes/grav/templates/themes.html.twig b/themes/grav/templates/themes.html.twig index e059f426..e079e479 100644 --- a/themes/grav/templates/themes.html.twig +++ b/themes/grav/templates/themes.html.twig @@ -16,6 +16,8 @@ {% endif %} {% set theme = package.toArray() %} + {% set state = config.get('system.pages.theme') == theme.slug ? 'active' : 'inactive' %} + {% set title = "PLUGIN_ADMIN.THEME"|tu ~ ": " ~ theme.name|e %} {% endif %} {% else %} @@ -51,7 +53,9 @@ {% if (installed) %}
{{ "PLUGIN_ADMIN.BACK_TO_THEMES"|tu }} + {% if state == 'active' %} + {% endif %}
{% else %}