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 Apr 18, 2018
1 parent f7d6eb9 commit 5f1f633
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 2 deletions.
12 changes: 12 additions & 0 deletions apps/updatenotification/css/admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#oca_updatenotification_section p {
margin: 25px 0;
}

#updatenotification .warning {
color: #ce3702;
}

#oca_updatenotification_section p.eol .icon {
display: inline-block;
margin-bottom: -3px;
}
2 changes: 1 addition & 1 deletion apps/updatenotification/lib/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,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'],
'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 @@ -47,6 +47,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
11 changes: 11 additions & 0 deletions apps/updatenotification/templates/admin.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
script('updatenotification', 'admin');
style('updatenotification', 'admin');

/** @var array $_ */
/** @var bool $isNewVersionAvailable */
Expand All @@ -16,6 +17,16 @@
<form id="oca_updatenotification_section" class="followupsection">
<?php if($isNewVersionAvailable === true) { ?>
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>

<?php if (!empty($_['versionIsEol'])) { ?>
<p class="eol">
<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 if ($_['updaterEnabled']) { ?>
<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
<?php } ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function testDisplayPanelWithUpdate() {
'updateVersion' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'updaterEnabled' => true,
'versionIsEol' => false,
]);

$params = [
Expand All @@ -126,6 +127,7 @@ public function testDisplayPanelWithUpdate() {
'newVersionString' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'updaterEnabled' => true,
'versionIsEol' => false,
'notify_groups' => 'admin',
];

Expand Down Expand Up @@ -171,7 +173,8 @@ public function testDisplayPanelWithoutUpdate() {
'channels' => $channels,
'newVersionString' => '',
'downloadLink' => '',
'updaterEnabled' => 0,
'updaterEnabled' => false,
'versionIsEol' => false,
'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 @@ -51,12 +51,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 @@ -71,12 +73,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 @@ -96,6 +96,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
3 changes: 3 additions & 0 deletions tests/lib/Updater/VersionCheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function testCheckWithoutUpdateUrl() {
'url' => 'https://download.owncloud.org/community/owncloud-8.0.4.zip',
'web' => 'http://doc.owncloud.org/server/8.0/admin_manual/maintenance/upgrade.html',
'autoupdater' => '0',
'eol' => '1',
];

$this->config
Expand Down Expand Up @@ -122,6 +123,7 @@ public function testCheckWithoutUpdateUrl() {
<url>https://download.owncloud.org/community/owncloud-8.0.4.zip</url>
<web>http://doc.owncloud.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 @@ -179,6 +181,7 @@ public function testCheckWithEmptyValidXmlResponse() {
'url' => '',
'web' => '',
'autoupdater' => '',
'eol' => '0',
];

$this->config
Expand Down

0 comments on commit 5f1f633

Please sign in to comment.