1
0
Fork 0
mirror of synced 2024-08-06 13:48:14 +12:00

PR comments

This commit is contained in:
Adria Navarro 2024-05-29 15:50:10 +02:00
parent 05544d3082
commit 2d5ecb6e3e
2 changed files with 27 additions and 27 deletions

View file

@ -386,7 +386,8 @@ describe.each([
await config.api.viewV2.create(newView, {
status: 400,
body: {
message: 'Field "name" cannot be readonly and not visible',
message:
'Field "name" must be visible if you want to make it readonly',
status: 400,
},
})
@ -686,7 +687,7 @@ describe.each([
})
mocks.licenses.useCloudFree()
await config.api.viewV2.create(view, {
await config.api.viewV2.update(view, {
status: 400,
body: {
message: "Readonly fields are not enabled for your tenant",

View file

@ -43,37 +43,36 @@ async function guardViewSchema(
return
}
const table = await sdk.tables.getTable(tableId)
if (viewSchema) {
for (const field of Object.keys(viewSchema)) {
const tableSchemaField = table.schema[field]
if (!tableSchemaField) {
for (const field of Object.keys(viewSchema)) {
const tableSchemaField = table.schema[field]
if (!tableSchemaField) {
throw new HTTPError(
`Field "${field}" is not valid for the requested table`,
400
)
}
if (viewSchema[field].readonly) {
if (!(await features.isViewReadonlyColumnsEnabled())) {
throw new HTTPError(
`Field "${field}" is not valid for the requested table`,
`Readonly fields are not enabled for your tenant`,
400
)
}
if (viewSchema[field].readonly) {
if (!(await features.isViewReadonlyColumnsEnabled())) {
throw new HTTPError(
`Readonly fields are not enabled for your tenant`,
400
)
}
if (isRequired(tableSchemaField.constraints)) {
throw new HTTPError(
`Field "${field}" cannot be readonly as it is a required field`,
400
)
}
if (isRequired(tableSchemaField.constraints)) {
throw new HTTPError(
`Field "${field}" cannot be readonly as it is a required field`,
400
)
}
if (!viewSchema[field].visible) {
throw new HTTPError(
`Field "${field}" cannot be readonly and not visible`,
400
)
}
if (!viewSchema[field].visible) {
throw new HTTPError(
`Field "${field}" must be visible if you want to make it readonly`,
400
)
}
}
}