Commit 97ed4075 authored by Michael Jobst's avatar Michael Jobst Committed by Vincent Petry
Browse files

Added show changelog information icon (#26800)

* Added show changelog information icon

* Moved URL construction to AdminController::displayPanel
parent 7fadb19a
......@@ -103,13 +103,27 @@ class AdminController extends Controller {
$updateState = $this->updateChecker->getUpdateState();
$notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true);
$isNewVersionAvailable = ($updateState === []) ? false : true;
$newVersionString = ($updateState === []) ? '' : $updateState['updateVersion'];
$changeLogUrl = null;
if( $isNewVersionAvailable === true ){
$varsionParts = explode(' ', $newVersionString);
if( count($varsionParts) >= 2){
$versionParts = explode('.', $varsionParts[1]); // remove the 'ownCloud' prefix
array_splice($versionParts, 2); // remove minor version info from parts
$changeLogUrl = 'https://owncloud.org/changelog/#latest' . implode('.', $versionParts);
}
}
$params = [
'isNewVersionAvailable' => ($updateState === []) ? false : true,
'isNewVersionAvailable' => $isNewVersionAvailable,
'lastChecked' => $lastUpdateCheck,
'currentChannel' => $currentChannel,
'channels' => $channels,
'newVersionString' => ($updateState === []) ? '' : $updateState['updateVersion'],
'newVersionString' => $newVersionString,
'changeLogUrl' => $changeLogUrl,
'notify_groups' => implode('|', $notifyGroups),
];
......
......@@ -12,6 +12,9 @@
$channels = $_['channels'];
/** @var string $currentChannel */
$currentChannel = $_['currentChannel'];
/** @var string $changeLogUrl */
$changeLogUrl = $_['changeLogUrl'];
?>
<form id="oca_updatenotification_section" class="section">
<h2><?php p($l->t('Updater')); ?></h2>
......@@ -19,6 +22,9 @@
<?php if($isNewVersionAvailable === true): ?>
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>
<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
<?php if ($changeLogUrl): ?>
<a target="_blank" rel="noreferrer" class="icon-info svg" title="<?php p($l->t('Show changelog')); ?>" href="<?php print_unescaped($changeLogUrl) ?>"></a>
<?php endif; ?>
<?php else: ?>
<strong><?php print_unescaped($l->t('Your version is up to date.')); ?></strong>
<span class="icon-info svg" title="<?php p($l->t('Checked on %s', [$lastCheckedDate])) ?>"></span>
......
......@@ -110,15 +110,16 @@ class AdminControllerTest extends TestCase {
$this->updateChecker
->expects($this->once())
->method('getUpdateState')
->willReturn(['updateVersion' => '8.1.2']);
->willReturn(['updateVersion' => 'ownCloud 8.1.2']);
$params = [
'isNewVersionAvailable' => true,
'lastChecked' => 'LastCheckedReturnValue',
'currentChannel' => \OCP\Util::getChannel(),
'channels' => $channels,
'newVersionString' => '8.1.2',
'notify_groups' => 'admin',
'newVersionString' => 'ownCloud 8.1.2',
'changeLogUrl' => 'https://owncloud.org/changelog/#latest8.1',
'notify_groups' => 'admin'
];
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
......@@ -162,6 +163,7 @@ class AdminControllerTest extends TestCase {
'currentChannel' => \OCP\Util::getChannel(),
'channels' => $channels,
'newVersionString' => '',
'changeLogUrl' => null,
'notify_groups' => 'admin',
];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment