|
62 | 62 | import axios from '@nextcloud/axios' |
63 | 63 | import { loadState } from '@nextcloud/initial-state' |
64 | 64 | import { t } from '@nextcloud/l10n' |
| 65 | +import { PwdConfirmationMode } from '@nextcloud/password-confirmation' |
65 | 66 | import { generateUrl, imagePath } from '@nextcloud/router' |
66 | | -import pLimit from 'p-limit' |
67 | 67 | import NcButton from '@nextcloud/vue/components/NcButton' |
68 | 68 | import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch' |
69 | 69 | import logger from '../../logger.js' |
@@ -147,35 +147,41 @@ export default { |
147 | 147 | }, |
148 | 148 |
|
149 | 149 | methods: { |
150 | | - installApps() { |
151 | | - this.installingApps = true |
152 | | -
|
153 | | - const limit = pLimit(1) |
154 | | - const installing = this.recommendedApps |
| 150 | + async installApps() { |
| 151 | + const apps = this.recommendedApps |
155 | 152 | .filter((app) => !app.active && app.isCompatible && app.canInstall && app.isSelected) |
156 | | - .map((app) => limit(async () => { |
157 | | - logger.info(`installing ${app.id}`) |
158 | | - app.loading = true |
159 | | - return axios.post(generateUrl('settings/apps/enable'), { appIds: [app.id], groups: [] }) |
160 | | - .catch((error) => { |
161 | | - logger.error(`could not install ${app.id}`, { error }) |
162 | | - app.isSelected = false |
163 | | - app.installationError = true |
164 | | - }) |
165 | | - .then(() => { |
166 | | - logger.info(`installed ${app.id}`) |
167 | | - app.loading = false |
168 | | - app.active = true |
169 | | - }) |
170 | | - })) |
171 | | - logger.debug(`installing ${installing.length} recommended apps`) |
172 | | - Promise.all(installing) |
173 | | - .then(() => { |
174 | | - logger.info('all recommended apps installed, redirecting …') |
175 | | -
|
176 | | - window.location = this.defaultPageUrl |
| 153 | + if (apps.length === 0) { |
| 154 | + return |
| 155 | + } |
| 156 | +
|
| 157 | + this.installingApps = true |
| 158 | + apps.forEach((app) => { |
| 159 | + app.loading = true |
| 160 | + }) |
| 161 | + const appIds = apps.map((app) => app.id) |
| 162 | + logger.debug(`installing ${apps.length} recommended apps`, { appIds }) |
| 163 | +
|
| 164 | + try { |
| 165 | + await axios.post( |
| 166 | + generateUrl('settings/apps/enable'), |
| 167 | + { appIds, groups: [] }, |
| 168 | + { confirmPassword: PwdConfirmationMode.Strict }, |
| 169 | + ) |
| 170 | + apps.forEach((app) => { |
| 171 | + app.loading = false |
| 172 | + app.active = true |
177 | 173 | }) |
178 | | - .catch((error) => logger.error('could not install recommended apps', { error })) |
| 174 | + logger.info('all recommended apps installed, redirecting …') |
| 175 | + window.location = this.defaultPageUrl |
| 176 | + } catch (error) { |
| 177 | + logger.error('could not install recommended apps', { error }) |
| 178 | + apps.forEach((app) => { |
| 179 | + app.loading = false |
| 180 | + app.isSelected = false |
| 181 | + app.installationError = true |
| 182 | + }) |
| 183 | + this.installingApps = false |
| 184 | + } |
179 | 185 | }, |
180 | 186 |
|
181 | 187 | customIcon(appId) { |
|
0 commit comments