Fix #48 : Display warning before installing an app on domain root (/)

This commit is contained in:
opi 2014-09-04 14:54:43 +02:00
parent 92b6cd0c0f
commit 17bbb55545

View file

@ -872,18 +872,26 @@ app = Sammy('#main', function (sam) {
}); });
sam.post('#/apps', function(c) { sam.post('#/apps', function(c) {
params = { 'label': c.params['label'], 'app': c.params['app'] } // Warn admin if app is going to be installed on domain root.
delete c.params['label']; if (c.params['path'] !== '/' || confirm(y18n.t('confirm_install_domain_root', [c.params['domain']]))) {
delete c.params['app']; params = { 'label': c.params['label'], 'app': c.params['app'] }
params['args'] = c.serialize(c.params.toHash()); delete c.params['label'];
// Do not pass empty args. delete c.params['app'];
if (params['args'] == "") { params['args'] = c.serialize(c.params.toHash());
delete params['args']; // Do not pass empty args.
} if (params['args'] == "") {
delete params['args'];
}
c.api('/apps', function() { // http://api.yunohost.org/#!/app/app_install_post_2 c.api('/apps', function() { // http://api.yunohost.org/#!/app/app_install_post_2
c.redirect('#/apps'); c.redirect('#/apps');
}, 'POST', params); }, 'POST', params);
}
else {
c.flash('warning', y18n.t('app_install_cancel'));
store.clear('slide');
c.redirect('#/apps/install');
}
}); });
// Install custom app from github // Install custom app from github