improve activation logic

This commit is contained in:
Andy Miller
2021-05-05 12:14:04 -06:00
parent bc7c44b91e
commit 3aae171297
4 changed files with 43 additions and 19 deletions

View File

@@ -700,6 +700,8 @@ class AdminController extends AdminBaseController
Cache::clearCache('invalidate');
$this->post = ['_redirect' => 'themes/' . $name ];
return true;
}

View 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>

View File

@@ -3,6 +3,9 @@
{% set isTestingRelease = gpm.isTestingRelease(theme.slug) %}
{% 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>
@@ -107,6 +110,7 @@
</div>
{% if (installed) %}
{% if (state == 'active') %}
{% set data = admin.data('themes/' ~ admin.route) %}
{% 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>
</div>
{% 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 %}
<div class="button-bar success">
{% if (theme.premium and not admin.license(theme.slug)) %}
@@ -133,6 +154,7 @@
</div>
{% endif %}
{% include 'partials/modal-switch-theme.html.twig' with {theme_name: theme.name} %}
{% include 'partials/modal-changes-detected.html.twig' %}
{% include 'partials/modal-add-package.html.twig' with { type: 'theme' } %}
{% include 'partials/modal-update-packages.html.twig' with { type: 'theme' } %}

View File

@@ -66,7 +66,7 @@
</div>
{% 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">
{{ "PLUGIN_ADMIN.ACTIVATE"|tu }}
<i class="fa fa-power-off" aria-hidden="true"></i> {{ "PLUGIN_ADMIN.ACTIVATE"|tu }}
</a>
{% endif %}
</div>
@@ -75,22 +75,6 @@
{% endfor %}
</div>
<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>
{% include 'partials/modal-switch-theme.html.twig' %}
{% include 'partials/modal-add-package.html.twig' with { type: 'theme' } %}
{% include 'partials/modal-update-packages.html.twig' with { type: 'theme' } %}