Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute Script V2 - UX #15461

Open
wants to merge 27 commits into
base: execute-script-v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0463462
v2 JavaScript UX, automation bug fixes and general refactoring
deanhannigan Jan 29, 2025
31053ca
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Jan 29, 2025
9ce885c
Fixed import
deanhannigan Jan 29, 2025
cb21024
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Jan 30, 2025
722fef2
Fix for automation panel icons
deanhannigan Jan 30, 2025
9f856d1
Add table to test data endpoint for row actions
deanhannigan Jan 30, 2025
ee5d194
Lint and tidying
deanhannigan Jan 30, 2025
7580957
Removing more dead code
deanhannigan Jan 30, 2025
655b809
Lint
deanhannigan Jan 30, 2025
352516a
Fix to ensure an empty string if no default value is set inthe CodeEd…
deanhannigan Jan 30, 2025
942ba78
Ensure empty values default to an empty string when null
deanhannigan Jan 30, 2025
7f5d4e4
Remove debugging text
deanhannigan Jan 30, 2025
1fd7685
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Jan 30, 2025
7583864
Test fixes
deanhannigan Jan 30, 2025
420bd39
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Jan 30, 2025
7a0d9ae
Refactor to ensure automation context isn't initialised before it is …
deanhannigan Jan 30, 2025
163fe86
Clean up comments
deanhannigan Jan 30, 2025
4f810f2
Fixed code editor placeholder to the js copy
deanhannigan Jan 30, 2025
182101a
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Jan 30, 2025
895f5b3
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Jan 31, 2025
ef2a2b8
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Jan 31, 2025
a280039
Refactor the binding generation to ensure types are processed correct…
deanhannigan Feb 3, 2025
f1fb9a8
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Feb 3, 2025
564fc5f
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Feb 4, 2025
eb510e9
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Feb 6, 2025
8b04a56
Merge remote-tracking branch 'origin/execute-script-v2' into execute-…
deanhannigan Feb 7, 2025
50fe275
Return AutomationResults type from test function
deanhannigan Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
import AutomationBindingPanel from "@/components/common/bindings/ServerBindingPanel.svelte"
import FlowItemHeader from "./FlowItemHeader.svelte"
import FlowItemActions from "./FlowItemActions.svelte"
import { automationStore, selectedAutomation } from "@/stores/builder"
import { QueryUtils, Utils } from "@budibase/frontend-core"
import {
automationStore,
selectedAutomation,
evaluationContext,
} from "@/stores/builder"
import { QueryUtils, Utils, memo } from "@budibase/frontend-core"
import { cloneDeep } from "lodash/fp"
import { createEventDispatcher, getContext } from "svelte"
import DragZone from "./DragZone.svelte"
Expand All @@ -34,11 +38,14 @@
export let automation

const view = getContext("draggableView")
const memoContext = memo({})

let drawer
let open = true
let confirmDeleteModal

$: memoContext.set($evaluationContext)

$: branch = step.inputs?.branches?.[branchIdx]
$: editableConditionUI = branch.conditionUI || {}

Expand Down Expand Up @@ -100,6 +107,7 @@
allowOnEmpty={false}
builderType={"condition"}
docsURL={null}
evaluationContext={$memoContext}
/>
</DrawerContent>
</Drawer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
})

$: groupedAutomations = groupAutomations(filteredAutomations)

$: showNoResults = searchString && !filteredAutomations.length

const groupAutomations = automations => {
Expand All @@ -41,7 +40,6 @@
for (let auto of automations) {
let category = null
let dataTrigger = false

// Group by datasource if possible
if (dsTriggers.includes(auto.definition?.trigger?.stepId)) {
if (auto.definition.trigger.inputs?.tableId) {
Expand Down Expand Up @@ -97,7 +95,10 @@
{triggerGroup?.name}
</div>
{#each triggerGroup.entries as automation}
<AutomationNavItem {automation} icon={triggerGroup.icon} />
<AutomationNavItem
{automation}
icon={automation?.definition?.trigger?.icon}
/>
{/each}
</div>
{/each}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
} from "@budibase/bbui"

import CreateWebhookModal from "@/components/automation/Shared/CreateWebhookModal.svelte"
import { automationStore, tables } from "@/stores/builder"
import { automationStore, tables, evaluationContext } from "@/stores/builder"
import { environment } from "@/stores/portal"
import WebhookDisplay from "../Shared/WebhookDisplay.svelte"
import {
Expand Down Expand Up @@ -62,6 +62,8 @@
} from "@budibase/types"
import PropField from "./PropField.svelte"
import { utils } from "@budibase/shared-core"
import { encodeJSBinding } from "@budibase/string-templates"
import CodeEditorField from "@/components/common/bindings/CodeEditorField.svelte"

export let automation
export let block
Expand All @@ -74,6 +76,7 @@

// Stop unnecessary rendering
const memoBlock = memo(block)
const memoContext = memo({})

const rowTriggers = [
TriggerStepID.ROW_UPDATED,
Expand All @@ -97,6 +100,7 @@
let stepLayouts = {}

$: memoBlock.set(block)
$: memoContext.set($evaluationContext)

$: filters = lookForFilters(schemaProperties)
$: filterCount =
Expand Down Expand Up @@ -140,6 +144,7 @@
? [hbAutocomplete([...bindingsToCompletions(bindings, codeMode)])]
: []

// TODO: check if it inputData != newInputData (memo)
const getInputData = (testData, blockInputs) => {
// Test data is not cloned for reactivity
let newInputData = testData || cloneDeep(blockInputs)
Expand All @@ -156,6 +161,7 @@
}

const setDefaultEnumValues = () => {
// TODO: Update this for memoisation
for (const [key, value] of schemaProperties) {
if (value.type === "string" && value.enum && inputData[key] == null) {
inputData[key] = value.enum[0]
Expand Down Expand Up @@ -200,7 +206,6 @@
onChange({ ["revision"]: e.detail })
},
updateOnChange: false,
forceModal: true,
},
},
]
Expand Down Expand Up @@ -228,7 +233,6 @@
onChange({ [rowIdentifier]: e.detail })
},
updateOnChange: false,
forceModal: true,
},
},
]
Expand Down Expand Up @@ -476,6 +480,10 @@
...update,
})

