From 9391d8fc60e452a53bb8ab0df98fa09f361015ee Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 2 Aug 2017 10:12:55 +0200 Subject: [PATCH] Improve update notification layout and show non-default update server Signed-off-by: Morris Jobke --- apps/updatenotification/css/admin.css | 3 ++ .../lib/Controller/AdminController.php | 6 ++- apps/updatenotification/templates/admin.php | 49 ++++++++++++------- .../tests/Controller/AdminControllerTest.php | 14 ++++++ 4 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 apps/updatenotification/css/admin.css diff --git a/apps/updatenotification/css/admin.css b/apps/updatenotification/css/admin.css new file mode 100644 index 0000000000..59c8f056fb --- /dev/null +++ b/apps/updatenotification/css/admin.css @@ -0,0 +1,3 @@ +#oca_updatenotification_section p { + margin: 25px 0; +} diff --git a/apps/updatenotification/lib/Controller/AdminController.php b/apps/updatenotification/lib/Controller/AdminController.php index e3139b42ed..fd68a6dd96 100644 --- a/apps/updatenotification/lib/Controller/AdminController.php +++ b/apps/updatenotification/lib/Controller/AdminController.php @@ -105,6 +105,9 @@ class AdminController extends Controller implements ISettings { $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); + $defaultUpdateServerURL = 'https://updates.nextcloud.com/server/'; + $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL); + $params = [ 'isNewVersionAvailable' => !empty($updateState['updateAvailable']), 'isUpdateChecked' => $lastUpdateCheckTimestamp > 0, @@ -114,7 +117,8 @@ class AdminController extends Controller implements ISettings { 'newVersionString' => (empty($updateState['updateVersion'])) ? '' : $updateState['updateVersion'], 'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'], 'updaterEnabled' => (empty($updateState['updaterEnabled'])) ? false : $updateState['updaterEnabled'], - + 'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL, + 'updateServerURL' => $updateServerURL, 'notify_groups' => implode('|', $notifyGroups), ]; diff --git a/apps/updatenotification/templates/admin.php b/apps/updatenotification/templates/admin.php index bda27abf25..e09d19848e 100644 --- a/apps/updatenotification/templates/admin.php +++ b/apps/updatenotification/templates/admin.php @@ -1,5 +1,6 @@
- - t('A new version is available: %s', [$newVersionString])); ?> - - +

+ + t('A new version is available: %s', [$newVersionString])); ?> + + + + + t('Download now')) ?> + + + t('The update check is not yet finished. Please refresh the page.')); ?> + + t('Your version is up to date.')); ?> + - - t('Download now')) ?> + + +
+ + t("A non-default update server is in use to be checked for updates:")); ?> + + - - t('The update check is not yet finished. Please refresh the page.')); ?> - - t('Your version is up to date.')); ?> - - +

@@ -41,20 +56,16 @@ - -

-

- t('You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel.')); ?> +
+ t('You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel.')); ?>
t('Note that after a new release it can take some time before it shows up here. We roll out new versions spread out over time to our users and sometimes skip a version when issues are found.')); ?>

-
t('Notify members of the following groups about available updates:')); ?> - +
-
t('Only notification for app updates are available.')); ?> t('The selected update channel makes dedicated notifications for the server obsolete.')); ?> t('The selected update channel does not support updates of the server.')); ?> diff --git a/apps/updatenotification/tests/Controller/AdminControllerTest.php b/apps/updatenotification/tests/Controller/AdminControllerTest.php index 21e86b7c02..ebf044abff 100644 --- a/apps/updatenotification/tests/Controller/AdminControllerTest.php +++ b/apps/updatenotification/tests/Controller/AdminControllerTest.php @@ -103,6 +103,11 @@ class AdminControllerTest extends TestCase { ['core', 'lastupdatedat', '', '12345'], ['updatenotification', 'notify_groups', '["admin"]', '["admin"]'], ]); + $this->config + ->expects($this->once()) + ->method('getSystemValue') + ->with('updater.server.url', 'https://updates.nextcloud.com/server/') + ->willReturn('https://updates.nextcloud.com/server/'); $this->dateTimeFormatter ->expects($this->once()) ->method('formatDateTime') @@ -127,6 +132,8 @@ class AdminControllerTest extends TestCase { 'newVersionString' => '8.1.2', 'downloadLink' => 'https://downloads.nextcloud.org/server', 'updaterEnabled' => true, + 'isDefaultUpdateServerURL' => true, + 'updateServerURL' => 'https://updates.nextcloud.com/server/', 'notify_groups' => 'admin', ]; @@ -155,6 +162,11 @@ class AdminControllerTest extends TestCase { ['core', 'lastupdatedat', '', '12345'], ['updatenotification', 'notify_groups', '["admin"]', '["admin"]'], ]); + $this->config + ->expects($this->once()) + ->method('getSystemValue') + ->with('updater.server.url', 'https://updates.nextcloud.com/server/') + ->willReturn('https://updates.nextcloud.com/server/'); $this->dateTimeFormatter ->expects($this->once()) ->method('formatDateTime') @@ -174,6 +186,8 @@ class AdminControllerTest extends TestCase { 'newVersionString' => '', 'downloadLink' => '', 'updaterEnabled' => 0, + 'isDefaultUpdateServerURL' => true, + 'updateServerURL' => 'https://updates.nextcloud.com/server/', 'notify_groups' => 'admin', ];