diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-09-08 15:40:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-08 15:40:41 +0200 |
commit | 7cd1369f7695974f720b3c47042692e2155f3f91 (patch) | |
tree | cac45d4bf1dba89dd1ebd6bd0e2064cce4ca99cc | |
parent | ef56b0b5c930e5325bfa2ba9a8484a4ea997e466 (diff) | |
parent | 0cec06d0c86f567bb3ff95c25bc7ff6d464bd2ba (diff) | |
download | nextcloud-server-7cd1369f7695974f720b3c47042692e2155f3f91.tar.gz nextcloud-server-7cd1369f7695974f720b3c47042692e2155f3f91.zip |
Merge pull request #1323 from nextcloud/show-download-button-for-updates-atm
Show an download button instead of the updater
-rw-r--r-- | apps/updatenotification/js/admin.js | 26 | ||||
-rw-r--r-- | apps/updatenotification/lib/Controller/AdminController.php | 1 | ||||
-rw-r--r-- | apps/updatenotification/lib/UpdateChecker.php | 3 | ||||
-rw-r--r-- | apps/updatenotification/templates/admin.php | 4 | ||||
-rw-r--r-- | apps/updatenotification/tests/Controller/AdminControllerTest.php | 7 | ||||
-rw-r--r-- | apps/updatenotification/tests/UpdateCheckerTest.php | 15 | ||||
-rw-r--r-- | config/config.sample.php | 2 | ||||
-rw-r--r-- | lib/private/Updater/VersionCheck.php | 2 | ||||
-rw-r--r-- | tests/lib/Updater/VersionCheckTest.php | 24 |
9 files changed, 36 insertions, 48 deletions
diff --git a/apps/updatenotification/js/admin.js b/apps/updatenotification/js/admin.js index 3ca45a191d4..e60e77ab89a 100644 --- a/apps/updatenotification/js/admin.js +++ b/apps/updatenotification/js/admin.js @@ -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(); diff --git a/apps/updatenotification/lib/Controller/AdminController.php b/apps/updatenotification/lib/Controller/AdminController.php index 9f10f1b32f2..16ae8144b16 100644 --- a/apps/updatenotification/lib/Controller/AdminController.php +++ b/apps/updatenotification/lib/Controller/AdminController.php @@ -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), ]; diff --git a/apps/updatenotification/lib/UpdateChecker.php b/apps/updatenotification/lib/UpdateChecker.php index dd51831007c..5f759b7c843 100644 --- a/apps/updatenotification/lib/UpdateChecker.php +++ b/apps/updatenotification/lib/UpdateChecker.php @@ -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; } diff --git a/apps/updatenotification/templates/admin.php b/apps/updatenotification/templates/admin.php index 68ef1d423b4..0dd8aec4a04 100644 --- a/apps/updatenotification/templates/admin.php +++ b/apps/updatenotification/templates/admin.php @@ -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> diff --git a/apps/updatenotification/tests/Controller/AdminControllerTest.php b/apps/updatenotification/tests/Controller/AdminControllerTest.php index 336edffc957..6d1ee219561 100644 --- a/apps/updatenotification/tests/Controller/AdminControllerTest.php +++ b/apps/updatenotification/tests/Controller/AdminControllerTest.php @@ -111,7 +111,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, @@ -120,6 +123,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, ''); @@ -164,6 +168,7 @@ class AdminControllerTest extends TestCase { 'channels' => $channels, 'newVersionString' => '', 'notify_groups' => 'admin', + 'downloadLink' => '', ]; $expected = new TemplateResponse('updatenotification', 'admin', $params, ''); diff --git a/apps/updatenotification/tests/UpdateCheckerTest.php b/apps/updatenotification/tests/UpdateCheckerTest.php index c2c9ba1438d..38e64b6b5e5 100644 --- a/apps/updatenotification/tests/UpdateCheckerTest.php +++ b/apps/updatenotification/tests/UpdateCheckerTest.php @@ -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()); } diff --git a/config/config.sample.php b/config/config.sample.php index 2b39e93aade..d6680caac18 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -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? diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php index 88ba9b63fa3..e846052a300 100644 --- a/lib/private/Updater/VersionCheck.php +++ b/lib/private/Updater/VersionCheck.php @@ -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()); diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php index e9b915f1508..d6b457da8a2 100644 --- a/tests/lib/Updater/VersionCheckTest.php +++ b/tests/lib/Updater/VersionCheckTest.php @@ -93,8 +93,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') @@ -124,7 +124,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()); @@ -139,8 +139,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') @@ -164,7 +164,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()); @@ -186,8 +186,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') @@ -213,7 +213,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()); @@ -230,8 +230,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') @@ -255,7 +255,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()); |