if (!updatedAutomation) {
return
}

// Exclude default or invalid data from the test data
let updatedFields = {}
for (const key of Object.keys(block?.inputs?.fields || {})) {
Expand Down Expand Up @@ -547,7 +555,7 @@
...newTestData,
body: {
...update,
...automation.testData?.body,
...(automation?.testData?.body || {}),
},
}
}
Expand Down Expand Up @@ -668,6 +676,7 @@
{...config.props}
{bindings}
on:change={config.props.onChange}
context={$memoContext}
/>
</PropField>
{:else}
Expand All @@ -676,6 +685,7 @@
{...config.props}
{bindings}
on:change={config.props.onChange}
context={$memoContext}
/>
{/if}
{/each}
Expand Down Expand Up @@ -800,6 +810,7 @@
: "Add signature"}
keyPlaceholder={"URL"}
valuePlaceholder={"Filename"}
context={$memoContext}
/>
{:else if isTestModal}
<ModalBindableInput
Expand All @@ -824,6 +835,7 @@
? queryLimit
: ""}
drawerLeft="260px"
context={$memoContext}
/>
{/if}
</div>
Expand Down Expand Up @@ -853,6 +865,7 @@
panel={AutomationBindingPanel}
showFilterEmptyDropdown={!rowTriggers.includes(stepId)}
on:change={e => (tempFilters = e.detail)}
evaluationContext={$memoContext}
/>
</DrawerContent>
</Drawer>
Expand Down Expand Up @@ -895,7 +908,37 @@
on:change={e => onChange({ [key]: e.detail })}
value={inputData[key]}
/>
{:else if value.customType === "code"}
{:else if value.customType === "code" && stepId === ActionStepID.EXECUTE_SCRIPT_V2}
<div class="scriptv2-wrapper">
<DrawerBindableSlot
title={"Edit Code"}
panel={AutomationBindingPanel}
type={"longform"}
{schema}
on:change={e => onChange({ [key]: e.detail })}
value={inputData[key]}
{bindings}
allowJS={true}
allowHBS={false}
updateOnChange={false}
context={$memoContext}
>
<div class="field-wrap code-editor">
<CodeEditorField
value={inputData[key]}
{bindings}
context={$memoContext}
allowHBS={false}
allowJS
placeholder={"Add bindings by typing $"}
on:blur={e =>
onChange({ [key]: encodeJSBinding(e.detail) })}
/>
</div>
</DrawerBindableSlot>
</div>
{:else if value.customType === "code" && stepId === ActionStepID.EXECUTE_SCRIPT}
<!-- DEPRECATED -->
<CodeEditorModal
on:hide={() => {
// Push any pending changes when the window closes
Expand Down Expand Up @@ -977,6 +1020,7 @@
? queryLimit
: ""}
drawerLeft="260px"
context={$memoContext}
/>
</div>
{/if}
Expand Down Expand Up @@ -1044,4 +1088,23 @@
flex: 3;
margin-top: calc((var(--spacing-xl) * -1) + 1px);
}

.field-wrap :global(.cm-editor),
.field-wrap :global(.cm-scroller) {
border-radius: 4px;
}
.field-wrap {
box-sizing: border-box;
border: 1px solid var(--spectrum-global-color-gray-400);
border-radius: 4px;
}
.field-wrap.code-editor {
height: 180px;
}
.scriptv2-wrapper :global(.icon.slot-icon) {
top: 1px;
border-bottom-left-radius: var(--spectrum-alias-border-radius-regular);
border-right: 0px;
border-bottom: 1px solid var(--spectrum-alias-border-color);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
export let meta
export let bindings
export let isTestModal
export let context = {}

const typeToField = Object.values(FIELDS).reduce((acc, field) => {
acc[field.type] = field
Expand Down Expand Up @@ -58,7 +59,7 @@

$: parsedBindings = bindings.map(binding => {
let clone = Object.assign({}, binding)
clone.icon = "ShareAndroid"
clone.icon = clone.icon ?? "ShareAndroid"
return clone
})

Expand Down Expand Up @@ -258,6 +259,7 @@
fields: editableFields,
}}
{onChange}
{context}
/>
{:else}
<DrawerBindableSlot
Expand All @@ -276,6 +278,7 @@
allowJS={true}
updateOnChange={false}
drawerLeft="260px"
{context}
>
<RowSelectorTypes
{isTestModal}
Expand All @@ -286,6 +289,7 @@
meta={{
fields: editableFields,
}}
{context}
onChange={change => onChange(change)}
/>
</DrawerBindableSlot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
export let meta
export let bindings
export let isTestModal
export let context

$: fieldData = value[field]

$: parsedBindings = bindings.map(binding => {
let clone = Object.assign({}, binding)
clone.icon = "ShareAndroid"
clone.icon = clone.icon ?? "ShareAndroid"
return clone
})

Expand Down Expand Up @@ -232,6 +233,7 @@
actionButtonDisabled={(schema.type === FieldType.ATTACHMENT_SINGLE ||
schema.type === FieldType.SIGNATURE_SINGLE) &&
fieldData}
{context}
/>
</div>
{:else}
Expand Down
Loading
Loading