Merge branch 'master' into update-eslint
This commit is contained in:
commit
1076e26a36
|
@ -46,7 +46,7 @@
|
|||
}
|
||||
} else {
|
||||
// Leave the core data as it is
|
||||
return testData
|
||||
return cloneDeep(testData)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,10 @@
|
|||
return true
|
||||
}
|
||||
|
||||
$: testData = testData || parseTestData($selectedAutomation.data.testData)
|
||||
$: currentTestData = $selectedAutomation.data.testData
|
||||
|
||||
// Can be updated locally to avoid race condition when testing
|
||||
$: testData = parseTestData(currentTestData)
|
||||
|
||||
$: {
|
||||
// clone the trigger so we're not mutating the reference
|
||||
|
@ -85,7 +88,7 @@
|
|||
required => testData?.[required] || required !== "row"
|
||||
)
|
||||
|
||||
function parseTestJSON(e) {
|
||||
async function parseTestJSON(e) {
|
||||
let jsonUpdate
|
||||
|
||||
try {
|
||||
|
@ -105,7 +108,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
const updatedAuto =
|
||||
automationStore.actions.addTestDataToAutomation(jsonUpdate)
|
||||
await automationStore.actions.save(updatedAuto)
|
||||
}
|
||||
|
||||
const testAutomation = async () => {
|
||||
|
@ -150,10 +155,14 @@
|
|||
{#if selectedValues}
|
||||
<div class="tab-content-padding">
|
||||
<AutomationBlockSetup
|
||||
bind:testData
|
||||
{schemaProperties}
|
||||
isTestModal
|
||||
{testData}
|
||||
block={trigger}
|
||||
on:update={e => {
|
||||
const { testData: updatedTestData } = e.detail
|
||||
testData = updatedTestData
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
@ -162,7 +171,7 @@
|
|||
<TextArea
|
||||
value={JSON.stringify($selectedAutomation.data.testData, null, 2)}
|
||||
error={failedParse}
|
||||
on:change={e => parseTestJSON(e)}
|
||||
on:change={async e => await parseTestJSON(e)}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
import { QueryUtils, Utils, search, memo } from "@budibase/frontend-core"
|
||||
import { getSchemaForDatasourcePlus } from "dataBinding"
|
||||
import { TriggerStepID, ActionStepID } from "constants/backend/automations"
|
||||
import { onMount } from "svelte"
|
||||
import { onMount, createEventDispatcher } from "svelte"
|
||||
import { writable } from "svelte/store"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import {
|
||||
|
@ -67,6 +67,8 @@
|
|||
export let isTestModal = false
|
||||
export let bindings = []
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
// Stop unnecessary rendering
|
||||
const memoBlock = memo(block)
|
||||
|
||||
|
@ -503,15 +505,7 @@
|
|||
row: { "Active": true, "Order Id" : 14, ... }
|
||||
})
|
||||
*/
|
||||
const onChange = async update => {
|
||||
if (isTestModal) {
|
||||
testData = update
|
||||
}
|
||||
|
||||
updateAutomation(update)
|
||||
}
|
||||
|
||||
const updateAutomation = Utils.sequential(async update => {
|
||||
const onChange = Utils.sequential(async update => {
|
||||
const request = cloneDeep(update)
|
||||
// Process app trigger updates
|
||||
if (isTrigger && !isTestModal) {
|
||||
|
@ -540,7 +534,9 @@
|
|||
}
|
||||
try {
|
||||
if (isTestModal) {
|
||||
let newTestData = { schema }
|
||||
// Be sure to merge in the testData prop data, as it can contain custom
|
||||
// default data
|
||||
let newTestData = { schema, ...testData }
|
||||
|
||||
// Special case for webhook, as it requires a body, but the schema already brings back the body's contents
|
||||
if (stepId === TriggerStepID.WEBHOOK) {
|
||||
|
@ -557,7 +553,13 @@
|
|||
...request,
|
||||
}
|
||||
|
||||
await automationStore.actions.addTestDataToAutomation(newTestData)
|
||||
const updatedAuto =
|
||||
automationStore.actions.addTestDataToAutomation(newTestData)
|
||||
|
||||
// Ensure the test request has the latest info.
|
||||
dispatch("update", updatedAuto)
|
||||
|
||||
await automationStore.actions.save(updatedAuto)
|
||||
} else {
|
||||
const data = { schema, ...request }
|
||||
await automationStore.actions.updateBlockInputs(block, data)
|
||||
|
|
|
@ -880,13 +880,13 @@ const automationActions = store => ({
|
|||
appId,
|
||||
})
|
||||
},
|
||||
addTestDataToAutomation: async data => {
|
||||
addTestDataToAutomation: data => {
|
||||
let newAutomation = cloneDeep(get(selectedAutomation).data)
|
||||
newAutomation.testData = {
|
||||
...newAutomation.testData,
|
||||
...data,
|
||||
}
|
||||
await store.actions.save(newAutomation)
|
||||
return newAutomation
|
||||
},
|
||||
constructBlock(type, stepId, blockDefinition) {
|
||||
let newName
|
||||
|
|
Loading…
Reference in New Issue