Skip to content

Commit 02d8eab

Browse files
committed
Improve installation pages
Signed-off-by: Christopher Ng <[email protected]> (cherry picked from commit 2276876)
1 parent 49a8a8f commit 02d8eab

File tree

5 files changed

+93
-48
lines changed

5 files changed

+93
-48
lines changed

core/Controller/SetupController.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function run($post) {
7878
$options = array_merge($opts, $post, $errors);
7979
$this->display($options);
8080
} else {
81-
$this->finishSetup(isset($post['install-recommended-apps']));
81+
$this->finishSetup();
8282
}
8383
} else {
8484
$options = array_merge($opts, $post);
@@ -106,7 +106,7 @@ public function display($post) {
106106
\OC_Template::printGuestPage('', 'installation', $parameters);
107107
}
108108

109-
private function finishSetup(bool $installRecommended) {
109+
private function finishSetup() {
110110
if (file_exists($this->autoConfigFile)) {
111111
unlink($this->autoConfigFile);
112112
}
@@ -118,13 +118,8 @@ private function finishSetup(bool $installRecommended) {
118118
}
119119
}
120120

121-
if ($installRecommended) {
122-
header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
123-
exit();
124-
} else {
125-
header('Location: ' . \OC::$server->getURLGenerator()->linkToDefaultPageUrl());
126-
exit();
127-
}
121+
header('Location: ' . \OC::$server->getURLGenerator()->getAbsoluteURL('index.php/core/apps/recommended'));
122+
exit();
128123
}
129124

130125
public function loadAutoConfig($post) {

core/css/guest.css

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -667,18 +667,14 @@ form #selectDbType label span {
667667
margin: 5px 0 !important;
668668
}
669669

670-
#install-recommended-apps + label span {
671-
display: inline-block;
672-
opacity: .7;
673-
}
674-
675670
/* Errors */
676671
/* Warnings and errors are the same */
677672
.body-login-container,
678673
.warning,
679674
.update,
680675
.error {
681-
display: block;
676+
display: flex;
677+
flex-direction: column;
682678
margin-top: 15px;
683679
padding: 15px;
684680
background-color: rgba(0,0,0,.3);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!--
2+
- @copyright 2022 Christopher Ng <[email protected]>
3+
-
4+
- @author Christopher Ng <[email protected]>
5+
-
6+
- @license GNU AGPL version 3 or any later version
7+
-
8+
- This program is free software: you can redistribute it and/or modify
9+
- it under the terms of the GNU Affero General Public License as
10+
- published by the Free Software Foundation, either version 3 of the
11+
- License, or (at your option) any later version.
12+
-
13+
- This program is distributed in the hope that it will be useful,
14+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
- GNU Affero General Public License for more details.
17+
-
18+
- You should have received a copy of the GNU Affero General Public License
19+
- along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
-
21+
-->
22+
23+
<template>
24+
<button
25+
class="primary"
26+
:autofocus="true"
27+
v-on="$listeners">
28+
{{ t('core', 'Install recommended apps') }}
29+
</button>
30+
</template>
31+
32+
<script>
33+
export default {
34+
name: 'InstallButton',
35+
}
36+
</script>
37+
38+
<style lang="scss" scoped>
39+
button {
40+
margin: 24px auto 10px auto;
41+
padding: 10px 20px;
42+
font-size: 20px;
43+
}
44+
</style>

core/src/components/setup/RecommendedApps.vue

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
<p v-else-if="loadingAppsError" class="loading-error text-center">
2929
{{ t('core', 'Could not fetch list of apps from the App Store.') }}
3030
</p>
31-
<p v-else class="text-center">
31+
<p v-else-if="installingApps" class="text-center">
3232
{{ t('core', 'Installing apps …') }}
3333
</p>
34+
3435
<div v-for="app in recommendedApps" :key="app.id" class="app">
3536
<img :src="customIcon(app.id)" alt="">
3637
<div class="info">
@@ -51,6 +52,10 @@
5152
</p>
5253
</div>
5354
</div>
55+
56+
<InstallButton v-if="showInstallButton"
57+
@click.stop.prevent="installApps" />
58+
5459
<p class="text-center">
5560
<a :href="defaultPageUrl">{{ t('core', 'Cancel') }}</a>
5661
</p>
@@ -64,6 +69,9 @@ import { loadState } from '@nextcloud/initial-state'
6469
import pLimit from 'p-limit'
6570
import { translate as t } from '@nextcloud/l10n'
6671
72+
// TODO replace with Button component when @nextcloud/vue is upgraded to v5
73+
import InstallButton from './InstallButton'
74+
6775
import logger from '../../logger'
6876
6977
const recommended = {
@@ -97,8 +105,13 @@ const defaultPageUrl = loadState('core', 'defaultPageUrl')
97105
98106
export default {
99107
name: 'RecommendedApps',
108+
components: {
109+
InstallButton,
110+
},
100111
data() {
101112
return {
113+
showInstallButton: false,
114+
installingApps: false,
102115
loadingApps: true,
103116
loadingAppsError: false,
104117
apps: [],
@@ -110,28 +123,28 @@ export default {
110123
return this.apps.filter(app => recommendedIds.includes(app.id))
111124
},
112125
},
113-
mounted() {
114-
return axios.get(generateUrl('settings/apps/list'))
115-
.then(resp => resp.data)
116-
.then(data => {
117-
logger.info(`${data.apps.length} apps fetched`)
118-
119-
this.apps = data.apps.map(app => Object.assign(app, { loading: false, installationError: false }))
120-
logger.debug(`${this.recommendedApps.length} recommended apps found`, { apps: this.recommendedApps })
121-
122-
this.installApps()
123-
})
124-
.catch(error => {
125-
logger.error('could not fetch app list', { error })
126-
127-
this.loadingAppsError = true
128-
})
129-
.then(() => {
130-
this.loadingApps = false
131-
})
126+
async mounted() {
127+
try {
128+
const { data } = await axios.get(generateUrl('settings/apps/list'))
129+
logger.info(`${data.apps.length} apps fetched`)
130+
131+
this.apps = data.apps.map(app => Object.assign(app, { loading: false, installationError: false }))
132+
logger.debug(`${this.recommendedApps.length} recommended apps found`, { apps: this.recommendedApps })
133+
134+
this.showInstallButton = true
135+
} catch (error) {
136+
logger.error('could not fetch app list', { error })
137+
138+
this.loadingAppsError = true
139+
} finally {
140+
this.loadingApps = false
141+
}
132142
},
133143
methods: {
134144
installApps() {
145+
this.showInstallButton = false
146+
this.installingApps = true
147+
135148
const limit = pLimit(1)
136149
const installing = this.recommendedApps
137150
.filter(app => !app.active && app.isCompatible && app.canInstall)
@@ -180,8 +193,15 @@ export default {
180193
181194
}
182195
183-
p.loading, p.loading-error {
184-
height: 100px;
196+
p {
197+
&.loading,
198+
&.loading-error {
199+
height: 100px;
200+
}
201+
202+
&:last-child {
203+
margin-top: 10px;
204+
}
185205
}
186206
187207
.text-center {

core/templates/installation.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,9 @@
159159
</fieldset>
160160
<?php endif ?>
161161

162-
<fieldset>
163-
<p class="info">
164-
<input type="checkbox" id="install-recommended-apps" name="install-recommended-apps" class="checkbox checkbox--white" checked>
165-
<label for="install-recommended-apps">
166-
<?php p($l->t('Install recommended apps')); ?>
167-
<span><?php p($l->t('Calendar, Contacts, Talk, Mail & Collaborative editing')); ?></span>
168-
</label>
169-
</p>
170-
</fieldset>
171-
172162
<div class="icon-loading-dark float-spinner">&nbsp;</div>
173163

174-
<div class="buttons"><input type="submit" class="primary" value="<?php p($l->t('Finish setup')); ?>" data-finishing="<?php p($l->t('Finishing')); ?>"></div>
164+
<div class="buttons"><input type="submit" class="primary" value="<?php p($l->t('Install')); ?>" data-finishing="<?php p($l->t('Installing')); ?>"></div>
175165

176166
<p class="info">
177167
<span class="icon-info-white"></span>

0 commit comments

Comments
 (0)