mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-27 16:26:32 +01:00
improve activation logic
This commit is contained in:
@@ -678,7 +678,7 @@ class AdminController extends AdminBaseController
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->post = ['_redirect' => 'themes'];
|
$this->post = ['_redirect' => 'themes' ];
|
||||||
|
|
||||||
// Make sure theme exists (throws exception)
|
// Make sure theme exists (throws exception)
|
||||||
$name = $this->route;
|
$name = $this->route;
|
||||||
@@ -699,6 +699,8 @@ class AdminController extends AdminBaseController
|
|||||||
$this->admin->setMessage($this->admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_CHANGED_THEME'), 'info');
|
$this->admin->setMessage($this->admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_CHANGED_THEME'), 'info');
|
||||||
|
|
||||||
Cache::clearCache('invalidate');
|
Cache::clearCache('invalidate');
|
||||||
|
|
||||||
|
$this->post = ['_redirect' => 'themes/' . $name ];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
16
themes/grav/templates/partials/modal-switch-theme.html.twig
Normal file
16
themes/grav/templates/partials/modal-switch-theme.html.twig
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<div class="remodal theme-switcher" data-remodal-id="theme-switch-warn" data-remodal-options="hashTracking: false">
|
||||||
|
<form>
|
||||||
|
<h1>{{ "PLUGIN_ADMIN.SWITCHING_TO"|tu }} <strong>{theme_name}</strong></h1>
|
||||||
|
<p class="bigger">
|
||||||
|
{{ "PLUGIN_ADMIN.SWITCHING_TO_DESCRIPTION"|tu }}
|
||||||
|
</p>
|
||||||
|
<p class="bigger">
|
||||||
|
{{ "PLUGIN_ADMIN.SWITCHING_TO_CONFIRMATION"|tu }} <strong>{theme_name}</strong>?
|
||||||
|
</p>
|
||||||
|
<br>
|
||||||
|
<div class="button-bar">
|
||||||
|
<button data-remodal-action="cancel" class="button secondary remodal-cancel"><i class="fa fa-fw fa-close"></i> {{ "PLUGIN_ADMIN.CANCEL"|tu }}</button>
|
||||||
|
<a class="button continue" href="#"><i class="fa fa-fw fa-check"></i>{{ "PLUGIN_ADMIN.CONTINUE"|tu }}</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
@@ -3,6 +3,9 @@
|
|||||||
{% set isTestingRelease = gpm.isTestingRelease(theme.slug) %}
|
{% set isTestingRelease = gpm.isTestingRelease(theme.slug) %}
|
||||||
{% set gumroad_loaded = false %}
|
{% set gumroad_loaded = false %}
|
||||||
|
|
||||||
|
{% set state = 'inactive' %}
|
||||||
|
{% if (config.get('system.pages.theme') == theme.slug) %}{% set state = 'active' %}{% endif %}
|
||||||
|
|
||||||
<div class="grav-update theme" data-gpm-theme="{{ admin.route }}">
|
<div class="grav-update theme" data-gpm-theme="{{ admin.route }}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -107,6 +110,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if (installed) %}
|
{% if (installed) %}
|
||||||
|
{% if (state == 'active') %}
|
||||||
{% set data = admin.data('themes/' ~ admin.route) %}
|
{% set data = admin.data('themes/' ~ admin.route) %}
|
||||||
{% include 'partials/blueprints.html.twig' with { data: data, blueprints: data.blueprints } %}
|
{% include 'partials/blueprints.html.twig' with { data: data, blueprints: data.blueprints } %}
|
||||||
|
|
||||||
@@ -119,6 +123,23 @@
|
|||||||
<a class="button" href="#" data-remodal-target="remove-package"><i class="fa fa-fw fa-warning"></i> {{ "PLUGIN_ADMIN.REMOVE_THEME"|tu }}</a>
|
<a class="button" href="#" data-remodal-target="remove-package"><i class="fa fa-fw fa-warning"></i> {{ "PLUGIN_ADMIN.REMOVE_THEME"|tu }}</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<div class="theme" data-gpm-theme="{{ theme.slug }}" data-gpm-name="{{ theme.name }}">
|
||||||
|
<div style="display:none;" class="gpm-name"><a>{{ theme.name }}</a></div>
|
||||||
|
<form>
|
||||||
|
<div class="form-field grid">
|
||||||
|
<div class="form-label block size-1-3">
|
||||||
|
<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">
|
||||||
|
<i class="fa fa-power-off" aria-hidden="true"></i> {{ "PLUGIN_ADMIN.ACTIVATE"|tu }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="button-bar success">
|
<div class="button-bar success">
|
||||||
{% if (theme.premium and not admin.license(theme.slug)) %}
|
{% if (theme.premium and not admin.license(theme.slug)) %}
|
||||||
@@ -133,6 +154,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% include 'partials/modal-switch-theme.html.twig' with {theme_name: theme.name} %}
|
||||||
{% include 'partials/modal-changes-detected.html.twig' %}
|
{% include 'partials/modal-changes-detected.html.twig' %}
|
||||||
{% include 'partials/modal-add-package.html.twig' with { type: 'theme' } %}
|
{% include 'partials/modal-add-package.html.twig' with { type: 'theme' } %}
|
||||||
{% include 'partials/modal-update-packages.html.twig' with { type: 'theme' } %}
|
{% include 'partials/modal-update-packages.html.twig' with { type: 'theme' } %}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a data-remodal-target="theme-switch-warn" href="{{ uri.addNonce(base_url_relative ~ '/themes/' ~ slug ~ '/task' ~ config.system.param_sep ~ 'activate', 'admin-form', 'admin-nonce') }}" class="gpm-actions">
|
<a data-remodal-target="theme-switch-warn" href="{{ uri.addNonce(base_url_relative ~ '/themes/' ~ slug ~ '/task' ~ config.system.param_sep ~ 'activate', 'admin-form', 'admin-nonce') }}" class="gpm-actions">
|
||||||
{{ "PLUGIN_ADMIN.ACTIVATE"|tu }}
|
<i class="fa fa-power-off" aria-hidden="true"></i> {{ "PLUGIN_ADMIN.ACTIVATE"|tu }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
@@ -75,22 +75,6 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="remodal theme-switcher" data-remodal-id="theme-switch-warn" data-remodal-options="hashTracking: false">
|
{% include 'partials/modal-switch-theme.html.twig' %}
|
||||||
<form>
|
|
||||||
<h1>{{ "PLUGIN_ADMIN.SWITCHING_TO"|tu }} <strong>{theme_name}</strong></h1>
|
|
||||||
<p class="bigger">
|
|
||||||
{{ "PLUGIN_ADMIN.SWITCHING_TO_DESCRIPTION"|tu }}
|
|
||||||
</p>
|
|
||||||
<p class="bigger">
|
|
||||||
{{ "PLUGIN_ADMIN.SWITCHING_TO_CONFIRMATION"|tu }} <strong>{theme_name}</strong>?
|
|
||||||
</p>
|
|
||||||
<br>
|
|
||||||
<div class="button-bar">
|
|
||||||
<button data-remodal-action="cancel" class="button secondary remodal-cancel"><i class="fa fa-fw fa-close"></i> {{ "PLUGIN_ADMIN.CANCEL"|tu }}</button>
|
|
||||||
<a class="button continue" href="#"><i class="fa fa-fw fa-check"></i>{{ "PLUGIN_ADMIN.CONTINUE"|tu }}</a>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% include 'partials/modal-add-package.html.twig' with { type: 'theme' } %}
|
{% include 'partials/modal-add-package.html.twig' with { type: 'theme' } %}
|
||||||
{% include 'partials/modal-update-packages.html.twig' with { type: 'theme' } %}
|
{% include 'partials/modal-update-packages.html.twig' with { type: 'theme' } %}
|
||||||
|
|||||||
Reference in New Issue
Block a user