Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable13] Show EOL warning in the update section #8986

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/updatenotification/css/admin.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#oca_updatenotification_section p {
margin: 25px 0;
}
#updatenotification .warning {
color: #ce3702;
}
1 change: 1 addition & 0 deletions apps/updatenotification/lib/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions apps/updatenotification/lib/UpdateChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down
10 changes: 10 additions & 0 deletions apps/updatenotification/templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
<?php if (!empty($_['downloadLink'])) { ?>
<a href="<?php p($_['downloadLink']); ?>" class="button<?php if ($_['updaterEnabled']) { p(' hidden'); } ?>"><?php p($l->t('Download now')) ?></a>
<?php } ?>

<?php if (!empty($_['versionIsEol'])) { ?>
<p>
<span class="warning">
<span class="icon icon-error"></span>
<?php p($l->t('The version you are running is not maintained anymore. Please make sure to update to a supported version as soon as possible.')); ?>
</span>
</p>
<?php } ?>

<?php } elseif (!$isUpdateChecked) { ?>
<?php p($l->t('The update check is not yet finished. Please refresh the page.')); ?>
<?php } else { ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public function testDisplayPanelWithUpdate() {
'updateVersion' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'updaterEnabled' => true,
'versionIsEol' => false,
]);

$params = [
Expand All @@ -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',
Expand Down Expand Up @@ -186,7 +188,8 @@ public function testDisplayPanelWithoutUpdate() {
'channels' => $channels,
'newVersionString' => '',
'downloadLink' => '',
'updaterEnabled' => 0,
'updaterEnabled' => false,
'versionIsEol' => false,
'isDefaultUpdateServerURL' => true,
'updateServerURL' => 'https://updates.nextcloud.com/updater_server/',
'notify_groups' => 'admin',
Expand Down
4 changes: 4 additions & 0 deletions apps/updatenotification/tests/UpdateCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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',
];
Expand Down
1 change: 1 addition & 0 deletions lib/private/Updater/VersionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/Updater/VersionCheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -123,6 +124,7 @@ public function testCheckWithoutUpdateUrl() {
<url>https://download.example.org/community/owncloud-8.0.4.zip</url>
<web>http://doc.example.org/server/8.0/admin_manual/maintenance/upgrade.html</web>
<autoupdater>0</autoupdater>
<eol>1</eol>
</owncloud>';
$this->updater
->expects($this->once())
Expand Down Expand Up @@ -180,6 +182,7 @@ public function testCheckWithEmptyValidXmlResponse() {
'url' => '',
'web' => '',
'autoupdater' => '',
'eol' => '0',
];

$this->config
Expand Down Expand Up @@ -273,6 +276,7 @@ public function testCheckWithMissingAttributeXmlResponse() {
'url' => '',
'web' => '',
'autoupdater' => '',
'eol' => '0',
];

$this->config
Expand Down