1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-30 23:30:02 +00:00

Fix protected field validation of data sync forms

This commit is contained in:
Bram Wiepjes 2025-03-03 12:27:41 +00:00
parent 774cd7efb1
commit 7747ec6fd4
7 changed files with 53 additions and 54 deletions
web-frontend/modules/database/components/dataSync

View file

@ -118,7 +118,13 @@ export default {
}
},
async submitted(values) {
await this.update(this.table, values, this.syncTableValue)
// Remove the `undefined` values, because those contain not updated secrets that
// are only meant to be included in the update request if they've changed
// because they're not exposed by the backend.
const valuesWithoutUndefined = Object.fromEntries(
Object.entries(values).filter(([_, v]) => v !== undefined)
)
await this.update(this.table, valuesWithoutUndefined, this.syncTableValue)
if (!this.syncTableValue) {
this.completed = true
}

View file

@ -35,13 +35,8 @@
small-label
:protected-edit="update && field.protectedEdit"
class="margin-bottom-2"
@enabled-protected-edit="allowedValues.push(field.name)"
@disable-protected-edit="
;[
allowedValues.splice(allowedValues.indexOf(field.name), 1),
delete values[field.name],
]
"
@enabled-protected-edit="values.postgresql_password = ''"
@disable-protected-edit="values.postgresql_password = undefined"
>
<template #label>{{
$t(`postgreSQLDataSync.${field.translationPrefix}`)
@ -129,13 +124,11 @@ export default {
'postgresql_username',
'postgresql_port',
'postgresql_database',
'postgresql_password',
'postgresql_schema',
'postgresql_table',
'postgresql_sslmode',
]
if (!this.update) {
allowedValues.push('postgresql_password')
}
return {
allowedValues,
values: {
@ -143,6 +136,9 @@ export default {
postgresql_username: '',
postgresql_port: '5432',
postgresql_database: '',
// If `undefined`, it's not included in the patch update request, and will then
// not be changed.
postgresql_password: this.update ? undefined : '',
postgresql_schema: 'public',
postgresql_table: '',
postgresql_sslmode: 'prefer',
@ -176,7 +172,7 @@ export default {
required: helpers.withMessage(
this.$t('error.requiredField'),
requiredIf(() => {
return this.allowedValues.includes('postgresql_password')
return this.values.postgresql_password !== undefined
})
),
},