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