Skip to content

Commit

Permalink
Show EOL warning in the update section
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Mar 15, 2018
1 parent af89db3 commit aebe631
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/updatenotification/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
#updatenotification .icon-triangle-n {
opacity: 0.5;
}

#updatenotification .warning {
color: #ce3702;
}
1 change: 1 addition & 0 deletions apps/updatenotification/js-src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ define(function (require) {
this.vm.channels = data.channels;
this.vm.notifyGroups = data.notifyGroups;
this.vm.isDefaultUpdateServerURL = data.isDefaultUpdateServerURL;
this.vm.versionIsEol = data.versionIsEol;
}
};
});
8 changes: 8 additions & 0 deletions apps/updatenotification/js-src/components/root.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
<div id="updatenotification" class="followupsection">
<div class="update">
<template v-if="isNewVersionAvailable">
<p v-if="versionIsEol">
<span class="warning">
<span class="icon icon-error"></span>
{{ t('updatenotification', 'The version you are running is not maintained anymore. Please make sure to update to a supported version as soon as possible.') }}
</span>
</p>

<p>
<span v-html="newVersionAvailableString"></span><br>
<span v-if="!isListFetched" class="icon icon-loading-small"></span>
Expand Down Expand Up @@ -77,6 +84,7 @@
lastCheckedDate: '',
isUpdateChecked: false,
updaterEnabled: true,
versionIsEol: false,
downloadLink: '',
isNewVersionAvailable: false,
updateServerURL: '',
Expand Down
1 change: 1 addition & 0 deletions apps/updatenotification/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function getForm(): TemplateResponse {
'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,
'notifyGroups' => $this->getSelectedGroups($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 @@ -49,6 +49,7 @@ public function getUpdateState(): array {
$result['updateAvailable'] = true;
$result['updateVersion'] = $data['versionstring'];
$result['updaterEnabled'] = $data['autoupdater'] === '1';
$result['versionIsEol'] = $data['eol'] === '1';
if (strpos($data['web'], 'https://') === 0) {
$result['updateLink'] = $data['web'];
}
Expand Down
2 changes: 2 additions & 0 deletions apps/updatenotification/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function testGetFormWithUpdate() {
'updateVersion' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'updaterEnabled' => true,
'versionIsEol' => false,
]);

$group = $this->createMock(IGroup::class);
Expand All @@ -124,6 +125,7 @@ public function testGetFormWithUpdate() {
'newVersionString' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'updaterEnabled' => true,
'versionIsEol' => false,
'isDefaultUpdateServerURL' => true,
'updateServerURL' => 'https://updates.nextcloud.com/updater_server/',
'notifyGroups' => [
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

0 comments on commit aebe631

Please sign in to comment.