Merge pull request #8987 from nextcloud/backport/8821/show-eol-warning-12

[stable12] Show EOL warning in the update section
This commit is contained in:
Roeland Jago Douma 2018-04-18 21:12:57 +02:00 committed by GitHub
commit d39f00a1ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 2 deletions

View File

@ -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;
}

View File

@ -114,7 +114,7 @@ class AdminController extends Controller implements ISettings {
'newVersionString' => (empty($updateState['updateVersion'])) ? '' : $updateState['updateVersion'], 'newVersionString' => (empty($updateState['updateVersion'])) ? '' : $updateState['updateVersion'],
'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'], 'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'],
'updaterEnabled' => (empty($updateState['updaterEnabled'])) ? false : $updateState['updaterEnabled'], 'updaterEnabled' => (empty($updateState['updaterEnabled'])) ? false : $updateState['updaterEnabled'],
'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
'notify_groups' => implode('|', $notifyGroups), 'notify_groups' => implode('|', $notifyGroups),
]; ];

View File

@ -47,6 +47,7 @@ class UpdateChecker {
$result['updateAvailable'] = true; $result['updateAvailable'] = true;
$result['updateVersion'] = $data['versionstring']; $result['updateVersion'] = $data['versionstring'];
$result['updaterEnabled'] = $data['autoupdater'] === '1'; $result['updaterEnabled'] = $data['autoupdater'] === '1';
$result['versionIsEol'] = $data['eol'] === '1';
if(substr($data['web'], 0, 8) === 'https://') { if(substr($data['web'], 0, 8) === 'https://') {
$result['updateLink'] = $data['web']; $result['updateLink'] = $data['web'];
} }

View File

@ -1,5 +1,6 @@
<?php <?php
script('updatenotification', 'admin'); script('updatenotification', 'admin');
style('updatenotification', 'admin');
/** @var array $_ */ /** @var array $_ */
/** @var bool $isNewVersionAvailable */ /** @var bool $isNewVersionAvailable */
@ -16,6 +17,16 @@
<form id="oca_updatenotification_section" class="followupsection"> <form id="oca_updatenotification_section" class="followupsection">
<?php if($isNewVersionAvailable === true) { ?> <?php if($isNewVersionAvailable === true) { ?>
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong> <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']) { ?> <?php if ($_['updaterEnabled']) { ?>
<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>"> <input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
<?php } ?> <?php } ?>

View File

@ -116,6 +116,7 @@ class AdminControllerTest extends TestCase {
'updateVersion' => '8.1.2', 'updateVersion' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server', 'downloadLink' => 'https://downloads.nextcloud.org/server',
'updaterEnabled' => true, 'updaterEnabled' => true,
'versionIsEol' => false,
]); ]);
$params = [ $params = [
@ -126,6 +127,7 @@ class AdminControllerTest extends TestCase {
'newVersionString' => '8.1.2', 'newVersionString' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server', 'downloadLink' => 'https://downloads.nextcloud.org/server',
'updaterEnabled' => true, 'updaterEnabled' => true,
'versionIsEol' => false,
'notify_groups' => 'admin', 'notify_groups' => 'admin',
]; ];
@ -171,7 +173,8 @@ class AdminControllerTest extends TestCase {
'channels' => $channels, 'channels' => $channels,
'newVersionString' => '', 'newVersionString' => '',
'downloadLink' => '', 'downloadLink' => '',
'updaterEnabled' => 0, 'updaterEnabled' => false,
'versionIsEol' => false,
'notify_groups' => 'admin', 'notify_groups' => 'admin',
]; ];

View File

@ -51,12 +51,14 @@ class UpdateCheckerTest extends TestCase {
'web'=> 'javascript:alert(1)', 'web'=> 'javascript:alert(1)',
'url'=> 'javascript:alert(2)', 'url'=> 'javascript:alert(2)',
'autoupdater'=> '0', 'autoupdater'=> '0',
'eol'=> '1',
]); ]);
$expected = [ $expected = [
'updateAvailable' => true, 'updateAvailable' => true,
'updateVersion' => 'Nextcloud 123', 'updateVersion' => 'Nextcloud 123',
'updaterEnabled' => false, 'updaterEnabled' => false,
'versionIsEol' => true,
]; ];
$this->assertSame($expected, $this->updateChecker->getUpdateState()); $this->assertSame($expected, $this->updateChecker->getUpdateState());
} }
@ -71,12 +73,14 @@ class UpdateCheckerTest extends TestCase {
'web'=> 'https://docs.nextcloud.com/myUrl', 'web'=> 'https://docs.nextcloud.com/myUrl',
'url'=> 'https://downloads.nextcloud.org/server', 'url'=> 'https://downloads.nextcloud.org/server',
'autoupdater'=> '1', 'autoupdater'=> '1',
'eol'=> '0',
]); ]);
$expected = [ $expected = [
'updateAvailable' => true, 'updateAvailable' => true,
'updateVersion' => 'Nextcloud 123', 'updateVersion' => 'Nextcloud 123',
'updaterEnabled' => true, 'updaterEnabled' => true,
'versionIsEol' => false,
'updateLink' => 'https://docs.nextcloud.com/myUrl', 'updateLink' => 'https://docs.nextcloud.com/myUrl',
'downloadLink' => 'https://downloads.nextcloud.org/server', 'downloadLink' => 'https://downloads.nextcloud.org/server',
]; ];

View File

@ -96,6 +96,7 @@ class VersionCheck {
$tmp['url'] = (string)$data->url; $tmp['url'] = (string)$data->url;
$tmp['web'] = (string)$data->web; $tmp['web'] = (string)$data->web;
$tmp['autoupdater'] = (string)$data->autoupdater; $tmp['autoupdater'] = (string)$data->autoupdater;
$tmp['eol'] = isset($data->eol) ? (string)$data->eol : '0';
} else { } else {
libxml_clear_errors(); libxml_clear_errors();
} }

View File

@ -84,6 +84,7 @@ class VersionCheckTest extends \Test\TestCase {
'url' => 'https://download.owncloud.org/community/owncloud-8.0.4.zip', 'url' => 'https://download.owncloud.org/community/owncloud-8.0.4.zip',
'web' => 'http://doc.owncloud.org/server/8.0/admin_manual/maintenance/upgrade.html', 'web' => 'http://doc.owncloud.org/server/8.0/admin_manual/maintenance/upgrade.html',
'autoupdater' => '0', 'autoupdater' => '0',
'eol' => '1',
]; ];
$this->config $this->config
@ -122,6 +123,7 @@ class VersionCheckTest extends \Test\TestCase {
<url>https://download.owncloud.org/community/owncloud-8.0.4.zip</url> <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> <web>http://doc.owncloud.org/server/8.0/admin_manual/maintenance/upgrade.html</web>
<autoupdater>0</autoupdater> <autoupdater>0</autoupdater>
<eol>1</eol>
</owncloud>'; </owncloud>';
$this->updater $this->updater
->expects($this->once()) ->expects($this->once())
@ -179,6 +181,7 @@ class VersionCheckTest extends \Test\TestCase {
'url' => '', 'url' => '',
'web' => '', 'web' => '',
'autoupdater' => '', 'autoupdater' => '',
'eol' => '0',
]; ];
$this->config $this->config