Skip to content

Commit 5c0ec6e

Browse files
nickvergessenMorrisJobke
authored andcommitted
Show EOL warning in the update section
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent f192bcc commit 5c0ec6e

File tree

8 files changed

+26
-0
lines changed

8 files changed

+26
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#oca_updatenotification_section p {
22
margin: 25px 0;
33
}
4+
#updatenotification .warning {
5+
color: #ce3702;
6+
}

apps/updatenotification/lib/Controller/AdminController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public function displayPanel() {
119119
'newVersionString' => (empty($updateState['updateVersion'])) ? '' : $updateState['updateVersion'],
120120
'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'],
121121
'updaterEnabled' => (empty($updateState['updaterEnabled'])) ? false : $updateState['updaterEnabled'],
122+
'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
122123
'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL,
123124
'updateServerURL' => $updateServerURL,
124125
'notify_groups' => implode('|', $notifyGroups),

apps/updatenotification/lib/UpdateChecker.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function getUpdateState() {
4848
$result['updateAvailable'] = true;
4949
$result['updateVersion'] = $data['versionstring'];
5050
$result['updaterEnabled'] = $data['autoupdater'] === '1';
51+
$result['versionIsEol'] = $data['eol'] === '1';
5152
if(substr($data['web'], 0, 8) === 'https://') {
5253
$result['updateLink'] = $data['web'];
5354
}

apps/updatenotification/templates/admin.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
<?php if (!empty($_['downloadLink'])) { ?>
3131
<a href="<?php p($_['downloadLink']); ?>" class="button<?php if ($_['updaterEnabled']) { p(' hidden'); } ?>"><?php p($l->t('Download now')) ?></a>
3232
<?php } ?>
33+
34+
<?php if (!empty($_['versionIsEol'])) { ?>
35+
<p>
36+
<span class="warning">
37+
<span class="icon icon-error"></span>
38+
<?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.')); ?>
39+
</span>
40+
</p>
41+
<?php } ?>
42+
3343
<?php } elseif (!$isUpdateChecked) { ?>
3444
<?php p($l->t('The update check is not yet finished. Please refresh the page.')); ?>
3545
<?php } else { ?>

apps/updatenotification/tests/Controller/AdminControllerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public function testDisplayPanelWithUpdate() {
122122
'updateVersion' => '8.1.2',
123123
'downloadLink' => 'https://downloads.nextcloud.org/server',
124124
'updaterEnabled' => true,
125+
'versionIsEol' => false,
125126
]);
126127

127128
$params = [
@@ -133,6 +134,7 @@ public function testDisplayPanelWithUpdate() {
133134
'newVersionString' => '8.1.2',
134135
'downloadLink' => 'https://downloads.nextcloud.org/server',
135136
'updaterEnabled' => true,
137+
'versionIsEol' => false,
136138
'isDefaultUpdateServerURL' => true,
137139
'updateServerURL' => 'https://updates.nextcloud.com/updater_server/',
138140
'notify_groups' => 'admin',

apps/updatenotification/tests/UpdateCheckerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ public function testGetUpdateStateWithUpdateAndInvalidLink() {
5252
'web'=> 'javascript:alert(1)',
5353
'url'=> 'javascript:alert(2)',
5454
'autoupdater'=> '0',
55+
'eol'=> '1',
5556
]);
5657

5758
$expected = [
5859
'updateAvailable' => true,
5960
'updateVersion' => 'Nextcloud 123',
6061
'updaterEnabled' => false,
62+
'versionIsEol' => true,
6163
];
6264
$this->assertSame($expected, $this->updateChecker->getUpdateState());
6365
}
@@ -72,12 +74,14 @@ public function testGetUpdateStateWithUpdateAndValidLink() {
7274
'web'=> 'https://docs.nextcloud.com/myUrl',
7375
'url'=> 'https://downloads.nextcloud.org/server',
7476
'autoupdater'=> '1',
77+
'eol'=> '0',
7578
]);
7679

7780
$expected = [
7881
'updateAvailable' => true,
7982
'updateVersion' => 'Nextcloud 123',
8083
'updaterEnabled' => true,
84+
'versionIsEol' => false,
8185
'updateLink' => 'https://docs.nextcloud.com/myUrl',
8286
'downloadLink' => 'https://downloads.nextcloud.org/server',
8387
];

lib/private/Updater/VersionCheck.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function check() {
9898
$tmp['url'] = (string)$data->url;
9999
$tmp['web'] = (string)$data->web;
100100
$tmp['autoupdater'] = (string)$data->autoupdater;
101+
$tmp['eol'] = isset($data->eol) ? (string)$data->eol : '0';
101102
} else {
102103
libxml_clear_errors();
103104
}

tests/lib/Updater/VersionCheckTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function testCheckWithoutUpdateUrl() {
8585
'url' => 'https://download.example.org/community/owncloud-8.0.4.zip',
8686
'web' => 'http://doc.example.org/server/8.0/admin_manual/maintenance/upgrade.html',
8787
'autoupdater' => '0',
88+
'eol' => '1',
8889
];
8990

9091
$this->config
@@ -123,6 +124,7 @@ public function testCheckWithoutUpdateUrl() {
123124
<url>https://download.example.org/community/owncloud-8.0.4.zip</url>
124125
<web>http://doc.example.org/server/8.0/admin_manual/maintenance/upgrade.html</web>
125126
<autoupdater>0</autoupdater>
127+
<eol>1</eol>
126128
</owncloud>';
127129
$this->updater
128130
->expects($this->once())
@@ -180,6 +182,7 @@ public function testCheckWithEmptyValidXmlResponse() {
180182
'url' => '',
181183
'web' => '',
182184
'autoupdater' => '',
185+
'eol' => '0',
183186
];
184187

185188
$this->config
@@ -273,6 +276,7 @@ public function testCheckWithMissingAttributeXmlResponse() {
273276
'url' => '',
274277
'web' => '',
275278
'autoupdater' => '',
279+
'eol' => '0',
276280
];
277281

278282
$this->config

0 commit comments

Comments
 (0)