add update all button (#17512)

add update all button
This commit is contained in:
John Molakvoæ 2019-12-03 08:14:59 +01:00 committed by GitHub
commit bcc32f6918
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 41 additions and 2 deletions

View file

@ -943,9 +943,17 @@ span.version {
.section { .section {
cursor: pointer; cursor: pointer;
} }
.app-list-move { .app-list-move {
transition: transform 1s; transition: transform 1s;
} }
#app-list-update-all {
margin-left: 10px;
}
.counter {
padding-left: $header-height - 10px;
margin: 10px;
}
&.installed { &.installed {
.apps-list-container { .apps-list-container {
display: table; display: table;
@ -969,6 +977,7 @@ span.version {
&.selected { &.selected {
background-color: var(--color-background-dark); background-color: var(--color-background-dark);
} }
} }
.groups-enable { .groups-enable {
margin-top: 0; margin-top: 0;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -24,6 +24,13 @@
<div id="app-content-inner"> <div id="app-content-inner">
<div id="apps-list" class="apps-list" :class="{installed: (useBundleView || useListView), store: useAppStoreView}"> <div id="apps-list" class="apps-list" :class="{installed: (useBundleView || useListView), store: useAppStoreView}">
<template v-if="useListView"> <template v-if="useListView">
<div v-if="showUpdateAll" class="counter">
{{ t('settings', '{counter} apps have an update available', {counter}) }}
<button v-if="showUpdateAll"
id="app-list-update-all"
class="primary"
@click="updateAll">{{t('settings', 'Update all')}}</button>
</div>
<transition-group name="app-list" tag="div" class="apps-list-container"> <transition-group name="app-list" tag="div" class="apps-list-container">
<AppItem v-for="app in apps" <AppItem v-for="app in apps"
:key="app.id" :key="app.id"
@ -91,6 +98,7 @@
<script> <script>
import AppItem from './AppList/AppItem' import AppItem from './AppList/AppItem'
import PrefixMixin from './PrefixMixin' import PrefixMixin from './PrefixMixin'
import pLimit from 'p-limit'
export default { export default {
name: 'AppList', name: 'AppList',
@ -100,9 +108,18 @@ export default {
mixins: [PrefixMixin], mixins: [PrefixMixin],
props: ['category', 'app', 'search'], props: ['category', 'app', 'search'],
computed: { computed: {
counter() {
return this.apps.filter(app => app.update).length
},
loading() { loading() {
return this.$store.getters.loading('list') return this.$store.getters.loading('list')
}, },
hasPendingUpdate() {
return this.apps.filter(app => app.update).length > 1
},
showUpdateAll() {
return this.hasPendingUpdate && ['installed', 'updates'].includes(this.category)
},
apps() { apps() {
let apps = this.$store.getters.getAllApps let apps = this.$store.getters.getAllApps
.filter(app => app.name.toLowerCase().search(this.search.toLowerCase()) !== -1) .filter(app => app.name.toLowerCase().search(this.search.toLowerCase()) !== -1)
@ -189,12 +206,24 @@ export default {
enableBundle(id) { enableBundle(id) {
let apps = this.bundleApps(id).map(app => app.id) let apps = this.bundleApps(id).map(app => app.id)
this.$store.dispatch('enableApp', { appId: apps, groups: [] }) this.$store.dispatch('enableApp', { appId: apps, groups: [] })
.catch((error) => { console.error(error); OC.Notification.show(error) }) .catch((error) => {
console.error(error)
OC.Notification.show(error)
})
}, },
disableBundle(id) { disableBundle(id) {
let apps = this.bundleApps(id).map(app => app.id) let apps = this.bundleApps(id).map(app => app.id)
this.$store.dispatch('disableApp', { appId: apps, groups: [] }) this.$store.dispatch('disableApp', { appId: apps, groups: [] })
.catch((error) => { OC.Notification.show(error) }) .catch((error) => {
OC.Notification.show(error)
})
},
updateAll() {
const limit = pLimit(1)
this.apps
.filter(app => app.update)
.map(app => limit(() => this.$store.dispatch('updateApp', { appId: app.id }))
)
} }
} }
} }

View file

@ -57,6 +57,7 @@
"nextcloud-router": "0.0.9", "nextcloud-router": "0.0.9",
"nextcloud-vue": "^0.12.7", "nextcloud-vue": "^0.12.7",
"nextcloud-vue-collections": "^0.6.0", "nextcloud-vue-collections": "^0.6.0",
"p-limit": "^2.2.1",
"p-queue": "^6.2.1", "p-queue": "^6.2.1",
"query-string": "^5.1.1", "query-string": "^5.1.1",
"select2": "3.5.1", "select2": "3.5.1",