From 5c0ec6e7ef2738c3aeaa7fe5dbd67c214d5939de Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 26 Mar 2018 13:56:14 +0200 Subject: [PATCH] Show EOL warning in the update section Signed-off-by: Joas Schilling --- apps/updatenotification/css/admin.css | 3 +++ .../lib/Controller/AdminController.php | 1 + apps/updatenotification/lib/UpdateChecker.php | 1 + apps/updatenotification/templates/admin.php | 10 ++++++++++ .../tests/Controller/AdminControllerTest.php | 2 ++ apps/updatenotification/tests/UpdateCheckerTest.php | 4 ++++ lib/private/Updater/VersionCheck.php | 1 + tests/lib/Updater/VersionCheckTest.php | 4 ++++ 8 files changed, 26 insertions(+) diff --git a/apps/updatenotification/css/admin.css b/apps/updatenotification/css/admin.css index 59c8f056fbc58..d3f7ef6aa261e 100644 --- a/apps/updatenotification/css/admin.css +++ b/apps/updatenotification/css/admin.css @@ -1,3 +1,6 @@ #oca_updatenotification_section p { margin: 25px 0; } +#updatenotification .warning { + color: #ce3702; +} diff --git a/apps/updatenotification/lib/Controller/AdminController.php b/apps/updatenotification/lib/Controller/AdminController.php index c96326c862e96..ac1d807aa2ecd 100644 --- a/apps/updatenotification/lib/Controller/AdminController.php +++ b/apps/updatenotification/lib/Controller/AdminController.php @@ -119,6 +119,7 @@ public function displayPanel() { 'newVersionString' => (empty($updateState['updateVersion'])) ? '' : $updateState['updateVersion'], 'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'], 'updaterEnabled' => (empty($updateState['updaterEnabled'])) ? false : $updateState['updaterEnabled'], + 'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'], 'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL, 'updateServerURL' => $updateServerURL, 'notify_groups' => implode('|', $notifyGroups), diff --git a/apps/updatenotification/lib/UpdateChecker.php b/apps/updatenotification/lib/UpdateChecker.php index ad76de5695382..bb5264a6c29f8 100644 --- a/apps/updatenotification/lib/UpdateChecker.php +++ b/apps/updatenotification/lib/UpdateChecker.php @@ -48,6 +48,7 @@ public function getUpdateState() { $result['updateAvailable'] = true; $result['updateVersion'] = $data['versionstring']; $result['updaterEnabled'] = $data['autoupdater'] === '1'; + $result['versionIsEol'] = $data['eol'] === '1'; if(substr($data['web'], 0, 8) === 'https://') { $result['updateLink'] = $data['web']; } diff --git a/apps/updatenotification/templates/admin.php b/apps/updatenotification/templates/admin.php index e09d19848e753..81201069feeff 100644 --- a/apps/updatenotification/templates/admin.php +++ b/apps/updatenotification/templates/admin.php @@ -30,6 +30,16 @@ t('Download now')) ?> + + +

+ + + t('The version you are running is not maintained anymore. Please make sure to update to a supported version as soon as possible.')); ?> + +

+ + t('The update check is not yet finished. Please refresh the page.')); ?> diff --git a/apps/updatenotification/tests/Controller/AdminControllerTest.php b/apps/updatenotification/tests/Controller/AdminControllerTest.php index 6eb049f6281b5..a0f74f5ad1fef 100644 --- a/apps/updatenotification/tests/Controller/AdminControllerTest.php +++ b/apps/updatenotification/tests/Controller/AdminControllerTest.php @@ -122,6 +122,7 @@ public function testDisplayPanelWithUpdate() { 'updateVersion' => '8.1.2', 'downloadLink' => 'https://downloads.nextcloud.org/server', 'updaterEnabled' => true, + 'versionIsEol' => false, ]); $params = [ @@ -133,6 +134,7 @@ public function testDisplayPanelWithUpdate() { 'newVersionString' => '8.1.2', 'downloadLink' => 'https://downloads.nextcloud.org/server', 'updaterEnabled' => true, + 'versionIsEol' => false, 'isDefaultUpdateServerURL' => true, 'updateServerURL' => 'https://updates.nextcloud.com/updater_server/', 'notify_groups' => 'admin', diff --git a/apps/updatenotification/tests/UpdateCheckerTest.php b/apps/updatenotification/tests/UpdateCheckerTest.php index f7ed83047a600..9920ed439d361 100644 --- a/apps/updatenotification/tests/UpdateCheckerTest.php +++ b/apps/updatenotification/tests/UpdateCheckerTest.php @@ -52,12 +52,14 @@ public function testGetUpdateStateWithUpdateAndInvalidLink() { 'web'=> 'javascript:alert(1)', 'url'=> 'javascript:alert(2)', 'autoupdater'=> '0', + 'eol'=> '1', ]); $expected = [ 'updateAvailable' => true, 'updateVersion' => 'Nextcloud 123', 'updaterEnabled' => false, + 'versionIsEol' => true, ]; $this->assertSame($expected, $this->updateChecker->getUpdateState()); } @@ -72,12 +74,14 @@ public function testGetUpdateStateWithUpdateAndValidLink() { 'web'=> 'https://docs.nextcloud.com/myUrl', 'url'=> 'https://downloads.nextcloud.org/server', 'autoupdater'=> '1', + 'eol'=> '0', ]); $expected = [ 'updateAvailable' => true, 'updateVersion' => 'Nextcloud 123', 'updaterEnabled' => true, + 'versionIsEol' => false, 'updateLink' => 'https://docs.nextcloud.com/myUrl', 'downloadLink' => 'https://downloads.nextcloud.org/server', ]; diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php index c7b829c9ec5e4..5cfc3c81a14cf 100644 --- a/lib/private/Updater/VersionCheck.php +++ b/lib/private/Updater/VersionCheck.php @@ -98,6 +98,7 @@ public function check() { $tmp['url'] = (string)$data->url; $tmp['web'] = (string)$data->web; $tmp['autoupdater'] = (string)$data->autoupdater; + $tmp['eol'] = isset($data->eol) ? (string)$data->eol : '0'; } else { libxml_clear_errors(); } diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php index 89a335722d7a2..216510b66283c 100644 --- a/tests/lib/Updater/VersionCheckTest.php +++ b/tests/lib/Updater/VersionCheckTest.php @@ -85,6 +85,7 @@ public function testCheckWithoutUpdateUrl() { 'url' => 'https://download.example.org/community/owncloud-8.0.4.zip', 'web' => 'http://doc.example.org/server/8.0/admin_manual/maintenance/upgrade.html', 'autoupdater' => '0', + 'eol' => '1', ]; $this->config @@ -123,6 +124,7 @@ public function testCheckWithoutUpdateUrl() { https://download.example.org/community/owncloud-8.0.4.zip http://doc.example.org/server/8.0/admin_manual/maintenance/upgrade.html 0 + 1 '; $this->updater ->expects($this->once()) @@ -180,6 +182,7 @@ public function testCheckWithEmptyValidXmlResponse() { 'url' => '', 'web' => '', 'autoupdater' => '', + 'eol' => '0', ]; $this->config @@ -273,6 +276,7 @@ public function testCheckWithMissingAttributeXmlResponse() { 'url' => '', 'web' => '', 'autoupdater' => '', + 'eol' => '0', ]; $this->config