Merge branch 'rename-workflow-automation' of github.com:Budibase/budibase into async-workflow-blocks
This commit is contained in:
commit
406032b444
|
@ -16,7 +16,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [10.x]
|
||||
node-version: [12.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
|
|
@ -15,7 +15,7 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
node-version: [10.x]
|
||||
node-version: [12.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
// Ensure any nullish modelId values get set to empty string so
|
||||
// that the select works
|
||||
$: if (value?.modelId == null) value = { modelId: "" }
|
||||
|
||||
function schemaHasOptions(schema) {
|
||||
return !!schema.constraints?.inclusion?.length
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="block-field">
|
||||
|
@ -27,18 +31,15 @@
|
|||
<div class="bb-margin-xl block-field">
|
||||
{#each schemaFields as [field, schema]}
|
||||
<div class="bb-margin-xl capitalise">
|
||||
{#if schema.constraints?.inclusion?.length}
|
||||
{#if schemaHasOptions(schema)}
|
||||
<div class="field-label">{field}</div>
|
||||
<Select
|
||||
thin
|
||||
secondary
|
||||
bind:value={value[field]}>
|
||||
<Select thin secondary bind:value={value[field]}>
|
||||
<option value="">Choose an option</option>
|
||||
{#each schema.constraints.inclusion as option}
|
||||
<option value={option}>{option}</option>
|
||||
{/each}
|
||||
</Select>
|
||||
{:else if schema.type === "string" || schema.type === "number"}
|
||||
{:else if schema.type === 'string' || schema.type === 'number'}
|
||||
<BindableInput
|
||||
thin
|
||||
bind:value={value[field]}
|
||||
|
@ -61,7 +62,8 @@
|
|||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.capitalise :global(label), .field-label {
|
||||
.capitalise :global(label),
|
||||
.field-label {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -13,6 +13,7 @@ const {
|
|||
|
||||
const { delay } = require("./testUtils")
|
||||
|
||||
const MAX_RETRIES = 4
|
||||
const TEST_AUTOMATION = {
|
||||
_id: "Test Automation",
|
||||
name: "My Automation",
|
||||
|
@ -168,11 +169,18 @@ describe("/automations", () => {
|
|||
expect(res.body.message).toEqual(`Automation ${automation._id} has been triggered.`)
|
||||
expect(res.body.automation.name).toEqual(TEST_AUTOMATION.name)
|
||||
// wait for automation to complete in background
|
||||
await delay(500)
|
||||
for (let tries = 0; tries < MAX_RETRIES; tries++) {
|
||||
let elements = await getAllFromModel(request, app._id, instance._id, model._id)
|
||||
// don't test it unless there are values to test
|
||||
if (elements.length === 1) {
|
||||
expect(elements.length).toEqual(1)
|
||||
expect(elements[0].name).toEqual("Test")
|
||||
expect(elements[0].description).toEqual("TEST")
|
||||
return
|
||||
}
|
||||
await delay(500)
|
||||
}
|
||||
throw "Failed to find the records"
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -10,11 +10,14 @@ function cleanMustache(string) {
|
|||
"]": "",
|
||||
}
|
||||
let regex = new RegExp(/{{[^}}]*}}/g)
|
||||
let match
|
||||
while ((match = regex.exec(string)) !== null) {
|
||||
let matches = string.match(regex)
|
||||
if (matches == null) {
|
||||
return string
|
||||
}
|
||||
for (let match of matches) {
|
||||
let baseIdx = string.indexOf(match)
|
||||
for (let key of Object.keys(charToReplace)) {
|
||||
let idxChar = match[0].indexOf(key)
|
||||
let idxChar = match.indexOf(key)
|
||||
if (idxChar !== -1) {
|
||||
string =
|
||||
string.slice(baseIdx, baseIdx + idxChar) +
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
function validate(schema, property) {
|
||||
// Return a Koa middleware function
|
||||
return (ctx, next) => {
|
||||
if (schema) {
|
||||
let params =
|
||||
ctx[property] != null
|
||||
? ctx[property]
|
||||
: ctx.request[property] != null
|
||||
? ctx.request[property]
|
||||
: null
|
||||
if (!schema) {
|
||||
return next()
|
||||
}
|
||||
let params = null
|
||||
if (ctx[property] != null) {
|
||||
params = ctx[property]
|
||||
} else if (ctx.request[property] != null) {
|
||||
params = ctx.request[property]
|
||||
}
|
||||
const { error } = schema.validate(params)
|
||||
if (error) {
|
||||
ctx.throw(400, `Invalid ${property} - ${error.message}`)
|
||||
return
|
||||
}
|
||||
}
|
||||
return next()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue