From 47d71a6022bb67328ad3ffbdc404a32697d29241 Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sat, 10 Apr 2021 14:16:47 +0200
Subject: [PATCH 1/7] add warning modal if last ws message is a warning
---
app/src/store/info.js | 11 +++++-
app/src/views/_partials/ViewLockOverlay.vue | 23 ++++++++---
app/src/views/_partials/WarningDisplay.vue | 43 +++++++++++++++++++++
app/src/views/_partials/index.js | 1 +
4 files changed, 72 insertions(+), 6 deletions(-)
create mode 100644 app/src/views/_partials/WarningDisplay.vue
diff --git a/app/src/store/info.js b/app/src/store/info.js
index 92f1fd2c..89d1a603 100644
--- a/app/src/store/info.js
+++ b/app/src/store/info.js
@@ -145,11 +145,15 @@ export default {
'END_REQUEST' ({ commit }, { request, success, wait }) {
let status = success ? 'success' : 'error'
if (success && (request.warnings || request.errors)) {
+ const messages = request.messages
+ if (messages.length && messages[messages.length - 1].color === 'warning') {
+ request.showWarningMessage = true
+ }
status = 'warning'
}
commit('UPDATE_REQUEST', { request, key: 'status', value: status })
- if (wait) {
+ if (wait && !request.showWarningMessage) {
// Remove the overlay after a short delay to allow an error to display withtout flickering.
setTimeout(() => {
commit('SET_WAITING', false)
@@ -214,6 +218,11 @@ export default {
}
}
commit('SET_ERROR', null)
+ },
+
+ 'DISMISS_WARNING' ({ commit, state }, request) {
+ commit('SET_WAITING', false)
+ delete request.showWarningMessage
}
},
diff --git a/app/src/views/_partials/ViewLockOverlay.vue b/app/src/views/_partials/ViewLockOverlay.vue
index 3c5fcdeb..a4f61faf 100644
--- a/app/src/views/_partials/ViewLockOverlay.vue
+++ b/app/src/views/_partials/ViewLockOverlay.vue
@@ -12,8 +12,7 @@
-
-
+
@@ -21,7 +20,7 @@
diff --git a/app/src/views/_partials/index.js b/app/src/views/_partials/index.js
index 950eecca..dfcda23a 100644
--- a/app/src/views/_partials/index.js
+++ b/app/src/views/_partials/index.js
@@ -1,4 +1,5 @@
export { default as ErrorDisplay } from './ErrorDisplay'
+export { default as WarningDisplay } from './WarningDisplay'
export { default as WaitingDisplay } from './WaitingDisplay'
export { default as HistoryConsole } from './HistoryConsole'
From a7bf1964de65f3495d03a3bda4b0fae2e7f6bd1e Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sat, 10 Apr 2021 14:45:40 +0200
Subject: [PATCH 2/7] replace backslash n with
---
app/src/api/handlers.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/src/api/handlers.js b/app/src/api/handlers.js
index 123797da..259e5d2d 100644
--- a/app/src/api/handlers.js
+++ b/app/src/api/handlers.js
@@ -59,7 +59,7 @@ export async function handleError (request, response, errorData) {
let errorCode = response.status in errors ? response.status : undefined
if (typeof errorData === 'string') {
// FIXME API: Patching errors that are plain text or html.
- errorData = { error: errorData }
+ errorData = { error: errorData.replace('\n', '
') }
}
if ('log_ref' in errorData) {
// Define a special error so it won't get caught as a `APIBadRequestError`.
From 4cc61594799235376ad9c738058ae90fe7b40945 Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sat, 10 Apr 2021 17:33:47 +0200
Subject: [PATCH 3/7] add ability to not query /installed in login component
---
app/src/views/Login.vue | 7 ++++++-
app/src/views/PostInstall.vue | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/app/src/views/Login.vue b/app/src/views/Login.vue
index 63d61815..190447d6 100644
--- a/app/src/views/Login.vue
+++ b/app/src/views/Login.vue
@@ -32,9 +32,13 @@
export default {
name: 'Login',
+ props: {
+ skipInstallCheck: { type: Boolean, default: false }
+ },
+
data () {
return {
- disabled: true,
+ disabled: !this.skipInstallCheck,
password: '',
isValid: null,
apiError: undefined
@@ -51,6 +55,7 @@ export default {
},
created () {
+ if (this.skipInstallCheck) return
this.$store.dispatch('CHECK_INSTALL').then(installed => {
if (installed) {
this.disabled = false
diff --git a/app/src/views/PostInstall.vue b/app/src/views/PostInstall.vue
index 8edcae6a..4682e30a 100644
--- a/app/src/views/PostInstall.vue
+++ b/app/src/views/PostInstall.vue
@@ -48,7 +48,7 @@
{{ $t('installation_complete') }}
-
+
From 146c51502cf4fbcdadb5aba5c1f16387fdbf87ca Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sat, 10 Apr 2021 17:34:32 +0200
Subject: [PATCH 4/7] removed unused prop in DomainForm
---
app/src/views/_partials/DomainForm.vue | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/app/src/views/_partials/DomainForm.vue b/app/src/views/_partials/DomainForm.vue
index 9586928a..b7a6dfe6 100644
--- a/app/src/views/_partials/DomainForm.vue
+++ b/app/src/views/_partials/DomainForm.vue
@@ -61,9 +61,7 @@ export default {
props: {
title: { type: String, required: true },
submitText: { type: String, default: null },
- serverError: { type: String, default: '' },
- // Do not query the api (used by postinstall)
- noStore: { type: Boolean, default: false }
+ serverError: { type: String, default: '' }
},
data () {
From 1a1da4c0d0e2de536e86bc037b01945ade2b0034 Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sat, 10 Apr 2021 17:39:20 +0200
Subject: [PATCH 5/7] handle validation errors & --force-diskspace
---
app/src/api/errors.js | 1 +
app/src/components/globals/CardForm.vue | 5 ++-
app/src/i18n/locales/en.json | 3 ++
app/src/views/PostInstall.vue | 58 ++++++++++++++++++++-----
4 files changed, 56 insertions(+), 11 deletions(-)
diff --git a/app/src/api/errors.js b/app/src/api/errors.js
index cbca7c12..f120ac02 100644
--- a/app/src/api/errors.js
+++ b/app/src/api/errors.js
@@ -47,6 +47,7 @@ class APIBadRequestError extends APIError {
constructor (method, response, errorData) {
super(method, response, errorData)
this.name = 'APIBadRequestError'
+ this.key = errorData.error_key
}
}
diff --git a/app/src/components/globals/CardForm.vue b/app/src/components/globals/CardForm.vue
index 1867f4bd..8debb8a3 100644
--- a/app/src/components/globals/CardForm.vue
+++ b/app/src/components/globals/CardForm.vue
@@ -10,7 +10,10 @@
-
+
diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json
index 71f20d8a..4e192826 100644
--- a/app/src/i18n/locales/en.json
+++ b/app/src/i18n/locales/en.json
@@ -314,6 +314,9 @@
"permission_show_tile_enabled": "Visible as tile in user portal",
"port": "Port",
"ports": "Ports",
+ "postinstall": {
+ "force": "Force the post-install"
+ },
"postinstall_domain": "This is the first domain name linked to your YunoHost server, but also the one which will be used by your server's users to access the authentication portal. Accordingly, it will be visible by everyone, so choose it carefully.",
"postinstall_intro_1": "Congratulations! YunoHost has been successfully installed.",
"postinstall_intro_2": "Two more configuration steps are required to activate you server's services.",
diff --git a/app/src/views/PostInstall.vue b/app/src/views/PostInstall.vue
index 4682e30a..4a55c906 100644
--- a/app/src/views/PostInstall.vue
+++ b/app/src/views/PostInstall.vue
@@ -12,37 +12,57 @@
-
+
{{ $t('begin') }}
-
+
-
+
{{ $t('previous') }}
-
+
-
+
{{ $t('previous') }}
+
+
+
+ {{ serverError }}
+
+
+
+
+ {{ $t('postinstall.force') }}
+
+
+
+
+
@@ -71,14 +91,20 @@ export default {
return {
step: 'start',
domain: undefined,
- password: undefined
+ password: undefined,
+ serverError: ''
}
},
methods: {
+ goToStep (step) {
+ this.serverError = ''
+ this.step = step
+ },
+
setDomain ({ domain }) {
this.domain = domain
- this.step = 'password'
+ this.goToStep('password')
},
async setPassword ({ password }) {
@@ -90,11 +116,23 @@ export default {
this.performPostInstall()
},
- performPostInstall () {
+ performPostInstall (force = false) {
// FIXME does the api will throw an error for bad passwords ?
- api.post('postinstall', { domain: this.domain, password: this.password }).then(data => {
+ api.post('postinstall' + (force ? '?force_diskspace' : ''), { domain: this.domain, password: this.password }).then(data => {
// Display success message and allow the user to login
- this.step = 'login'
+ this.goToStep('login')
+ }).catch(err => {
+ if (err.name !== 'APIBadRequestError') throw err
+ if (err.key === 'postinstall_low_rootfsspace') {
+ this.step = 'rootfsspace-error'
+ } else if (err.key.includes('password')) {
+ this.step = 'password'
+ } else if (['domain', 'dyndns'].some(word => err.key.includes(word))) {
+ this.step = 'domain'
+ } else {
+ throw err
+ }
+ this.serverError = err.message
})
}
},
From 40ef5b2d7ee22f32465c02a4c21b81cc6ac1f089 Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sun, 11 Apr 2021 14:39:41 +0200
Subject: [PATCH 6/7] try to format the error just before ApiError creation
---
app/src/api/errors.js | 4 ++--
app/src/api/handlers.js | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/src/api/errors.js b/app/src/api/errors.js
index cbca7c12..999aa2ca 100644
--- a/app/src/api/errors.js
+++ b/app/src/api/errors.js
@@ -7,8 +7,8 @@ import i18n from '@/i18n'
class APIError extends Error {
- constructor (request, { url, status, statusText }, errorData) {
- super(errorData.error || i18n.t('error_server_unexpected'))
+ constructor (request, { url, status, statusText }, { error }) {
+ super(error ? error.replace('\n', '
') : i18n.t('error_server_unexpected'))
const urlObj = new URL(url)
this.name = 'APIError'
this.code = status
diff --git a/app/src/api/handlers.js b/app/src/api/handlers.js
index 259e5d2d..123797da 100644
--- a/app/src/api/handlers.js
+++ b/app/src/api/handlers.js
@@ -59,7 +59,7 @@ export async function handleError (request, response, errorData) {
let errorCode = response.status in errors ? response.status : undefined
if (typeof errorData === 'string') {
// FIXME API: Patching errors that are plain text or html.
- errorData = { error: errorData.replace('\n', '
') }
+ errorData = { error: errorData }
}
if ('log_ref' in errorData) {
// Define a special error so it won't get caught as a `APIBadRequestError`.
From 0acbbf8550e25d76a4bed064b2ce42173fd0a28b Mon Sep 17 00:00:00 2001
From: axolotle
Date: Sun, 11 Apr 2021 14:40:14 +0200
Subject: [PATCH 7/7] fix wrong args for /migration/run
---
app/src/views/tool/ToolMigrations.vue | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/src/views/tool/ToolMigrations.vue b/app/src/views/tool/ToolMigrations.vue
index 400b3627..823490dc 100644
--- a/app/src/views/tool/ToolMigrations.vue
+++ b/app/src/views/tool/ToolMigrations.vue
@@ -121,7 +121,7 @@ export default {
}
// Check that every migration's disclaimer has been checked.
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()
})
}
@@ -131,7 +131,7 @@ export default {
const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_migrations_skip'))
if (!confirmed) return
- api.post('/migrations/run', { skip: true, targets: id }).then(() => {
+ api.post('/migrations/run', { skip: '', targets: id }).then(() => {
this.$refs.view.fetchQueries()
})
}