show a different message for custom domain alias when deleting

This commit is contained in:
Son NK 2021-03-18 14:45:18 +01:00
parent 8b234b63a5
commit f0fb5108f9
3 changed files with 14 additions and 1 deletions

View File

@ -432,6 +432,9 @@
<span class="btn btn-link btn-sm float-right text-danger"
onclick="confirmDeleteAlias.call(this)"
{% if alias.custom_domain %}
data-custom-domain-trash-url="{{ alias.custom_domain.get_trash_url() }}"
{% endif %}
data-alias="{{ alias.id }}"
data-alias-email="{{ alias.email }}"
>

View File

@ -1684,6 +1684,9 @@ class CustomDomain(db.Model, ModelMixin):
def nb_alias(self):
return Alias.filter_by(custom_domain_id=self.id).count()
def get_trash_url(self):
return URL + f"/dashboard/domains/{self.id}/trash"
def __repr__(self):
return f"<Custom Domain {self.domain}>"

View File

@ -3,10 +3,17 @@ $('.mailbox-select').multipleSelect();
function confirmDeleteAlias() {
let that = $(this);
let alias = that.data("alias-email");
let aliasDomainTrashUrl = that.data("custom-domain-trash-url");
let message = `Maybe you want to disable the alias instead? Please note once deleted, it <b>can't</b> be restored.`;
if (aliasDomainTrashUrl !== undefined) {
message = `Maybe you want to disable the alias instead? When it's deleted, it's moved to the domain
<a href="${aliasDomainTrashUrl}">trash</a>`;
}
bootbox.dialog({
title: `Delete ${alias}`,
message: `Maybe you want to disable the alias instead? Please note once deleted, it <b>can't</b> be restored.`,
message: message,
size: 'large',
onEscape: true,
backdrop: true,