diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-09-08 15:41:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-08 15:41:45 +0200 |
commit | 520bfa872b0a2c3b6a701158c1a5b34b778e286f (patch) | |
tree | 474db7179e14a5f9575715d130ffe947e3ce55c4 /apps | |
parent | 72fed6e8b86cabbdaf822c3e38b4d8de014094fd (diff) | |
parent | 280a4520556af5502fe06faf00f9dcfa3aadc590 (diff) | |
download | nextcloud-server-520bfa872b0a2c3b6a701158c1a5b34b778e286f.tar.gz nextcloud-server-520bfa872b0a2c3b6a701158c1a5b34b778e286f.zip |
Merge pull request #1324 from nextcloud/backport-1323-show-download-button-for-updates-atm
[stable10] Show an download button instead of the updater
Diffstat (limited to 'apps')
6 files changed, 22 insertions, 34 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 cf99679e680..92d2ee6dbe9 100644 --- a/apps/updatenotification/tests/Controller/AdminControllerTest.php +++ b/apps/updatenotification/tests/Controller/AdminControllerTest.php @@ -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, ''); 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()); } |