fix(migration): handle file errors in frontend

This commit is contained in:
kolaente 2025-01-09 14:51:55 +01:00
parent 3d5d17336e
commit 304de78c48
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
2 changed files with 13 additions and 2 deletions

View File

@ -1203,7 +1203,8 @@
"12001": "The subscription entity type is invalid.",
"12002": "You are already subscribed to the entity itself or a parent entity.",
"13001": "This link share requires a password for authentication, but none was provided.",
"13002": "The provided link share password was invalid."
"13002": "The provided link share password was invalid.",
"14001": "The provided file is not a valid zip file."
},
"about": {
"title": "About",

View File

@ -7,6 +7,13 @@
<template v-if="isMigrating === false">
<template v-if="migrator.isFileMigrator">
<p>{{ $t('migrate.importUpload', {name: migrator.name}) }}</p>
<Message
v-if="migrationError"
variant="danger"
class="mb-4"
>
{{ migrationError }}
</Message>
<input
ref="uploadInput"
class="is-hidden"
@ -129,6 +136,7 @@ import {parseDateOrNull} from '@/helpers/parseDateOrNull'
import {MIGRATORS, type Migrator} from './migrators'
import {useTitle} from '@/composables/useTitle'
import {useProjectStore} from '@/stores/projects'
import {getErrorText} from '@/message'
const props = defineProps<{
service: string,
@ -147,6 +155,7 @@ const lastMigrationStartedAt = ref<Date | null>(null)
const message = ref('')
const migratorAuthCode = ref('')
const migrationJustStarted = ref(false)
const migrationError = ref('')
const migrator = computed<Migrator>(() => MIGRATORS[props.service])
@ -198,6 +207,7 @@ async function migrate() {
isMigrating.value = true
lastMigrationFinishedAt.value = null
message.value = ''
migrationError.value = ''
let migrationConfig: MigrationConfig | File = {code: migratorAuthCode.value}
@ -219,7 +229,7 @@ async function migrate() {
await migrationService.migrate(migrationConfig as MigrationConfig)
migrationJustStarted.value = true
} catch (e) {
console.log(e)
migrationError.value = getErrorText(e)
} finally {
isMigrating.value = false
}