Merge branch 'contextual-workflows' of github.com:Budibase/budibase into rename-workflow-automation

This commit is contained in:
mike12345567 2020-09-22 12:00:54 +01:00
commit 1845a8c452
7 changed files with 44 additions and 29 deletions

View File

@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
node-version: [10.x]
node-version: [12.x]
steps:
- uses: actions/checkout@v2

View File

@ -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

View File

@ -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>

View File

@ -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)
let elements = await getAllFromModel(request, app._id, instance._id, model._id)
expect(elements.length).toEqual(1)
expect(elements[0].name).toEqual("Test")
expect(elements[0].description).toEqual("TEST")
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"
})
})

View File

@ -25,6 +25,7 @@ module.exports.init = function() {
if (environment.BUDIBASE_ENVIRONMENT === "PRODUCTION") {
await runWorker(job)
} else {
console.log("Testing standard thread")
await singleThread(job)
}
})

View File

@ -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) +

View File

@ -1,18 +1,19 @@
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
const { error } = schema.validate(params)
if (error) {
ctx.throw(400, `Invalid ${property} - ${error.message}`)
return
}
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()
}