1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-18 02:41:27 +02:00

feat(admin-plugin): show Confirmation Required modal for system plugins deactivation #211

This commit is contained in:
Awilum
2020-02-06 15:34:19 +03:00
parent cfea5dd2c6
commit f0270a17a9
2 changed files with 32 additions and 7 deletions

View File

@@ -339,6 +339,7 @@ admin_cofirmation_required_for_fieldset_delete: "Are you sure you want to delete
admin_cofirmation_required_for_snippet_delete: "Are you sure you want to delete this snippet?"
admin_cofirmation_required_for_template_delete: "Are you sure you want to delete this template?"
admin_author: "Author"
admin_cofirmation_required_for_deactivate_system_plugin: "Are you sure you want to deactivate system plugin?"
admin_message_delivery_api_token_updated: "Delivery token updated."
admin_message_delivery_api_token_was_not_updated: "Delivery token was not updated."
admin_message_delivery_api_token_created: "Delivery token created."

View File

@@ -51,15 +51,24 @@
<i class="icon icon--white mr-3">{{ icon('fas fa-cog') }}</i>
{{ tr('admin_settings') }}</a>
<a class="dropdown__item" onclick="event.preventDefault(); document.getElementById('update-plugin-status-{{ key }}').submit();" href="javascript:;">
{% if plugin.enabled %}
<i class="icon icon--white mr-3">{{ icon('fas fa-toggle-on') }}</i>
{{ tr('admin_deactivate') }}
{% if plugin.enabled %}
{% if key == 'admin' or key == 'site' %}
<a class="dropdown__item" onclick="event.preventDefault(); deactivatePlugin('{{ key }}', {{ loop.index0 }});" href="javascript:;">
<i class="icon icon--white mr-3">{{ icon('fas fa-toggle-on') }}</i>
{{ tr('admin_deactivate') }}
</a>
{% else %}
<a class="dropdown__item" onclick="event.preventDefault(); document.getElementById('update-plugin-status-{{ key }}').submit();" href="javascript:;">
<i class="icon icon--white mr-3">{{ icon('fas fa-toggle-on') }}</i>
{{ tr('admin_deactivate') }}
</a>
{% endif %}
{% else %}
<a class="dropdown__item" onclick="event.preventDefault(); document.getElementById('update-plugin-status-{{ key }}').submit();" href="javascript:;">
<i class="icon icon--white mr-3">{{ icon('fas fa-toggle-off') }}</i>
{{ tr('admin_activate') }}
{% endif %}
</a>
</a>
{% endif %}
<form id="update-plugin-status-{{ key }}" action="{{ path_for('admin.plugins.update-status') }}" method="POST" style="display: none;">
{{ csrf() }}
<input type="hidden" name="plugin-key" value="{{ key }}">
@@ -80,4 +89,19 @@
</div>
</div>
{% endif %}
{% endblock %}
{% endblock %}
{% block tail %}
<script>
function deactivatePlugin(id, row_num) {
dropdown[row_num].hide();
Swal.fire(
{title: "{{ tr('admin_cofirmation_required') }}", text: "{{ tr('admin_cofirmation_required_for_deactivate_system_plugin') }}", showCancelButton: true, confirmButtonText: "{{ tr('admin_yes_iam_sure')|raw }}", cancelButtonText: "{{ tr('admin_cancel') }}"}
).then((result) => {
if (result.value) {
document.getElementById('update-plugin-status-' + id).submit();
}
});
}
</script>
{% endblock %}