From 17bbb555458144e4a83a528adbaca5c732fec199 Mon Sep 17 00:00:00 2001 From: opi Date: Thu, 4 Sep 2014 14:54:43 +0200 Subject: [PATCH] Fix #48 : Display warning before installing an app on domain root (/) --- js/app.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/js/app.js b/js/app.js index 900e0e03..7dbac916 100644 --- a/js/app.js +++ b/js/app.js @@ -872,18 +872,26 @@ app = Sammy('#main', function (sam) { }); sam.post('#/apps', function(c) { - params = { 'label': c.params['label'], 'app': c.params['app'] } - delete c.params['label']; - delete c.params['app']; - params['args'] = c.serialize(c.params.toHash()); - // Do not pass empty args. - if (params['args'] == "") { - delete params['args']; - } + // Warn admin if app is going to be installed on domain root. + if (c.params['path'] !== '/' || confirm(y18n.t('confirm_install_domain_root', [c.params['domain']]))) { + params = { 'label': c.params['label'], 'app': c.params['app'] } + delete c.params['label']; + delete c.params['app']; + params['args'] = c.serialize(c.params.toHash()); + // 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.redirect('#/apps'); - }, 'POST', params); + c.api('/apps', function() { // http://api.yunohost.org/#!/app/app_install_post_2 + c.redirect('#/apps'); + }, 'POST', params); + } + else { + c.flash('warning', y18n.t('app_install_cancel')); + store.clear('slide'); + c.redirect('#/apps/install'); + } }); // Install custom app from github