From 5d15051da4a170b5c944ccffe372f1ebe2649924 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 29 Jul 2015 16:41:22 +0200 Subject: [PATCH] Allow setupchecks to specify a warning level --- core/js/setupchecks.js | 13 ++++++--- core/js/tests/specs/setupchecksSpec.js | 16 +++++++++-- settings/js/admin.js | 37 +++++++++++++++++++++----- settings/templates/admin.php | 2 ++ 4 files changed, 56 insertions(+), 12 deletions(-) diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 35f24b188f..bf8dba78c4 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -10,6 +10,12 @@ (function() { OC.SetupChecks = { + + /* Message types */ + MESSAGE_TYPE_INFO:0, + MESSAGE_TYPE_WARNING:1, + MESSAGE_TYPE_ERROR:2, + /** * Check whether the WebDAV connection works. * @@ -60,9 +66,10 @@ ); } if(!data.isMemcacheConfigured) { - messages.push( - t('core', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.', {docLink: data.memcacheDocs}) - ); + messages.push({ + msg: t('core', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.', {docLink: data.memcacheDocs}), + type: OC.SetupChecks.MESSAGE_TYPE_TIP + }); } if(!data.isUrandomAvailable) { messages.push( diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index ec8a732b4a..2bf8129fd5 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -70,7 +70,13 @@ describe('OC.SetupChecks tests', function() { ); async.done(function( data, s, x ){ - expect(data).toEqual(['This server has no working Internet connection. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. We suggest to enable Internet connection for this server if you want to have all features.', 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.']); + expect(data).toEqual([ + 'This server has no working Internet connection. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. We suggest to enable Internet connection for this server if you want to have all features.', + 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.', + { + msg: 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.', + type: OC.SetupChecks.MESSAGE_TYPE_INFO + }]); done(); }); }); @@ -87,7 +93,13 @@ describe('OC.SetupChecks tests', function() { ); async.done(function( data, s, x ){ - expect(data).toEqual(['This server has no working Internet connection. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. We suggest to enable Internet connection for this server if you want to have all features.', 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.', 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.']); + expect(data).toEqual([ + 'This server has no working Internet connection. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. We suggest to enable Internet connection for this server if you want to have all features.', + 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.', + { + msg: 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our documentation.', + type: OC.SetupChecks.MESSAGE_TYPE_TIP + }]); done(); }); }); diff --git a/settings/js/admin.js b/settings/js/admin.js index 8f705b9048..752ab44534 100644 --- a/settings/js/admin.js +++ b/settings/js/admin.js @@ -166,17 +166,40 @@ $(document).ready(function(){ OC.SetupChecks.checkSetup(), OC.SetupChecks.checkGeneric() ).then(function(check1, check2, check3) { - var errors = [].concat(check1, check2, check3); + var messages = [].concat(check1, check2, check3); var $el = $('#postsetupchecks'); - var $errorsEl; $el.find('.loading').addClass('hidden'); - if (errors.length === 0) { + if (messages.length === 0) { } else { - $errorsEl = $el.find('.errors'); - for (var i = 0; i < errors.length; i++ ) { - $errorsEl.append('
  • ' + errors[i] + '
  • '); + var $errorsEl = $el.find('.errors'); + var $warningsEl = $el.find('.warnings'); + var $infoEl = $el.find('.info'); + for (var i = 0; i < messages.length; i++ ) { + if ($.isPlainObject(messages[i])) { + switch(messages[i].type) { + case OC.SetupChecks.MESSAGE_TYPE_INFO: + $tipsEl.append('
  • ' + messages[i].msg + '
  • '); + break; + case OC.SetupChecks.MESSAGE_TYPE_WARNING: + $warningsEl.append('
  • ' + messages[i].msg + '
  • '); + break; + case OC.SetupChecks.MESSAGE_TYPE_ERROR: + default: + $errorsEl.append('
  • ' + messages[i].msg + '
  • '); + } + } else { + $errorsEl.append('
  • ' + messages[i] + '
  • '); + } + } + if ($errorsEl.find('li').length > 0) { + $errorsEl.removeClass('hidden'); + } + if ($warningsEl.find('li').length > 0) { + $warningsEl.removeClass('hidden'); + } + if ($infoEl.find('li').length > 0) { + $infoEl.removeClass('hidden'); } - $errorsEl.removeClass('hidden'); $el.find('.hint').removeClass('hidden'); } }); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index a55071bdf8..1c5135c45b 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -171,6 +171,8 @@ if ($_['cronErrors']) {
    + +