Merge pull request #1324 from nextcloud/backport-1323-show-download-button-for-updates-atm

[stable10] Show an download button instead of the updater
This commit is contained in:
Morris Jobke 2016-09-08 15:41:45 +02:00 committed by GitHub
commit 520bfa872b
9 changed files with 36 additions and 48 deletions

View File

@ -13,33 +13,7 @@
/**
* Creates a new authentication token and loads the updater URL
*/
var loginToken = '';
$(document).ready(function(){
$('#oca_updatenotification_button').click(function() {
// Load the new token
$.ajax({
url: OC.generateUrl('/apps/updatenotification/credentials')
}).success(function(data) {
loginToken = data;
$.ajax({
url: OC.webroot+'/updater/',
headers: {
'X-Updater-Auth': loginToken
},
method: 'POST',
success: function(data){
if(data !== 'false') {
var body = $('body');
$('head').remove();
body.html(data);
body.removeAttr('id');
body.attr('id', 'body-settings');
}
}
});
});
});
$('#release-channel').change(function() {
var newChannel = $('#release-channel').find(":selected").val();

View File

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

View File

@ -49,6 +49,9 @@ class UpdateChecker {
if(substr($data['web'], 0, 8) === 'https://') {
$result['updateLink'] = $data['web'];
}
if(substr($data['url'], 0, 8) === 'https://') {
$result['downloadLink'] = $data['url'];
}
return $result;
}

View File

@ -16,7 +16,9 @@
<form id="oca_updatenotification_section" class="followupsection">
<?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 ($_['downloadLink']): ?>
<a href="<?php p($_['downloadLink']); ?>" class="button"><?php p($l->t('Download now')) ?></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>

View File

@ -110,7 +110,10 @@ class AdminControllerTest extends TestCase {
$this->updateChecker
->expects($this->once())
->method('getUpdateState')
->willReturn(['updateVersion' => '8.1.2']);
->willReturn([
'updateVersion' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
]);
$params = [
'isNewVersionAvailable' => true,
@ -119,6 +122,7 @@ class AdminControllerTest extends TestCase {
'channels' => $channels,
'newVersionString' => '8.1.2',
'notify_groups' => 'admin',
'downloadLink' => 'https://downloads.nextcloud.org/server',
];
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
@ -163,6 +167,7 @@ class AdminControllerTest extends TestCase {
'channels' => $channels,
'newVersionString' => '',
'notify_groups' => 'admin',
'downloadLink' => '',
];
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');

View File

@ -47,13 +47,14 @@ class UpdateCheckerTest extends TestCase {
->method('check')
->willReturn([
'version' => 123,
'versionstring' => 'ownCloud 123',
'versionstring' => 'Nextcloud 123',
'web'=> 'javascript:alert(1)',
'url'=> 'javascript:alert(2)',
]);
$expected = [
'updateAvailable' => true,
'updateVersion' => 'ownCloud 123',
'updateVersion' => 'Nextcloud 123',
];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}
@ -64,14 +65,16 @@ class UpdateCheckerTest extends TestCase {
->method('check')
->willReturn([
'version' => 123,
'versionstring' => 'ownCloud 123',
'web'=> 'https://owncloud.org/myUrl',
'versionstring' => 'Nextcloud 123',
'web'=> 'https://docs.nextcloud.com/myUrl',
'url'=> 'https://downloads.nextcloud.org/server',
]);
$expected = [
'updateAvailable' => true,
'updateVersion' => 'ownCloud 123',
'updateLink' => 'https://owncloud.org/myUrl',
'updateVersion' => 'Nextcloud 123',
'updateLink' => 'https://docs.nextcloud.com/myUrl',
'downloadLink' => 'https://downloads.nextcloud.org/server',
];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}

View File

@ -519,7 +519,7 @@ $CONFIG = array(
/**
* URL that Nextcloud should use to look for updates
*/
'updater.server.url' => 'https://updates.nextcloud.org/server/',
'updater.server.url' => 'https://updates.nextcloud.com/update-server/',
/**
* Is Nextcloud connected to the Internet or running in a closed network?

View File

@ -59,7 +59,7 @@ class VersionCheck {
return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
}
$updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.com/server/');
$updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.com/update-server/');
$this->config->setAppValue('core', 'lastupdatedat', time());

View File

@ -91,8 +91,8 @@ class VersionCheckTest extends \Test\TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/server/')
->willReturn('https://updates.nextcloud.com/server/');
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
->willReturnArgument(1);
$this->config
->expects($this->at(2))
->method('setAppValue')
@ -122,7 +122,7 @@ class VersionCheckTest extends \Test\TestCase {
$this->updater
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.com/server/'))
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));
$this->assertSame($expectedResult, $this->updater->check());
@ -137,8 +137,8 @@ class VersionCheckTest extends \Test\TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/server/')
->willReturn('https://updates.nextcloud.com/server/');
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
->willReturnArgument(1);
$this->config
->expects($this->at(2))
->method('setAppValue')
@ -162,7 +162,7 @@ class VersionCheckTest extends \Test\TestCase {
$this->updater
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.com/server/'))
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));
$this->assertSame([], $this->updater->check());
@ -184,8 +184,8 @@ class VersionCheckTest extends \Test\TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/server/')
->willReturn('https://updates.nextcloud.com/server/');
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
->willReturnArgument(1);
$this->config
->expects($this->at(2))
->method('setAppValue')
@ -211,7 +211,7 @@ class VersionCheckTest extends \Test\TestCase {
$this->updater
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.com/server/'))
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));
$this->assertSame($expectedResult, $this->updater->check());
@ -228,8 +228,8 @@ class VersionCheckTest extends \Test\TestCase {
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/server/')
->willReturn('https://updates.nextcloud.com/server/');
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
->willReturnArgument(1);
$this->config
->expects($this->at(2))
->method('setAppValue')
@ -253,7 +253,7 @@ class VersionCheckTest extends \Test\TestCase {
$this->updater
->expects($this->once())
->method('getUrlContent')
->with($this->buildUpdateUrl('https://updates.nextcloud.com/server/'))
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
->will($this->returnValue($updateXml));
$this->assertSame($expectedResult, $this->updater->check());