display whats new info in admin settings

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2018-05-30 15:53:08 +02:00 committed by Morris Jobke
parent 61842f66ee
commit bafb6b3c29
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
11 changed files with 151 additions and 12 deletions

View File

@ -44,3 +44,30 @@
#updatenotification .warning {
color: #ce3702;
}
#updatenotification .whatsNew {
display: inline-block;
}
#updatenotification .toggleWhatsNews {
position: relative;
}
#updatenotification .item-wrapper {
display: flex;
align-items: flex-start;
}
#updatenotification .item-wrapper {
display: flex;
align-items: flex-start;
}
#updatenotification .item-wrapper p {
margin-bottom: 10px;
margin-left: 0.5em;
}
#updatenotification .item-wrapper span[class^="icon-"] {
padding: 0 19px 0 0;
}

View File

@ -0,0 +1,18 @@
<template>
<ul>
<popover-item v-for="(item, key) in menu" :item="item" :key="key" />
</ul>
</template>
<script>
import popoverItem from './popoverMenu/popoverItem';
export default {
name: 'popoverMenu',
props: ['menu'],
components: {
popoverItem
}
}
</script>

View File

@ -0,0 +1,28 @@
<template>
<li>
<!-- If item.href is set, a link will be directly used -->
<a @click="item.action" v-if="item.href" :href="(item.href) ? item.href : '#' " :target="(item.target) ? item.target : '' " rel="noreferrer noopener">
<span :class="item.icon"></span>
<span v-if="item.text">{{item.text}}</span>
<p v-else-if="item.longtext">{{item.longtext}}</p>
</a>
<!-- If item.action is set instead, a button will be used -->
<button @click="item.action" v-else-if="item.action">
<span :class="item.icon"></span>
<span v-if="item.text">{{item.text}}</span>
<p v-else-if="item.longtext">{{item.longtext}}</p>
</button>
<!-- If item.longtext is set AND the item does not have an action -->
<span class="item-wrapper" v-else>
<span :class="item.icon"></span>
<span v-if="item.text">{{item.text}}</span>
<p v-else-if="item.longtext">{{item.longtext}}</p>
</span>
</li>
</template>
<script>
export default {
props: ['item']
}
</script>

View File

@ -39,6 +39,14 @@
<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>
<div class="whatsNew" v-if="whatsNew">
<div class="toggleWhatsNews">
<span v-click-outside="hideMenu" @click="toggleMenu">{{ t('updatenotification', 'What\'s new?') }}</span>
<div class="popovermenu" :class="{ 'open': openedWhatsNew }">
<popover-menu :menu="whatsNew" />
</div>
</div>
</div>
</template>
<template v-else-if="!isUpdateChecked">{{ t('updatenotification', 'The update check is not yet finished. Please refresh the page.') }}</template>
<template v-else>
@ -80,11 +88,17 @@
<script>
import vSelect from 'vue-select';
import popoverMenu from './popoverMenu';
import ClickOutside from 'vue-click-outside';
export default {
name: 'root',
components: {
vSelect,
popoverMenu,
},
directives: {
ClickOutside
},
data: function () {
return {
@ -96,6 +110,8 @@
downloadLink: '',
isNewVersionAvailable: false,
updateServerURL: '',
changelogURL: '',
whatsNewData: [],
currentChannel: '',
channels: [],
notifyGroups: '',
@ -109,7 +125,8 @@
appStoreDisabled: false,
isListFetched: false,
hideMissingUpdates: false,
hideAvailableUpdates: true
hideAvailableUpdates: true,
openedWhatsNew: false,
};
},
@ -202,6 +219,24 @@
betaInfoString: function() {
return t('updatenotification', '<strong>beta</strong> is a pre-release version only for testing new features, not for production environments.');
},
whatsNew: function () {
console.warn("fobar");
var whatsNew = [];
for (var i in this.whatsNewData) {
whatsNew[i] = { icon: 'icon-star-dark', longtext: this.whatsNewData[i] };
}
if(this.changelogURL) {
whatsNew.push({
href: this.changelogURL,
text: t('updatenotificaiton', 'View changelog'),
icon: 'icon-link',
target: '_blank',
action: ''
});
}
return whatsNew;
}
},
@ -261,11 +296,18 @@
},
toggleHideAvailableUpdates: function() {
this.hideAvailableUpdates = !this.hideAvailableUpdates;
}
},
toggleMenu() {
this.openedWhatsNew = !this.openedWhatsNew;
},
hideMenu() {
this.openedWhatsNew = false;
},
},
beforeMount: function() {
// Parse server data
var data = JSON.parse($('#updatenotification').attr('data-json'));
console.warn(data);
this.newVersionString = data.newVersionString;
this.lastCheckedDate = data.lastChecked;
@ -279,6 +321,7 @@
this.notifyGroups = data.notifyGroups;
this.isDefaultUpdateServerURL = data.isDefaultUpdateServerURL;
this.versionIsEol = data.versionIsEol;
this.whatsNewData = data.whatsNew;
},
mounted: function () {
this._$el = $(this.$el);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -93,6 +93,8 @@ class Admin implements ISettings {
'channels' => $channels,
'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
'changelogURL' => empty($updateState['changelog']) ? false : $updateState['changelog'],
'whatsNew' => empty($updateState['whatsNew']) ? false : $updateState['whatsNew'],
'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL,

View File

@ -56,6 +56,12 @@ class UpdateChecker {
if (strpos($data['url'], 'https://') === 0) {
$result['downloadLink'] = $data['url'];
}
if (strpos($data['changelog'], 'https://') === 0) {
$result['changelog'] = $data['changelog'];
}
if($data['whatsNew'] !== null) {
$result['whatsNew'] = $data['whatsNew'];
}
return $result;
}

View File

@ -2076,7 +2076,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -2491,7 +2492,8 @@
"safe-buffer": {
"version": "5.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -2547,6 +2549,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -2590,12 +2593,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},
@ -6839,6 +6844,11 @@
"resolved": "https://registry.npmjs.org/vue/-/vue-2.5.16.tgz",
"integrity": "sha512-/ffmsiVuPC8PsWcFkZngdpas19ABm5mh2wA7iDqcltyCTwlgZjHGeJYOXkBMo422iPwIcviOtrTCUpSfXmToLQ=="
},
"vue-click-outside": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/vue-click-outside/-/vue-click-outside-1.0.7.tgz",
"integrity": "sha1-zdKxYF48SUR4TheU6uShKg9wC9Y="
},
"vue-hot-reload-api": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.0.tgz",

View File

@ -25,6 +25,7 @@
"homepage": "https://github.com/nextcloud/notifications#readme",
"dependencies": {
"vue": "^2.5.16",
"vue-click-outside": "^1.0.7",
"vue-select": "^2.4.0"
},
"devDependencies": {

View File

@ -55,7 +55,7 @@ class VersionCheck {
*/
public function check() {
// Look up the cache - it is invalidated all 30 minutes
if (((int)$this->config->getAppValue('core', 'lastupdatedat') + 1800) > time()) {
if (false && ((int)$this->config->getAppValue('core', 'lastupdatedat') + 1800) > time()) {
return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
}
@ -70,7 +70,7 @@ class VersionCheck {
$version = Util::getVersion();
$version['installed'] = $this->config->getAppValue('core', 'installedat');
$version['updated'] = $this->config->getAppValue('core', 'lastupdatedat');
$version['updatechannel'] = \OC_Util::getChannel();
$version['updatechannel'] = 'stable'; //\OC_Util::getChannel();
$version['edition'] = '';
$version['build'] = \OC_Util::getBuild();
$version['php_major'] = PHP_MAJOR_VERSION;
@ -97,6 +97,10 @@ class VersionCheck {
$tmp['versionstring'] = (string)$data->versionstring;
$tmp['url'] = (string)$data->url;
$tmp['web'] = (string)$data->web;
$tmp['changelog'] = isset($data->changelog) ? (string)$data->changelog : null;
// TODO: one's it is decided, use the proper field…
$tmp['whatsNew'] = isset($data->whatsNew) ? ((array)$data->whatsNew)['item'] : null;
$tmp['whatsNew'] = isset($data->whatsNew_admin) ? ((array)$data->whatsNew_admin)['item'] : (string)$data->whatsNew;
$tmp['autoupdater'] = (string)$data->autoupdater;
$tmp['eol'] = isset($data->eol) ? (string)$data->eol : '0';
} else {