Merge pull request #221 from eauchat/stretch-unstable

Added option to purge user's data when removing it from the admin panel
This commit is contained in:
Alexandre Aubin 2018-12-20 17:57:09 +01:00 committed by GitHub
commit b5d112954d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 4 deletions

View file

@ -269,6 +269,9 @@ button {
.content { .content {
.modal-body; .modal-body;
.danger {
color: red;
}
} }
footer { footer {

View file

@ -196,19 +196,43 @@
// Remove existing user // Remove existing user
app.get('#/users/:user/delete', function (c) { app.get('#/users/:user/delete', function (c) {
var params = {};
// make confirm content
var purgeCheckbox = '<div><input type="checkbox" id="purge-user-data" name="purge-user-data"> <label for="purge-user-data">'+ y18n.t('purge_user_data_checkbox', [c.params['user']]) +'</label></div>';
var purgeAlertMessage = '<div class="danger" style="display: none">⚠ '+ y18n.t('purge_user_data_warning') +'</div>';
var confirmModalContent = $('<div>'+ y18n.t('confirm_delete', [c.params['user']]) +'<br><br>'+ purgeCheckbox +'<br>'+ purgeAlertMessage +'</div>');
// display confirm modal
c.confirm( c.confirm(
y18n.t('users'), y18n.t('users'),
y18n.t('confirm_delete', [c.params['user']]), confirmModalContent,
function(){ function(){
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_delete_delete_4 c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_delete_delete_4
c.redirect('#/users'); c.redirect('#/users');
}, 'DELETE'); }, 'DELETE', params);
}, },
function(){ function(){
store.clear('slide'); store.clear('slide');
c.redirect('#/users/'+ c.params['user']); c.redirect('#/users/'+ c.params['user']);
} }
); );
// toggle purge warning and parameter
confirmModalContent.find("input").click(function(){
if (confirmModalContent.find("input").is(':checked')) {
params.purge = "";
confirmModalContent.find(".warning").show();
}
else {
delete params.purge;
confirmModalContent.find(".warning").hide();
};
});
}); });
})(); })();

View file

@ -414,5 +414,7 @@
"name" : "Name", "name" : "Name",
"install_community_appslists_info" : "Community applications list allows you to install community maintained applications.<br />See the full list on <a href='https://yunohost.org/apps'>yunohost.org/apps</a>.", "install_community_appslists_info" : "Community applications list allows you to install community maintained applications.<br />See the full list on <a href='https://yunohost.org/apps'>yunohost.org/apps</a>.",
"install_community_appslists_warning" : "Note that these applications packages are <strong>not</strong> official and not maintained by the YunoHost team.<br />Installing these applications is at your own risk and could break your system.", "install_community_appslists_warning" : "Note that these applications packages are <strong>not</strong> official and not maintained by the YunoHost team.<br />Installing these applications is at your own risk and could break your system.",
"install_custom_app_appslists_info" : "Note that you can use alternative applications lists to install some other apps maintained by the YunoHost community." "install_custom_app_appslists_info" : "Note that you can use alternative applications lists to install some other apps maintained by the YunoHost community.",
"purge_user_data_checkbox" : "Purge %s's data? (This will remove the content of it's home and mail directories.)",
"purge_user_data_warning" : "Purging user's data is not reversible. Be sure you know what you're doing!"
} }