UI: Make import more accessible

This commit is contained in:
Marcel Klehr 2020-04-17 13:22:00 +02:00
parent dffdb6c0e0
commit 1187e8d2b3
3 changed files with 23 additions and 5 deletions

2
package-lock.json generated
View File

@ -7316,7 +7316,7 @@
"private": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz",
"integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg=="
"integrity": "sha1-I4Hts2ifelPWUxkAYPz4ItLzaP8="
},
"process": {
"version": "0.11.10",

View File

@ -5,7 +5,7 @@
size="5"
@change="onImportSubmit">
<button @click="onImportOpen">
<span class="icon-upload" />{{ t('bookmarks', 'Import') }}
<span :class="{'icon-upload': !importing, 'icon-loading-small': importing}" />{{ t('bookmarks', 'Import') }}
</button>
<button @click="onExport">
<span class="icon-download" /> {{ t('bookmarks', 'Export') }}
@ -89,6 +89,11 @@ import { getRequestToken } from '@nextcloud/auth'
export default {
name: 'Settings',
components: {},
data() {
return {
importing: false,
}
},
computed: {
oc_defaults() {
return window.oc_defaults
@ -123,8 +128,14 @@ export default {
onImportOpen(e) {
e.target.previousElementSibling.click()
},
onImportSubmit(e) {
this.$store.dispatch(actions.IMPORT_BOOKMARKS, e.target.files[0])
async onImportSubmit(e) {
this.importing = true
try {
await this.$store.dispatch(actions.IMPORT_BOOKMARKS, e.target.files[0])
this.$router.push({ name: this.routes.HOME })
} finally {
this.importing = false
}
},
onExport() {
window.location
@ -153,7 +164,7 @@ export default {
return
}
await this.$store.dispatch(actions.DELETE_BOOKMARKS)
this.$router.push({ name: this.routes.HOME })
await this.$router.push({ name: this.routes.HOME })
},
},
}

View File

@ -247,6 +247,11 @@ export default {
console.error('Failed to import bookmarks', response)
throw new Error(response.data)
}
commit(mutations.SET_NOTIFICATION, AppGlobal.methods.t('bookmarks', 'Import successful'))
dispatch(actions.COUNT_BOOKMARKS, -1)
dispatch(actions.FILTER_BY_FOLDER, '-1')
dispatch(actions.LOAD_TAGS)
return dispatch(actions.LOAD_FOLDERS)
})
.catch(err => {
console.error(err)
@ -268,6 +273,8 @@ export default {
throw new Error(response.data)
}
dispatch(actions.COUNT_BOOKMARKS, -1)
dispatch(actions.FILTER_BY_FOLDER, '-1')
dispatch(actions.LOAD_TAGS)
return dispatch(actions.LOAD_FOLDERS)
})
.catch(err => {