Merge pull request #12412 from nextcloud/backport/12358/fix-update-check

[stable14] Fix app update available check
This commit is contained in:
Morris Jobke 2018-11-12 16:23:33 +01:00 committed by GitHub
commit 17d581a446
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 35 additions and 23 deletions

View file

@ -61,3 +61,7 @@
margin-top: 5px;
width: 300px;
}
#updatenotification .applist {
margin-bottom: 25px;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -97,7 +97,8 @@ class Admin implements ISettings {
'lastChecked' => $lastUpdateCheck,
'currentChannel' => $currentChannel,
'channels' => $channels,
'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
'newVersion' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
'newVersionString' => empty($updateState['updateVersionString']) ? '' : $updateState['updateVersionString'],
'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
'changes' => $this->filterChanges($updateState['changes'] ?? []),
'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],

View file

@ -51,7 +51,8 @@ class UpdateChecker {
if (isset($data['version']) && $data['version'] !== '' && $data['version'] !== []) {
$result['updateAvailable'] = true;
$result['updateVersion'] = $data['versionstring'];
$result['updateVersion'] = $data['version'];
$result['updateVersionString'] = $data['versionstring'];
$result['updaterEnabled'] = $data['autoupdater'] === '1';
$result['versionIsEol'] = $data['eol'] === '1';
if (strpos($data['web'], 'https://') === 0) {
@ -80,7 +81,7 @@ class UpdateChecker {
public function populateJavaScriptVariables(array $data) {
$data['array']['oc_updateState'] = json_encode([
'updateAvailable' => true,
'updateVersion' => $this->getUpdateState()['updateVersion'],
'updateVersion' => $this->getUpdateState()['updateVersionString'],
'updateLink' => $this->getUpdateState()['updateLink'] ?? '',
]);
}

View file

@ -37,8 +37,10 @@
</ul>
</template>
<a v-if="updaterEnabled" href="#" class="button" @click="clickUpdaterButton">{{ t('updatenotification', 'Open updater') }}</a>
<a v-if="downloadLink" :href="downloadLink" class="button" :class="{ hidden: !updaterEnabled }">{{ t('updatenotification', 'Download now') }}</a>
<p>
<a v-if="updaterEnabled" href="#" class="button" @click="clickUpdaterButton">{{ t('updatenotification', 'Open updater') }}</a>
<a v-if="downloadLink" :href="downloadLink" class="button" :class="{ hidden: !updaterEnabled }">{{ t('updatenotification', 'Download now') }}</a>
</p>
<div class="whatsNew" v-if="whatsNew">
<div class="toggleWhatsNew">
<span v-click-outside="hideMenu" @click="toggleMenu">{{ t('updatenotification', 'What\'s new?') }}</span>
@ -55,8 +57,9 @@
</template>
<template v-if="!isDefaultUpdateServerURL">
<br />
<em>{{ t('updatenotification', 'A non-default update server is in use to be checked for updates:') }} <code>{{updateServerURL}}</code></em>
<p>
<em>{{ t('updatenotification', 'A non-default update server is in use to be checked for updates:') }} <code>{{updateServerURL}}</code></em>
</p>
</template>
</div>
@ -153,7 +156,7 @@
}
$.ajax({
url: OC.linkToOCS('apps/updatenotification/api/v1/applist', 2) + this.newVersionString,
url: OC.linkToOCS('apps/updatenotification/api/v1/applist', 2) + this.newVersion,
type: 'GET',
beforeSend: function (request) {
request.setRequestHeader('Accept', 'application/json');
@ -193,20 +196,18 @@
return t('updatenotification', 'Checking apps for compatible updates');
}
if (this.appstoreDisabled) {
if (this.appStoreDisabled) {
return t('updatenotification', 'Please make sure your config.php does not set <samp>appstoreenabled</samp> to false.');
}
if (this.appstoreFailed) {
if (this.appStoreFailed) {
return t('updatenotification', 'Could not connect to the appstore or the appstore returned no updates at all. Search manually for updates or make sure your server has access to the internet and can connect to the appstore.');
}
return this.missingAppUpdates.length === 0 ? t('updatenotification', '<strong>All</strong> apps have an update for this version available', this) : n('updatenotification',
'<strong>%n</strong> app has no update for this version available',
'<strong>%n</strong> apps have no update for this version available',
this.missingAppUpdates.length, {
version: this.newVersionString
});
this.missingAppUpdates.length);
},
productionInfoString: function() {
@ -310,6 +311,7 @@
// Parse server data
var data = JSON.parse($('#updatenotification').attr('data-json'));
this.newVersion = data.newVersion;
this.newVersionString = data.newVersionString;
this.lastCheckedDate = data.lastChecked;
this.isUpdateChecked = data.isUpdateChecked;

View file

@ -104,6 +104,7 @@ class AdminTest extends TestCase {
->willReturn([
'updateAvailable' => true,
'updateVersion' => '8.1.2',
'updateVersionString' => 'Nextcloud 8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'changes' => [],
'updaterEnabled' => true,
@ -129,7 +130,8 @@ class AdminTest extends TestCase {
'lastChecked' => 'LastCheckedReturnValue',
'currentChannel' => Util::getChannel(),
'channels' => $channels,
'newVersionString' => '8.1.2',
'newVersion' => '8.1.2',
'newVersionString' => 'Nextcloud 8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'changes' => [],
'updaterEnabled' => true,

View file

@ -51,8 +51,8 @@ class UpdateCheckerTest extends TestCase {
->expects($this->once())
->method('check')
->willReturn([
'version' => 123,
'versionstring' => 'Nextcloud 123',
'version' => '1.2.3',
'versionstring' => 'Nextcloud 1.2.3',
'web'=> 'javascript:alert(1)',
'url'=> 'javascript:alert(2)',
'changes' => 'javascript:alert(3)',
@ -62,7 +62,8 @@ class UpdateCheckerTest extends TestCase {
$expected = [
'updateAvailable' => true,
'updateVersion' => 'Nextcloud 123',
'updateVersion' => '1.2.3',
'updateVersionString' => 'Nextcloud 1.2.3',
'updaterEnabled' => false,
'versionIsEol' => true,
];
@ -91,8 +92,8 @@ class UpdateCheckerTest extends TestCase {
->expects($this->once())
->method('check')
->willReturn([
'version' => '123',
'versionstring' => 'Nextcloud 123',
'version' => '1.2.3',
'versionstring' => 'Nextcloud 1.2.3',
'web'=> 'https://docs.nextcloud.com/myUrl',
'url'=> 'https://downloads.nextcloud.org/server',
'changes' => 'https://updates.nextcloud.com/changelog_server/?version=123.0.0',
@ -106,7 +107,8 @@ class UpdateCheckerTest extends TestCase {
$expected = [
'updateAvailable' => true,
'updateVersion' => 'Nextcloud 123',
'updateVersion' => '1.2.3',
'updateVersionString' => 'Nextcloud 1.2.3',
'updaterEnabled' => true,
'versionIsEol' => false,
'updateLink' => 'https://docs.nextcloud.com/myUrl',