Merge pull request #1325 from nextcloud/backport-1323-show-download-button-for-updates-atm-9
[stable9] Show an download button instead of the updater
This commit is contained in:
commit
36c554718f
|
@ -134,6 +134,7 @@ class AdminController extends Controller {
|
|||
'channels' => $channels,
|
||||
'newVersionString' => ($updateState === []) ? '' : $updateState['updateVersion'],
|
||||
'updaterRequirementsFulfilled' => $this->isCompatibleWithUpdater(),
|
||||
'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'],
|
||||
];
|
||||
|
||||
return new TemplateResponse($this->appName, 'admin', $params, '');
|
||||
|
|
|
@ -13,32 +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();
|
||||
$.post(
|
||||
|
|
|
@ -48,6 +48,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;
|
||||
}
|
||||
|
|
|
@ -20,10 +20,8 @@
|
|||
|
||||
<?php if($isNewVersionAvailable === true): ?>
|
||||
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>
|
||||
<?php if($updaterRequirementsFulfilled === true): ?>
|
||||
<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
|
||||
<?php else: ?>
|
||||
<br/><?php p($l->t('At the moment only manual updates are supported on your environment. This is very likely the case because functions such as shell_exec are not available.')); ?>
|
||||
<?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>
|
||||
|
|
|
@ -46,13 +46,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());
|
||||
}
|
||||
|
@ -63,14 +64,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());
|
||||
}
|
||||
|
|
|
@ -127,6 +127,7 @@ class AdminControllerTest extends TestCase {
|
|||
'channels' => $channels,
|
||||
'newVersionString' => '8.1.2',
|
||||
'updaterRequirementsFulfilled' => true,
|
||||
'downloadLink' => '',
|
||||
];
|
||||
|
||||
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
|
||||
|
@ -160,7 +161,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',
|
||||
]);
|
||||
$this->adminController
|
||||
->expects($this->once())
|
||||
->method('isCompatibleWithUpdater')
|
||||
|
@ -173,6 +177,7 @@ class AdminControllerTest extends TestCase {
|
|||
'channels' => $channels,
|
||||
'newVersionString' => '8.1.2',
|
||||
'updaterRequirementsFulfilled' => false,
|
||||
'downloadLink' => 'https://downloads.nextcloud.org/server',
|
||||
];
|
||||
|
||||
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
|
||||
|
@ -219,6 +224,7 @@ class AdminControllerTest extends TestCase {
|
|||
'channels' => $channels,
|
||||
'newVersionString' => '',
|
||||
'updaterRequirementsFulfilled' => true,
|
||||
'downloadLink' => '',
|
||||
];
|
||||
|
||||
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
|
||||
|
|
|
@ -498,7 +498,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/',
|
||||
|
||||
/**
|
||||
* Release channel to use for updates
|
||||
|
|
|
@ -144,7 +144,7 @@ class Updater extends BasicEmitter {
|
|||
return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
|
||||
}
|
||||
|
||||
$updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.org/server/');
|
||||
$updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.com/update-server/');
|
||||
|
||||
$this->config->setAppValue('core', 'lastupdatedat', time());
|
||||
|
||||
|
|
|
@ -222,8 +222,8 @@ class UpdaterTest extends \Test\TestCase {
|
|||
$this->config
|
||||
->expects($this->at(1))
|
||||
->method('getSystemValue')
|
||||
->with('updater.server.url', 'https://updates.nextcloud.org/server/')
|
||||
->willReturn('https://updates.nextcloud.org/server/');
|
||||
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
|
||||
->willReturn('https://updates.nextcloud.com/update-server/');
|
||||
$this->config
|
||||
->expects($this->at(2))
|
||||
->method('setAppValue')
|
||||
|
@ -253,7 +253,7 @@ class UpdaterTest extends \Test\TestCase {
|
|||
$this->httpHelper
|
||||
->expects($this->once())
|
||||
->method('getUrlContent')
|
||||
->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
|
||||
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
|
||||
->will($this->returnValue($updateXml));
|
||||
|
||||
$this->assertSame($expectedResult, $this->updater->check());
|
||||
|
@ -268,8 +268,8 @@ class UpdaterTest extends \Test\TestCase {
|
|||
$this->config
|
||||
->expects($this->at(1))
|
||||
->method('getSystemValue')
|
||||
->with('updater.server.url', 'https://updates.nextcloud.org/server/')
|
||||
->willReturn('https://updates.nextcloud.org/server/');
|
||||
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
|
||||
->willReturn('https://updates.nextcloud.com/update-server/');
|
||||
$this->config
|
||||
->expects($this->at(2))
|
||||
->method('setAppValue')
|
||||
|
@ -293,7 +293,7 @@ class UpdaterTest extends \Test\TestCase {
|
|||
$this->httpHelper
|
||||
->expects($this->once())
|
||||
->method('getUrlContent')
|
||||
->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
|
||||
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
|
||||
->will($this->returnValue($updateXml));
|
||||
|
||||
$this->assertSame([], $this->updater->check());
|
||||
|
@ -315,8 +315,8 @@ class UpdaterTest extends \Test\TestCase {
|
|||
$this->config
|
||||
->expects($this->at(1))
|
||||
->method('getSystemValue')
|
||||
->with('updater.server.url', 'https://updates.nextcloud.org/server/')
|
||||
->willReturn('https://updates.nextcloud.org/server/');
|
||||
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
|
||||
->willReturn('https://updates.nextcloud.com/update-server/');
|
||||
$this->config
|
||||
->expects($this->at(2))
|
||||
->method('setAppValue')
|
||||
|
@ -342,7 +342,7 @@ class UpdaterTest extends \Test\TestCase {
|
|||
$this->httpHelper
|
||||
->expects($this->once())
|
||||
->method('getUrlContent')
|
||||
->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
|
||||
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
|
||||
->will($this->returnValue($updateXml));
|
||||
|
||||
$this->assertSame($expectedResult, $this->updater->check());
|
||||
|
@ -359,8 +359,8 @@ class UpdaterTest extends \Test\TestCase {
|
|||
$this->config
|
||||
->expects($this->at(1))
|
||||
->method('getSystemValue')
|
||||
->with('updater.server.url', 'https://updates.nextcloud.org/server/')
|
||||
->willReturn('https://updates.nextcloud.org/server/');
|
||||
->with('updater.server.url', 'https://updates.nextcloud.com/update-server/')
|
||||
->willReturn('https://updates.nextcloud.com/update-server/');
|
||||
$this->config
|
||||
->expects($this->at(2))
|
||||
->method('setAppValue')
|
||||
|
@ -384,7 +384,7 @@ class UpdaterTest extends \Test\TestCase {
|
|||
$this->httpHelper
|
||||
->expects($this->once())
|
||||
->method('getUrlContent')
|
||||
->with($this->buildUpdateUrl('https://updates.nextcloud.org/server/'))
|
||||
->with($this->buildUpdateUrl('https://updates.nextcloud.com/update-server/'))
|
||||
->will($this->returnValue($updateXml));
|
||||
|
||||
$this->assertSame($expectedResult, $this->updater->check());
|
||||
|
|
Loading…
Reference in New Issue