Merge pull request #350 from YunoHost/fix-migration-and-error-text

Fix migration and error text
This commit is contained in:
Alexandre Aubin 2021-04-11 15:11:29 +02:00 committed by GitHub
commit f1855f4cf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -7,8 +7,8 @@ import i18n from '@/i18n'
class APIError extends Error { class APIError extends Error {
constructor (request, { url, status, statusText }, errorData) { constructor (request, { url, status, statusText }, { error }) {
super(errorData.error || i18n.t('error_server_unexpected')) super(error ? error.replace('\n', '<br>') : i18n.t('error_server_unexpected'))
const urlObj = new URL(url) const urlObj = new URL(url)
this.name = 'APIError' this.name = 'APIError'
this.code = status this.code = status

View file

@ -59,7 +59,7 @@ export async function handleError (request, response, errorData) {
let errorCode = response.status in errors ? response.status : undefined let errorCode = response.status in errors ? response.status : undefined
if (typeof errorData === 'string') { if (typeof errorData === 'string') {
// FIXME API: Patching errors that are plain text or html. // FIXME API: Patching errors that are plain text or html.
errorData = { error: errorData.replace('\n', '<br>') } errorData = { error: errorData }
} }
if ('log_ref' in errorData) { if ('log_ref' in errorData) {
// Define a special error so it won't get caught as a `APIBadRequestError`. // Define a special error so it won't get caught as a `APIBadRequestError`.

View file

@ -121,7 +121,7 @@ export default {
} }
// Check that every migration's disclaimer has been checked. // Check that every migration's disclaimer has been checked.
if (Object.values(this.checked).every(value => value === true)) { if (Object.values(this.checked).every(value => value === true)) {
api.post('migrations/run', { accept_disclaimer: true }).then(() => { api.post('migrations/run?accept_disclaimer').then(() => {
this.$refs.view.fetchQueries() this.$refs.view.fetchQueries()
}) })
} }
@ -131,7 +131,7 @@ export default {
const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_migrations_skip')) const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_migrations_skip'))
if (!confirmed) return if (!confirmed) return
api.post('/migrations/run', { skip: true, targets: id }).then(() => { api.post('/migrations/run', { skip: '', targets: id }).then(() => {
this.$refs.view.fetchQueries() this.$refs.view.fetchQueries()
}) })
} }