WebAdmin: improve the error message when trying to delete referenced resources

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2024-02-05 19:18:37 +01:00
parent d7975d8d76
commit c60eb050ef
5 changed files with 64 additions and 22 deletions

View File

@@ -529,7 +529,8 @@
"template_no_user": "No valid user defined, unable to complete the requested action" "template_no_user": "No valid user defined, unable to complete the requested action"
}, },
"group": { "group": {
"view_manage": "View and manage groups" "view_manage": "View and manage groups",
"err_delete_referenced": "Cannot delete a group with associated users, remove associations first"
}, },
"virtual_folders": { "virtual_folders": {
"view_manage": "View and manage virtual folders", "view_manage": "View and manage virtual folders",
@@ -739,7 +740,8 @@
"client": "Client: {{- val}}" "client": "Client: {{- val}}"
}, },
"role": { "role": {
"view_manage": "View and manage roles" "view_manage": "View and manage roles",
"err_delete_referenced": "Cannot delete a role with associated admins, remove associations first"
}, },
"ip_list": { "ip_list": {
"view_manage": "View and manage IP lists", "view_manage": "View and manage IP lists",
@@ -896,6 +898,7 @@
}, },
"actions": { "actions": {
"view_manage": "View and manage rule actions for events", "view_manage": "View and manage rule actions for events",
"err_delete_referenced": "Cannot delete an action with associated rules, remove associations first",
"http_url": "Server URL", "http_url": "Server URL",
"http_url_help": "i.e https://host:port/path. Placeholders are supported within the URL path", "http_url_help": "i.e https://host:port/path. Placeholders are supported within the URL path",
"http_url_required": "URL is required", "http_url_required": "URL is required",

View File

@@ -529,7 +529,8 @@
"template_no_user": "Nessun utente valido definito. Impossibile completare l'azione richiesta" "template_no_user": "Nessun utente valido definito. Impossibile completare l'azione richiesta"
}, },
"group": { "group": {
"view_manage": "Visualizza e gestisci gruppi" "view_manage": "Visualizza e gestisci gruppi",
"err_delete_referenced": "Impossibile eliminare un gruppo con utenti associati, rimuovere prima le associazioni"
}, },
"virtual_folders": { "virtual_folders": {
"view_manage": "Visualizza e gestisci cartelle virtuali", "view_manage": "Visualizza e gestisci cartelle virtuali",
@@ -739,7 +740,8 @@
"client": "Client: {{- val}}" "client": "Client: {{- val}}"
}, },
"role": { "role": {
"view_manage": "Visualizza e gestisci ruoli" "view_manage": "Visualizza e gestisci ruoli",
"err_delete_referenced": "Impossibile eliminare un ruolo con amministratori associati, rimuovere prima le associazioni"
}, },
"ip_list": { "ip_list": {
"view_manage": "Visualizza e gestisci liste IP", "view_manage": "Visualizza e gestisci liste IP",
@@ -896,6 +898,7 @@
}, },
"actions": { "actions": {
"view_manage": "Visualizza e gestisci le azioni delle regole per gli eventi", "view_manage": "Visualizza e gestisci le azioni delle regole per gli eventi",
"err_delete_referenced": "Impossibile eliminare un'azione con regole associate, rimuovere prima le associazioni",
"http_url": "URL Server", "http_url": "URL Server",
"http_url_help": "Ad es. \"https://host:port/path\". I segnaposto sono supportati nel path dell'URL", "http_url_help": "Ad es. \"https://host:port/path\". I segnaposto sono supportati nel path dell'URL",
"http_url_required": "L'URL è obbligatorio", "http_url_required": "L'URL è obbligatorio",

View File

@@ -248,11 +248,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
stateSave: true, stateSave: true,
stateDuration: 0, stateDuration: 0,
stateLoadParams: function (settings, data) { stateLoadParams: function (settings, data) {
if (data.search.search){ if (data.search.search){
const filterSearch = document.querySelector('[data-table-filter="search"]'); const filterSearch = document.querySelector('[data-table-filter="search"]');
filterSearch.value = data.search.search; filterSearch.value = data.search.search;
} }
}, },
language: { language: {
info: $.t('datatable.info'), info: $.t('datatable.info'),
infoEmpty: $.t('datatable.info_empty'), infoEmpty: $.t('datatable.info_empty'),
@@ -312,7 +312,19 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
el.on("click", function(e){ el.on("click", function(e){
e.preventDefault(); e.preventDefault();
const parent = e.target.closest('tr'); const parent = e.target.closest('tr');
deleteAction(dt.row(parent).data()['name']); let row = dt.row(parent).data();
if (row.rules && row.rules.length > 0){
ModalAlert.fire({
text: $.t('actions.err_delete_referenced'),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
return;
}
deleteAction(row['name']);
}); });
}); });
} }

View File

@@ -251,11 +251,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
fixedColumnsLeft: 1 fixedColumnsLeft: 1
}, },
stateLoadParams: function (settings, data) { stateLoadParams: function (settings, data) {
if (data.search.search){ if (data.search.search){
const filterSearch = document.querySelector('[data-table-filter="search"]'); const filterSearch = document.querySelector('[data-table-filter="search"]');
filterSearch.value = data.search.search; filterSearch.value = data.search.search;
} }
}, },
language: { language: {
info: $.t('datatable.info'), info: $.t('datatable.info'),
infoEmpty: $.t('datatable.info_empty'), infoEmpty: $.t('datatable.info_empty'),
@@ -326,7 +326,19 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
el.on("click", function(e){ el.on("click", function(e){
e.preventDefault(); e.preventDefault();
const parent = e.target.closest('tr'); const parent = e.target.closest('tr');
deleteAction(dt.row(parent).data()['name']); let row = dt.row(parent).data();
if (row.users && row.users.length > 0){
ModalAlert.fire({
text: $.t('group.err_delete_referenced'),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
return;
}
deleteAction(row['name']);
}); });
}); });
} }

View File

@@ -252,11 +252,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
fixedColumnsLeft: 1 fixedColumnsLeft: 1
}, },
stateLoadParams: function (settings, data) { stateLoadParams: function (settings, data) {
if (data.search.search){ if (data.search.search){
const filterSearch = document.querySelector('[data-table-filter="search"]'); const filterSearch = document.querySelector('[data-table-filter="search"]');
filterSearch.value = data.search.search; filterSearch.value = data.search.search;
} }
}, },
language: { language: {
info: $.t('datatable.info'), info: $.t('datatable.info'),
infoEmpty: $.t('datatable.info_empty'), infoEmpty: $.t('datatable.info_empty'),
@@ -327,7 +327,19 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
el.on("click", function(e){ el.on("click", function(e){
e.preventDefault(); e.preventDefault();
const parent = e.target.closest('tr'); const parent = e.target.closest('tr');
deleteAction(dt.row(parent).data()['name']); let row = dt.row(parent).data();
if (row.admins && row.admins.length > 0){
ModalAlert.fire({
text: $.t('role.err_delete_referenced'),
icon: "warning",
confirmButtonText: $.t('general.ok'),
customClass: {
confirmButton: "btn btn-primary"
}
});
return;
}
deleteAction(row['name']);
}); });
}); });
} }