Skip to content

Commit c2b4eef

Browse files
committed
Improve update channel layout to be a popup menu
* now the entries are in a popup menu * if a non-default channel is used the entry will be at the bottom * channel descriptions are embeded into the menu * use nextcloud-vue componenets for the channel selector * update nextcloud-vue dependency from 0.6.1 to 0.6.3 * fixes #13806 Signed-off-by: Morris Jobke <hey@morrisjobke.de>
1 parent cc69038 commit c2b4eef

5 files changed

Lines changed: 147 additions & 57 deletions

File tree

apps/updatenotification/js/updatenotification.js

Lines changed: 13 additions & 13 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/package-lock.json

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

apps/updatenotification/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/nextcloud/notifications#readme",
2525
"dependencies": {
26-
"nextcloud-vue": "^0.6.1",
26+
"nextcloud-vue": "^0.6.3",
2727
"v-tooltip": "^2.0.0-rc.33",
2828
"vue": "^2.6.4",
2929
"vue-click-outside": "^1.0.7"

apps/updatenotification/src/components/root.vue

Lines changed: 126 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,24 @@
6363
</template>
6464
</div>
6565

66+
<h3 class="update-channel-selector">
67+
{{ t('updatenotification', 'Update channel:') }}
68+
<div class="update-menu">
69+
<span class="icon-update-menu" @click="toggleUpdateChannelMenu">
70+
{{ localizedChannelName }}
71+
<span class="icon-triangle-s"></span>
72+
</span>
73+
<div class="popovermenu menu menu-center" v-bind:class="{ 'show-menu': openedUpdateChannelMenu}">
74+
<popover-menu :menu="channelList" />
75+
</div>
76+
</div>
77+
</h3>
78+
<span id="channel_save_msg" class="msg"></span><br />
6679
<p>
67-
<label for="release-channel">{{ t('updatenotification', 'Update channel:') }}</label>
68-
<select id="release-channel" v-model="currentChannel" @change="changeReleaseChannel">
69-
<option v-for="channel in channels" :value="channel">{{channel}}</option>
70-
</select>
71-
<span id="channel_save_msg" class="msg"></span><br />
72-
<em>{{ t('updatenotification', 'You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel.') }}</em><br />
80+
<em>{{ t('updatenotification', 'You can always update to a newer version. But you can never downgrade to a more stable version.') }}</em><br />
7381
<em>{{ t('updatenotification', 'Note that after a new release it can take some time before it shows up here. We roll out new versions spread out over time to our users and sometimes skip a version when issues are found.') }}</em>
7482
</p>
7583

76-
<p class="channel-description">
77-
<span v-html="productionInfoString"></span><br>
78-
<span v-html="stableInfoString"></span><br>
79-
<span v-html="betaInfoString"></span>
80-
</p>
81-
8284
<p id="oca_updatenotification_groups">
8385
{{ t('updatenotification', 'Notify members of the following groups about available updates:') }}
8486
<multiselect v-model="notifyGroups" :options="availableGroups" :multiple="true" label="label" track-by="value" :tag-width="75" /><br />
@@ -131,11 +133,11 @@
131133
hideMissingUpdates: false,
132134
hideAvailableUpdates: true,
133135
openedWhatsNew: false,
136+
openedUpdateChannelMenu: false,
134137
};
135138
},
136139
137140
_$el: null,
138-
_$releaseChannel: null,
139141
_$notifyGroups: null,
140142
141143
watch: {
@@ -211,19 +213,7 @@
211213
this.missingAppUpdates.length);
212214
},
213215
214-
productionInfoString: function() {
215-
return t('updatenotification', '<strong>production</strong> will always provide the latest patch level, but not update to the next major release immediately. That update usually happens with the second minor release (x.0.2).');
216-
},
217-
218-
stableInfoString: function() {
219-
return t('updatenotification', '<strong>stable</strong> is the most recent stable version. It is suited for regular use and will always update to the latest major version.');
220-
},
221-
222-
betaInfoString: function() {
223-
return t('updatenotification', '<strong>beta</strong> is a pre-release version only for testing new features, not for production environments.');
224-
},
225-
226-
whatsNew: function () {
216+
whatsNew: function() {
227217
if(this.whatsNewData.length === 0) {
228218
return null;
229219
}
@@ -241,6 +231,65 @@
241231
});
242232
}
243233
return whatsNew;
234+
},
235+
236+
channelList: function() {
237+
let channelList = [];
238+
239+
channelList.push({
240+
text: t('updatenotificaiton', 'Stable'),
241+
longtext: t('updatenotification', 'The most recent stable version. It is suited for regular use and will always update to the latest major version.'),
242+
icon: 'icon-checkmark',
243+
active: this.currentChannel === 'stable',
244+
action: () => { this.changeReleaseChannel('stable') }
245+
});
246+
247+
channelList.push({
248+
text: t('updatenotificaiton', 'Production'),
249+
longtext: t('updatenotification', 'Will always provide the latest patch level, but not update to the next major release immediately. That update usually happens with the second minor release (x.0.2) and only if the instance is already on the latest minor version.'),
250+
icon: 'icon-star',
251+
active: this.currentChannel === 'production',
252+
action: () => { this.changeReleaseChannel('production') }
253+
});
254+
255+
channelList.push({
256+
text: t('updatenotificaiton', 'Beta'),
257+
longtext: t('updatenotification', 'A pre-release version only for testing new features, not for production environments.'),
258+
icon: 'icon-category-customization',
259+
active: this.currentChannel === 'beta',
260+
action: () => { this.changeReleaseChannel('beta') }
261+
});
262+
263+
if (this.isNonDefaultChannel) {
264+
channelList.push({
265+
text: this.currentChannel,
266+
icon: 'icon-rename',
267+
active: true
268+
});
269+
}
270+
271+
return channelList;
272+
},
273+
274+
isNonDefaultChannel: function() {
275+
return this.currentChannel !== 'production' && this.currentChannel !== 'stable' && this.currentChannel !== 'beta';
276+
},
277+
278+
localizedChannelName: function() {
279+
switch (this.currentChannel) {
280+
case 'production':
281+
return t('updatenotificaiton', 'Production');
282+
break;
283+
case 'stable':
284+
return t('updatenotificaiton', 'Stable');
285+
break;
286+
case 'beta':
287+
return t('updatenotificaiton', 'Beta');
288+
break;
289+
default:
290+
return this.currentChannel;
291+
break;
292+
}
244293
}
245294
},
246295
@@ -268,8 +317,8 @@
268317
form.submit();
269318
}.bind(this));
270319
},
271-
changeReleaseChannel: function() {
272-
this.currentChannel = this._$releaseChannel.val();
320+
changeReleaseChannel: function(channel) {
321+
this.currentChannel = channel;
273322
274323
$.ajax({
275324
url: OC.generateUrl('/apps/updatenotification/channel'),
@@ -281,6 +330,11 @@
281330
OC.msg.finishedAction('#channel_save_msg', data);
282331
}
283332
});
333+
334+
this.openedUpdateChannelMenu = false;
335+
},
336+
toggleUpdateChannelMenu: function() {
337+
this.openedUpdateChannelMenu = !this.openedUpdateChannelMenu;
284338
},
285339
toggleHideMissingUpdates: function() {
286340
this.hideMissingUpdates = !this.hideMissingUpdates;
@@ -324,7 +378,6 @@
324378
},
325379
mounted: function () {
326380
this._$el = $(this.$el);
327-
this._$releaseChannel = this._$el.find('#release-channel');
328381
this._$notifyGroups = this._$el.find('#oca_updatenotification_groups_list');
329382
this._$notifyGroups.on('change', function () {
330383
this.$emit('input');
@@ -350,6 +403,7 @@
350403
<style lang="sass" scoped>
351404
#updatenotification {
352405
margin-top: -25px;
406+
margin-bottom: 200px;
353407
div.update,
354408
p:not(.inlineblock) {
355409
margin-bottom: 25px;
@@ -365,6 +419,10 @@
365419
&:first-of-type {
366420
margin-top: 0;
367421
}
422+
&.update-channel-selector {
423+
display: inline-block;
424+
cursor: inherit;
425+
}
368426
}
369427
.icon {
370428
display: inline-block;
@@ -373,13 +431,6 @@
373431
.icon-triangle-s, .icon-triangle-n {
374432
opacity: 0.5;
375433
}
376-
.channel-description span {
377-
color: var(--color-text-lighter);
378-
strong {
379-
color: var(--color-main-text);
380-
font-weight: normal;
381-
}
382-
}
383434
.whatsNew {
384435
display: inline-block;
385436
}
@@ -397,5 +448,44 @@
397448
.applist {
398449
margin-bottom: 25px;
399450
}
451+
452+
.update-menu {
453+
position: relative;
454+
cursor: pointer;
455+
margin-left: 3px;
456+
display: inline-block;
457+
.icon-update-menu {
458+
cursor: inherit;
459+
.icon-triangle-s {
460+
display: inline-block;
461+
vertical-align: middle;
462+
cursor: inherit;
463+
opacity: 1;
464+
}
465+
}
466+
.popovermenu {
467+
display: none;
468+
top: 28px;
469+
&.show-menu {
470+
display: block;
471+
}
472+
}
473+
}
474+
}
475+
</style>
476+
<style lang="sass">
477+
/* override needed to make menu wider */
478+
#updatenotification .popovermenu {
479+
p {
480+
margin-top: 5px;
481+
width: 100%;
482+
}
483+
margin-top: 5px;
484+
width: 300px;
485+
}
486+
/* override needed to replace yellow hover state with a dark one */
487+
#updatenotification .update-menu .icon-star:hover,
488+
#updatenotification .update-menu .icon-star:focus {
489+
background-image: var(--icon-star-000);
400490
}
401491
</style>

0 commit comments

Comments
 (0)