Merge pull request #1799 from Budibase/fix/june-mike

Various release fixes
This commit is contained in:
Michael Drury 2021-06-22 17:24:09 +01:00 committed by GitHub
commit f503de3025
8 changed files with 1049 additions and 20 deletions

View File

@ -16,7 +16,7 @@
"cy:open": "cypress open", "cy:open": "cypress open",
"cy:run:ci": "cypress run --record --key f308590b-6070-41af-b970-794a3823d451", "cy:run:ci": "cypress run --record --key f308590b-6070-41af-b970-794a3823d451",
"cy:test": "start-server-and-test cy:setup http://localhost:10001/builder cy:run", "cy:test": "start-server-and-test cy:setup http://localhost:10001/builder cy:run",
"cy:ci": "start-server-and-test cy:setup http://localhost:10001/builder cy:run:ci", "cy:ci": "start-server-and-test cy:setup http://localhost:10001/builder cy:run",
"cy:debug": "start-server-and-test cy:setup http://localhost:10001/builder cy:open" "cy:debug": "start-server-and-test cy:setup http://localhost:10001/builder cy:open"
}, },
"jest": { "jest": {

View File

@ -14,6 +14,10 @@ const apiCall =
}) })
if (resp.status === 403) { if (resp.status === 403) {
removeCookie(Cookies.Auth) removeCookie(Cookies.Auth)
// reload after removing cookie, go to login
if (!url.includes("self")) {
location.reload()
}
} }
return resp return resp
} }

View File

@ -72,10 +72,7 @@
field.subtype !== AUTO_COLUMN_SUB_TYPES.CREATED_BY && field.subtype !== AUTO_COLUMN_SUB_TYPES.CREATED_BY &&
field.subtype !== AUTO_COLUMN_SUB_TYPES.UPDATED_BY && field.subtype !== AUTO_COLUMN_SUB_TYPES.UPDATED_BY &&
field.type !== FORMULA_TYPE field.type !== FORMULA_TYPE
$: canBeDisplay = $: canBeDisplay = field.type !== LINK_TYPE && field.type !== AUTO_TYPE
field.type !== LINK_TYPE &&
field.type !== AUTO_TYPE &&
field.type !== FORMULA_TYPE
$: canBeRequired = $: canBeRequired =
field.type !== LINK_TYPE && !uneditable && field.type !== AUTO_TYPE field.type !== LINK_TYPE && !uneditable && field.type !== AUTO_TYPE
$: relationshipOptions = getRelationshipOptions(field) $: relationshipOptions = getRelationshipOptions(field)

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,10 @@ const makeApiCall = async ({ method, url, body, json = true }) => {
case 400: case 400:
return handleError(`${url}: Bad Request`) return handleError(`${url}: Bad Request`)
case 403: case 403:
notificationStore.danger("Forbidden") // reload the page incase the token has expired
if (!url.includes("self")) {
location.reload()
}
return handleError(`${url}: Forbidden`) return handleError(`${url}: Forbidden`)
default: default:
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {

View File

@ -14,6 +14,7 @@ const { FieldTypes } = require("../../constants")
const { getMultiIDParams, USER_METDATA_PREFIX } = require("../../db/utils") const { getMultiIDParams, USER_METDATA_PREFIX } = require("../../db/utils")
const { partition } = require("lodash") const { partition } = require("lodash")
const { getGlobalUsers } = require("../../utilities/global") const { getGlobalUsers } = require("../../utilities/global")
const processor = require("../../utilities/rowProcessor")
/** /**
* This functionality makes sure that when rows with links are created, updated or deleted they are processed * This functionality makes sure that when rows with links are created, updated or deleted they are processed
@ -201,7 +202,9 @@ exports.attachFullLinkedDocs = async (appId, table, rows) => {
if (!linkedRow || !linkedTable) { if (!linkedRow || !linkedTable) {
continue continue
} }
row[link.fieldName].push(linkedRow) row[link.fieldName].push(
processor.processFormulas(linkedTable, linkedRow)
)
} }
} }
return rows return rows

View File

@ -4,13 +4,35 @@ const { FieldTypes } = require("../constants")
const VALIDATORS = { const VALIDATORS = {
[FieldTypes.STRING]: () => true, [FieldTypes.STRING]: () => true,
[FieldTypes.OPTIONS]: () => true, [FieldTypes.OPTIONS]: () => true,
[FieldTypes.NUMBER]: attribute => !isNaN(Number(attribute)), [FieldTypes.NUMBER]: attribute => {
[FieldTypes.DATETIME]: attribute => !isNaN(new Date(attribute).getTime()), // allow not to be present
if (!attribute) {
return true
}
return !isNaN(Number(attribute))
},
[FieldTypes.DATETIME]: attribute => {
// allow not to be present
if (!attribute) {
return true
}
return !isNaN(new Date(attribute).getTime())
},
} }
const PARSERS = { const PARSERS = {
[FieldTypes.NUMBER]: attribute => Number(attribute), [FieldTypes.NUMBER]: attribute => {
[FieldTypes.DATETIME]: attribute => new Date(attribute).toISOString(), if (!attribute) {
return attribute
}
return Number(attribute)
},
[FieldTypes.DATETIME]: attribute => {
if (!attribute) {
return attribute
}
return new Date(attribute).toISOString()
},
} }
function parse(csvString, parsers) { function parse(csvString, parsers) {

View File

@ -127,6 +127,10 @@ function processAutoColumn(user, table, row) {
* Looks through the rows provided and finds formulas - which it then processes. * Looks through the rows provided and finds formulas - which it then processes.
*/ */
function processFormulas(table, rows) { function processFormulas(table, rows) {
const single = !Array.isArray(rows)
if (single) {
rows = [rows]
}
for (let [column, schema] of Object.entries(table.schema)) { for (let [column, schema] of Object.entries(table.schema)) {
if (schema.type !== FieldTypes.FORMULA) { if (schema.type !== FieldTypes.FORMULA) {
continue continue
@ -137,8 +141,9 @@ function processFormulas(table, rows) {
[column]: processStringSync(schema.formula, row), [column]: processStringSync(schema.formula, row),
})) }))
} }
return rows return single ? rows[0] : rows
} }
exports.processFormulas = processFormulas
/** /**
* This will coerce a value to the correct types based on the type transform map * This will coerce a value to the correct types based on the type transform map