Skip to content

Commit

Permalink
File picker filter by export extension
Browse files Browse the repository at this point in the history
The file picker now only display files with the extension
".nextcloud_export"

Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Apr 14, 2022
1 parent b7c6481 commit 3bd621a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 2 additions & 2 deletions js/user_migration-personal-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/user_migration-personal-settings.js.map

Large diffs are not rendered by default.

29 changes: 27 additions & 2 deletions src/components/ImportSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@

<script>
import confirmPassword from '@nextcloud/password-confirmation'
import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
// import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
import { showError } from '@nextcloud/dialogs'
import Button from '@nextcloud/vue/dist/Components/Button'
import CheckCircleOutline from 'vue-material-design-icons/CheckCircleOutline'
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import Modal from '@nextcloud/vue/dist/Components/Modal'
import PackageUp from 'vue-material-design-icons/PackageUp'
/*
const picker = getFilePickerBuilder(t('user_migration', 'Choose a file to import'))
.setMultiSelect(false)
// TODO add custom mime type for user_migration files?
Expand All @@ -106,6 +108,7 @@ const picker = getFilePickerBuilder(t('user_migration', 'Choose a file to import
.setType(1)
.allowDirectories(false)
.build()
*/
export default {
name: 'ImportSection',
Expand Down Expand Up @@ -153,7 +156,29 @@ export default {
this.filePickerError = null
try {
const filePath = await picker.pick()
// TODO: bring this back once nextcloud-dialogs is updated to support the filter function
// const filePath = await picker.pick()
const filePath = await new Promise((resolve, reject) => {
OC.dialogs.filepicker(
t('user_migration', 'Choose a file to import'),
resolve,
false,
null,
true,
1,
null,
{
allowDirectoryChooser: this.directoriesAllowed,
filter: entry => {
if (entry.mimetype === 'httpd/unix-directory') {
return true
}
return entry.name.endsWith('.nextcloud_export')
},
}
)
})
this.logger.debug(`Path "${filePath}" selected for import`)
if (!filePath.startsWith('/')) {
throw new Error()
Expand Down

0 comments on commit 3bd621a

Please sign in to comment.