mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
Merge pull request #47055 from nextcloud/feat/select-install-recommended-apps
This commit is contained in:
commit
4642d82e8b
6 changed files with 44 additions and 23 deletions
|
|
@ -12,19 +12,12 @@
|
|||
<p v-else-if="loadingAppsError" class="loading-error text-center">
|
||||
{{ t('core', 'Could not fetch list of apps from the App Store.') }}
|
||||
</p>
|
||||
<p v-else-if="installingApps" class="text-center">
|
||||
{{ t('core', 'Installing apps …') }}
|
||||
</p>
|
||||
|
||||
<div v-for="app in recommendedApps" :key="app.id" class="app">
|
||||
<template v-if="!isHidden(app.id)">
|
||||
<img :src="customIcon(app.id)" alt="">
|
||||
<div class="info">
|
||||
<h3>
|
||||
{{ customName(app) }}
|
||||
<span v-if="app.loading" class="icon icon-loading-small-dark" />
|
||||
<span v-else-if="app.active" class="icon icon-checkmark-white" />
|
||||
</h3>
|
||||
<h3>{{ customName(app) }}</h3>
|
||||
<p v-html="customDescription(app.id)" />
|
||||
<p v-if="app.installationError">
|
||||
<strong>{{ t('core', 'App download or installation failed') }}</strong>
|
||||
|
|
@ -36,11 +29,15 @@
|
|||
<strong>{{ t('core', 'Cannot install this app') }}</strong>
|
||||
</p>
|
||||
</div>
|
||||
<NcCheckboxRadioSwitch :checked="app.isSelected || app.active"
|
||||
:disabled="!app.isCompatible || app.active"
|
||||
:loading="app.loading"
|
||||
@update:checked="toggleSelect(app.id)" />
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="dialog-row">
|
||||
<NcButton v-if="showInstallButton"
|
||||
<NcButton v-if="showInstallButton && !installingApps"
|
||||
type="tertiary"
|
||||
role="link"
|
||||
:href="defaultPageUrl">
|
||||
|
|
@ -49,8 +46,9 @@
|
|||
|
||||
<NcButton v-if="showInstallButton"
|
||||
type="primary"
|
||||
:disabled="installingApps || !isAnyAppSelected"
|
||||
@click.stop.prevent="installApps">
|
||||
{{ t('core', 'Install recommended apps') }}
|
||||
{{ installingApps ? t('core', 'Installing apps …') : t('core', 'Install recommended apps') }}
|
||||
</NcButton>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -63,6 +61,7 @@ import { loadState } from '@nextcloud/initial-state'
|
|||
import pLimit from 'p-limit'
|
||||
import { translate as t } from '@nextcloud/l10n'
|
||||
|
||||
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
|
||||
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
|
||||
|
||||
import logger from '../../logger.js'
|
||||
|
|
@ -102,6 +101,7 @@ const recommendedIds = Object.keys(recommended)
|
|||
export default {
|
||||
name: 'RecommendedApps',
|
||||
components: {
|
||||
NcCheckboxRadioSwitch,
|
||||
NcButton,
|
||||
},
|
||||
data() {
|
||||
|
|
@ -118,13 +118,16 @@ export default {
|
|||
recommendedApps() {
|
||||
return this.apps.filter(app => recommendedIds.includes(app.id))
|
||||
},
|
||||
isAnyAppSelected() {
|
||||
return this.recommendedApps.some(app => app.isSelected)
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
try {
|
||||
const { data } = await axios.get(generateUrl('settings/apps/list'))
|
||||
logger.info(`${data.apps.length} apps fetched`)
|
||||
|
||||
this.apps = data.apps.map(app => Object.assign(app, { loading: false, installationError: false }))
|
||||
this.apps = data.apps.map(app => Object.assign(app, { loading: false, installationError: false, isSelected: app.isCompatible }))
|
||||
logger.debug(`${this.recommendedApps.length} recommended apps found`, { apps: this.recommendedApps })
|
||||
|
||||
this.showInstallButton = true
|
||||
|
|
@ -138,23 +141,24 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
installApps() {
|
||||
this.showInstallButton = false
|
||||
this.installingApps = true
|
||||
|
||||
const limit = pLimit(1)
|
||||
const installing = this.recommendedApps
|
||||
.filter(app => !app.active && app.isCompatible && app.canInstall)
|
||||
.map(app => limit(() => {
|
||||
.filter(app => !app.active && app.isCompatible && app.canInstall && app.isSelected)
|
||||
.map(app => limit(async () => {
|
||||
logger.info(`installing ${app.id}`)
|
||||
app.loading = true
|
||||
return axios.post(generateUrl('settings/apps/enable'), { appIds: [app.id], groups: [] })
|
||||
.catch(error => {
|
||||
logger.error(`could not install ${app.id}`, { error })
|
||||
app.isSelected = false
|
||||
app.installationError = true
|
||||
})
|
||||
.then(() => {
|
||||
logger.info(`installed ${app.id}`)
|
||||
app.loading = false
|
||||
app.active = true
|
||||
})
|
||||
}))
|
||||
logger.debug(`installing ${installing.length} recommended apps`)
|
||||
|
|
@ -192,6 +196,14 @@ export default {
|
|||
}
|
||||
return !!recommended[appId].hidden
|
||||
},
|
||||
toggleSelect(appId) {
|
||||
// disable toggle when installButton is disabled
|
||||
if (!(appId in recommended) || !this.showInstallButton) {
|
||||
return
|
||||
}
|
||||
const index = this.apps.findIndex(app => app.id === appId)
|
||||
this.$set(this.apps[index], 'isSelected', !this.apps[index].isSelected)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
@ -240,10 +252,11 @@ p {
|
|||
h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
h3 > span.icon {
|
||||
display: inline-block;
|
||||
}
|
||||
.checkbox-radio-switch {
|
||||
margin-left: auto;
|
||||
padding: 0 2px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
4
dist/core-common.js
vendored
4
dist/core-common.js
vendored
File diff suppressed because one or more lines are too long
2
dist/core-common.js.map
vendored
2
dist/core-common.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/core-recommendedapps.js
vendored
4
dist/core-recommendedapps.js
vendored
File diff suppressed because one or more lines are too long
8
dist/core-recommendedapps.js.license
vendored
8
dist/core-recommendedapps.js.license
vendored
|
|
@ -16,12 +16,14 @@ SPDX-FileCopyrightText: Matt Zabriskie
|
|||
SPDX-FileCopyrightText: Joyent
|
||||
SPDX-FileCopyrightText: Jordan Harband <ljharb@gmail.com>
|
||||
SPDX-FileCopyrightText: Jordan Harband
|
||||
SPDX-FileCopyrightText: John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)
|
||||
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
|
||||
SPDX-FileCopyrightText: GitHub Inc.
|
||||
SPDX-FileCopyrightText: Feross Aboukhadijeh
|
||||
SPDX-FileCopyrightText: Evan You
|
||||
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <mario@cure53.de> (https://cure53.de/)
|
||||
SPDX-FileCopyrightText: Christoph Wurst
|
||||
SPDX-FileCopyrightText: Andris Reinman
|
||||
|
||||
|
||||
This file is generated from multiple sources. Included packages:
|
||||
|
|
@ -139,6 +141,12 @@ This file is generated from multiple sources. Included packages:
|
|||
- is-typed-array
|
||||
- version: 1.1.13
|
||||
- license: MIT
|
||||
- lodash.get
|
||||
- version: 4.4.2
|
||||
- license: MIT
|
||||
- node-gettext
|
||||
- version: 3.0.0
|
||||
- license: MIT
|
||||
- buffer
|
||||
- version: 6.0.3
|
||||
- license: MIT
|
||||
|
|
|
|||
2
dist/core-recommendedapps.js.map
vendored
2
dist/core-recommendedapps.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue