mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-27 08:16:41 +01:00
improve plugin enabled logic
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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') %}
|
||||
<div class="button-bar danger">
|
||||
<span class="danger-zone"></span>
|
||||
{% if not plugin.symlink %}
|
||||
<a class="button button-reinstall-package hidden" href="#" data-remodal-target="reinstall-package"><i class="fa fa-fw fa-repeat"></i> {{ "PLUGIN_ADMIN.REINSTALL_PLUGIN"|tu }}</a>
|
||||
{% endif %}
|
||||
<a class="button" href="#" data-remodal-target="remove-package"><i class="fa fa-fw fa-warning"></i> {{ "PLUGIN_ADMIN.REMOVE_PLUGIN"|tu }}</a>
|
||||
{% if (plugin.form.fields.enabled.type != 'hidden' and plugin.form.fields.tabs.fields.login.fields.enabled.type != 'hidden') %}
|
||||
<div class="button-bar danger">
|
||||
<span class="danger-zone"></span>
|
||||
{% if not plugin.symlink %}
|
||||
<a class="button button-reinstall-package hidden" href="#" data-remodal-target="reinstall-package"><i class="fa fa-fw fa-repeat"></i> {{ "PLUGIN_ADMIN.REINSTALL_PLUGIN"|tu }}</a>
|
||||
{% endif %}
|
||||
<a class="button" href="#" data-remodal-target="remove-package"><i class="fa fa-fw fa-warning"></i> {{ "PLUGIN_ADMIN.REMOVE_PLUGIN"|tu }}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<form>
|
||||
<div class="form-field grid">
|
||||
<div class="form-label block size-1-3">
|
||||
<label>Plugin must be enabled to configure</label>
|
||||
</div>
|
||||
<div class="form-data block size-2-3">
|
||||
<a class="button" href="{{ uri.addNonce(base_url_relative ~ '/plugins/' ~ plugin.slug ~ '/task' ~ config.system.param_sep ~ 'enable', 'admin-form', 'admin-nonce') ~ '/redirect:true' }}">
|
||||
<i class="fa fa-power-off" aria-hidden="true"></i> Enable <strong>{{ plugin.name }}</strong>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
<div class="button-bar success">
|
||||
{% if (plugin.premium and not admin.license(plugin.slug)) %}
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
{% endif %}
|
||||
<a class="gumroad-button button" href="https://gum.co/{{ plugin.premium.permalink }}" target="_blank" data-gumroad-single-product="true"><i class="fa fa-shopping-cart"></i> {{ plugin.premium.button|default('Purchase') }}</a>
|
||||
{% else %}
|
||||
<a class="button" href="#" data-remodal-target="add-package" data-packages-slugs="{{ plugin.slug }}" data-plugin-action="start-package-installation"><i class="fa fa-plus"></i> {{ "PLUGIN_ADMIN.INSTALL"|tu }}</a>
|
||||
<a class="button" href="#" data-remodal-target="add-package" data-packages-slugs="{{ plugin.slug }}" data-plugin-action="start-package-installation"><i class="fa fa-plus"></i> {{ "PLUGIN_ADMIN.INSTALL"|tu }}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<span class="gpm-details-expand"><i class="fa fa-chevron-down"></i></span>
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
<label>Activation required to configure</label>
|
||||
</div>
|
||||
<div class="form-data block size-2-3">
|
||||
<a class="button" data-remodal-target="theme-switch-warn" href="{{ uri.addNonce(base_url_relative ~ '/themes/' ~ theme.slug ~ '/task' ~ config.system.param_sep ~ 'activate', 'admin-form', 'admin-nonce') }}" class="gpm-actions">
|
||||
<a class="button gpm-actions" data-remodal-target="theme-switch-warn" href="{{ uri.addNonce(base_url_relative ~ '/themes/' ~ theme.slug ~ '/task' ~ config.system.param_sep ~ 'activate', 'admin-form', 'admin-nonce') }}">
|
||||
<i class="fa fa-power-off" aria-hidden="true"></i> {{ "PLUGIN_ADMIN.ACTIVATE"|tu }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -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 @@
|
||||
<a class="button" href="{{ admin_route('/plugins') }}"><i class="fa fa-arrow-left"></i> {{ "PLUGIN_ADMIN.BACK_TO_PLUGINS"|tu }}</a>
|
||||
<a class="button" href="{{ admin_route('/plugins/install') }}"><i class="fa fa-plus"></i> {{ "PLUGIN_ADMIN.ADD"|tu }}</a>
|
||||
{% include 'plugins/'~admin.route~'-buttons.html.twig' ignore missing %}
|
||||
{% if enabled %}
|
||||
<button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SAVE"|tu }}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="button-bar">
|
||||
|
||||
@@ -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) %}
|
||||
<div class="button-bar">
|
||||
<a class="button" href="{{ admin_route('/themes') }}"><i class="fa fa-arrow-left"></i> {{ "PLUGIN_ADMIN.BACK_TO_THEMES"|tu }}</a>
|
||||
{% if state == 'active' %}
|
||||
<button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SAVE"|tu }}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="button-bar">
|
||||
|
||||
Reference in New Issue
Block a user