Skip to content

Commit 17d581a

Browse files
authored
Merge pull request #12412 from nextcloud/backport/12358/fix-update-check
[stable14] Fix app update available check
2 parents 13eae29 + da21063 commit 17d581a

File tree

8 files changed

+35
-23
lines changed

8 files changed

+35
-23
lines changed

apps/updatenotification/css/admin.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@
6161
margin-top: 5px;
6262
width: 300px;
6363
}
64+
65+
#updatenotification .applist {
66+
margin-bottom: 25px;
67+
}

apps/updatenotification/js/updatenotification.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/updatenotification/js/updatenotification.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/updatenotification/lib/Settings/Admin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public function getForm(): TemplateResponse {
9797
'lastChecked' => $lastUpdateCheck,
9898
'currentChannel' => $currentChannel,
9999
'channels' => $channels,
100-
'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
100+
'newVersion' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
101+
'newVersionString' => empty($updateState['updateVersionString']) ? '' : $updateState['updateVersionString'],
101102
'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
102103
'changes' => $this->filterChanges($updateState['changes'] ?? []),
103104
'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],

apps/updatenotification/lib/UpdateChecker.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public function getUpdateState(): array {
5151

5252
if (isset($data['version']) && $data['version'] !== '' && $data['version'] !== []) {
5353
$result['updateAvailable'] = true;
54-
$result['updateVersion'] = $data['versionstring'];
54+
$result['updateVersion'] = $data['version'];
55+
$result['updateVersionString'] = $data['versionstring'];
5556
$result['updaterEnabled'] = $data['autoupdater'] === '1';
5657
$result['versionIsEol'] = $data['eol'] === '1';
5758
if (strpos($data['web'], 'https://') === 0) {
@@ -80,7 +81,7 @@ public function getUpdateState(): array {
8081
public function populateJavaScriptVariables(array $data) {
8182
$data['array']['oc_updateState'] = json_encode([
8283
'updateAvailable' => true,
83-
'updateVersion' => $this->getUpdateState()['updateVersion'],
84+
'updateVersion' => $this->getUpdateState()['updateVersionString'],
8485
'updateLink' => $this->getUpdateState()['updateLink'] ?? '',
8586
]);
8687
}

apps/updatenotification/src/components/root.vue

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
</ul>
3838
</template>
3939

40-
<a v-if="updaterEnabled" href="#" class="button" @click="clickUpdaterButton">{{ t('updatenotification', 'Open updater') }}</a>
41-
<a v-if="downloadLink" :href="downloadLink" class="button" :class="{ hidden: !updaterEnabled }">{{ t('updatenotification', 'Download now') }}</a>
40+
<p>
41+
<a v-if="updaterEnabled" href="#" class="button" @click="clickUpdaterButton">{{ t('updatenotification', 'Open updater') }}</a>
42+
<a v-if="downloadLink" :href="downloadLink" class="button" :class="{ hidden: !updaterEnabled }">{{ t('updatenotification', 'Download now') }}</a>
43+
</p>
4244
<div class="whatsNew" v-if="whatsNew">
4345
<div class="toggleWhatsNew">
4446
<span v-click-outside="hideMenu" @click="toggleMenu">{{ t('updatenotification', 'What\'s new?') }}</span>
@@ -55,8 +57,9 @@
5557
</template>
5658

5759
<template v-if="!isDefaultUpdateServerURL">
58-
<br />
59-
<em>{{ t('updatenotification', 'A non-default update server is in use to be checked for updates:') }} <code>{{updateServerURL}}</code></em>
60+
<p>
61+
<em>{{ t('updatenotification', 'A non-default update server is in use to be checked for updates:') }} <code>{{updateServerURL}}</code></em>
62+
</p>
6063
</template>
6164
</div>
6265

@@ -153,7 +156,7 @@
153156
}
154157
155158
$.ajax({
156-
url: OC.linkToOCS('apps/updatenotification/api/v1/applist', 2) + this.newVersionString,
159+
url: OC.linkToOCS('apps/updatenotification/api/v1/applist', 2) + this.newVersion,
157160
type: 'GET',
158161
beforeSend: function (request) {
159162
request.setRequestHeader('Accept', 'application/json');
@@ -193,20 +196,18 @@
193196
return t('updatenotification', 'Checking apps for compatible updates');
194197
}
195198
196-
if (this.appstoreDisabled) {
199+
if (this.appStoreDisabled) {
197200
return t('updatenotification', 'Please make sure your config.php does not set <samp>appstoreenabled</samp> to false.');
198201
}
199202
200-
if (this.appstoreFailed) {
203+
if (this.appStoreFailed) {
201204
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.');
202205
}
203206
204207
return this.missingAppUpdates.length === 0 ? t('updatenotification', '<strong>All</strong> apps have an update for this version available', this) : n('updatenotification',
205208
'<strong>%n</strong> app has no update for this version available',
206209
'<strong>%n</strong> apps have no update for this version available',
207-
this.missingAppUpdates.length, {
208-
version: this.newVersionString
209-
});
210+
this.missingAppUpdates.length);
210211
},
211212
212213
productionInfoString: function() {
@@ -310,6 +311,7 @@
310311
// Parse server data
311312
var data = JSON.parse($('#updatenotification').attr('data-json'));
312313
314+
this.newVersion = data.newVersion;
313315
this.newVersionString = data.newVersionString;
314316
this.lastCheckedDate = data.lastChecked;
315317
this.isUpdateChecked = data.isUpdateChecked;

apps/updatenotification/tests/Settings/AdminTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public function testGetFormWithUpdate() {
104104
->willReturn([
105105
'updateAvailable' => true,
106106
'updateVersion' => '8.1.2',
107+
'updateVersionString' => 'Nextcloud 8.1.2',
107108
'downloadLink' => 'https://downloads.nextcloud.org/server',
108109
'changes' => [],
109110
'updaterEnabled' => true,
@@ -129,7 +130,8 @@ public function testGetFormWithUpdate() {
129130
'lastChecked' => 'LastCheckedReturnValue',
130131
'currentChannel' => Util::getChannel(),
131132
'channels' => $channels,
132-
'newVersionString' => '8.1.2',
133+
'newVersion' => '8.1.2',
134+
'newVersionString' => 'Nextcloud 8.1.2',
133135
'downloadLink' => 'https://downloads.nextcloud.org/server',
134136
'changes' => [],
135137
'updaterEnabled' => true,

apps/updatenotification/tests/UpdateCheckerTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public function testGetUpdateStateWithUpdateAndInvalidLink() {
5151
->expects($this->once())
5252
->method('check')
5353
->willReturn([
54-
'version' => 123,
55-
'versionstring' => 'Nextcloud 123',
54+
'version' => '1.2.3',
55+
'versionstring' => 'Nextcloud 1.2.3',
5656
'web'=> 'javascript:alert(1)',
5757
'url'=> 'javascript:alert(2)',
5858
'changes' => 'javascript:alert(3)',
@@ -62,7 +62,8 @@ public function testGetUpdateStateWithUpdateAndInvalidLink() {
6262

6363
$expected = [
6464
'updateAvailable' => true,
65-
'updateVersion' => 'Nextcloud 123',
65+
'updateVersion' => '1.2.3',
66+
'updateVersionString' => 'Nextcloud 1.2.3',
6667
'updaterEnabled' => false,
6768
'versionIsEol' => true,
6869
];
@@ -91,8 +92,8 @@ public function testGetUpdateStateWithUpdateAndValidLink() {
9192
->expects($this->once())
9293
->method('check')
9394
->willReturn([
94-
'version' => '123',
95-
'versionstring' => 'Nextcloud 123',
95+
'version' => '1.2.3',
96+
'versionstring' => 'Nextcloud 1.2.3',
9697
'web'=> 'https://docs.nextcloud.com/myUrl',
9798
'url'=> 'https://downloads.nextcloud.org/server',
9899
'changes' => 'https://updates.nextcloud.com/changelog_server/?version=123.0.0',
@@ -106,7 +107,8 @@ public function testGetUpdateStateWithUpdateAndValidLink() {
106107

107108
$expected = [
108109
'updateAvailable' => true,
109-
'updateVersion' => 'Nextcloud 123',
110+
'updateVersion' => '1.2.3',
111+
'updateVersionString' => 'Nextcloud 1.2.3',
110112
'updaterEnabled' => true,
111113
'versionIsEol' => false,
112114
'updateLink' => 'https://docs.nextcloud.com/myUrl',

0 commit comments

Comments
 (0)