Skip to content

Commit f7ed66c

Browse files
authored
Merge pull request #104 from nextcloud/fix/status-modal
Fetch status before opening modal
2 parents 5ad9f18 + 2206810 commit f7ed66c

14 files changed

+68
-46
lines changed

js/user_migration-admin-settings.js

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

js/user_migration-admin-settings.js.LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @author Christopher Ng <chrng8@gmail.com>
1818
*
19-
* @license GNU AGPL version 3 or any later version
19+
* @license AGPL-3.0-or-later
2020
*
2121
* This program is free software: you can redistribute it and/or modify
2222
* it under the terms of the GNU Affero General Public License as

js/user_migration-admin-settings.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.

js/user_migration-personal-settings.js

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

js/user_migration-personal-settings.js.LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @author Christopher Ng <chrng8@gmail.com>
3030
*
31-
* @license GNU AGPL version 3 or any later version
31+
* @license AGPL-3.0-or-later
3232
*
3333
* This program is free software: you can redistribute it and/or modify
3434
* it under the terms of the GNU Affero General Public License as

js/user_migration-personal-settings.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.

src/admin-settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* @author Christopher Ng <chrng8@gmail.com>
55
*
6-
* @license GNU AGPL version 3 or any later version
6+
* @license AGPL-3.0-or-later
77
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as

src/components/ExportSection.vue

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-
44
- @author Christopher Ng <chrng8@gmail.com>
55
-
6-
- @license GNU AGPL version 3 or any later version
6+
- @license AGPL-3.0-or-later
77
-
88
- This program is free software: you can redistribute it and/or modify
99
- it under the terms of the GNU Affero General Public License as
@@ -49,16 +49,19 @@
4949
</div>
5050
</div>
5151

52-
<Button v-if="status.current !== 'export'"
53-
type="secondary"
54-
:aria-label="t('user_migration', 'Export your data')"
55-
:disabled="status.current === 'import'"
56-
@click.stop.prevent="startExport">
57-
<template #icon>
58-
<PackageDown title="" :size="20" />
59-
</template>
60-
{{ t('user_migration', 'Export') }}
61-
</Button>
52+
<div v-if="status.current !== 'export'"
53+
class="section__status">
54+
<Button type="secondary"
55+
:aria-label="t('user_migration', 'Export your data')"
56+
:disabled="status.current === 'import'"
57+
@click.stop.prevent="startExport">
58+
<template #icon>
59+
<PackageDown title="" :size="20" />
60+
</template>
61+
{{ t('user_migration', 'Export') }}
62+
</Button>
63+
<div v-if="startingExport" class="icon-loading" />
64+
</div>
6265
<div v-else class="section__status">
6366
<Button type="secondary"
6467
:aria-label="t('user_migration', 'Show export status')"
@@ -133,6 +136,7 @@ export default {
133136
data() {
134137
return {
135138
modalOpened: false,
139+
startingExport: false,
136140
selectedMigrators: [],
137141
}
138142
},
@@ -157,12 +161,16 @@ export default {
157161
async startExport() {
158162
try {
159163
await confirmPassword()
164+
this.startingExport = true
160165
await axios.post(generateOcsUrl('/apps/{appId}/api/v1/export', { appId: APP_ID }), {
161166
migrators: this.selectedMigrators,
162167
})
163-
this.$emit('refresh-status')
164-
this.openModal()
168+
this.$emit('refresh-status', () => {
169+
this.openModal()
170+
this.startingExport = false
171+
})
165172
} catch (error) {
173+
this.startingExport = false
166174
const errorMessage = error.message || 'Unknown error'
167175
this.logger.error(`Error starting user export: ${errorMessage}`, { error })
168176
showError(errorMessage)

src/components/ImportSection.vue

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-
44
- @author Christopher Ng <chrng8@gmail.com>
55
-
6-
- @license GNU AGPL version 3 or any later version
6+
- @license AGPL-3.0-or-later
77
-
88
- This program is free software: you can redistribute it and/or modify
99
- it under the terms of the GNU Affero General Public License as
@@ -30,16 +30,19 @@
3030

3131
<!-- TODO use server API -->
3232

33-
<Button v-if="status.current !== 'import'"
34-
type="secondary"
35-
:aria-label="t('user_migration', 'Import your data')"
36-
:disabled="status.current === 'export'"
37-
@click.stop.prevent="pickImportFile">
38-
<template #icon>
39-
<PackageUp title="" :size="20" />
40-
</template>
41-
{{ t('user_migration', 'Import') }}
42-
</Button>
33+
<div v-if="status.current !== 'import'"
34+
class="section__status">
35+
<Button type="secondary"
36+
:aria-label="t('user_migration', 'Import your data')"
37+
:disabled="status.current === 'export'"
38+
@click.stop.prevent="pickImportFile">
39+
<template #icon>
40+
<PackageUp title="" :size="20" />
41+
</template>
42+
{{ t('user_migration', 'Import') }}
43+
</Button>
44+
<div v-if="startingImport" class="icon-loading" />
45+
</div>
4346
<div v-else class="section__status">
4447
<Button type="secondary"
4548
:aria-label="t('user_migration', 'Show import status')"
@@ -76,6 +79,7 @@
7679
</template>
7780

7881
<script>
82+
import confirmPassword from '@nextcloud/password-confirmation'
7983
import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
8084
8185
import Button from '@nextcloud/vue/dist/Components/Button'
@@ -114,6 +118,7 @@ export default {
114118
data() {
115119
return {
116120
modalOpened: false,
121+
startingImport: false,
117122
filePickerError: null,
118123
}
119124
},
@@ -139,11 +144,17 @@ export default {
139144
if (!filePath.startsWith('/')) {
140145
throw new Error()
141146
}
147+
142148
try {
149+
await confirmPassword()
150+
this.startingImport = true
143151
// TODO call API to start background job
144-
this.$emit('refresh-status')
145-
this.openModal()
152+
this.$emit('refresh-status', () => {
153+
this.openModal()
154+
this.startingImport = false
155+
})
146156
} catch (error) {
157+
this.startingImport = false
147158
const errorMessage = error.message || 'Unknown error'
148159
this.logger.error(`Error starting user import: ${errorMessage}`, { error })
149160
showError(errorMessage)

src/logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* @author Christopher Ng <chrng8@gmail.com>
55
*
6-
* @license GNU AGPL version 3 or any later version
6+
* @license AGPL-3.0-or-later
77
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as

0 commit comments

Comments
 (0)