add envrionment bindings to automations

This commit is contained in:
Peter Clement 2023-01-26 14:59:29 +00:00
parent 4eaefa677a
commit 843649eb54
2 changed files with 24 additions and 2 deletions

View File

@ -92,7 +92,7 @@ export const getAuthBindings = () => {
export const getEnvironmentBindings = () => { export const getEnvironmentBindings = () => {
let envVars = get(environment).variables let envVars = get(environment).variables
let test = envVars.map(variable => { return envVars.map(variable => {
return { return {
type: "context", type: "context",
runtimeBinding: `env.${makePropSafe(variable.name)}`, runtimeBinding: `env.${makePropSafe(variable.name)}`,
@ -102,7 +102,6 @@ export const getEnvironmentBindings = () => {
display: { type: "string", name: variable.name }, display: { type: "string", name: variable.name },
} }
}) })
return test
} }
/** /**

View File

@ -18,6 +18,7 @@
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import { tables } from "stores/backend" import { tables } from "stores/backend"
import { environment } from "stores/portal"
import WebhookDisplay from "../Shared/WebhookDisplay.svelte" import WebhookDisplay from "../Shared/WebhookDisplay.svelte"
import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte" import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte"
import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte" import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte"
@ -33,6 +34,7 @@
import { Utils } from "@budibase/frontend-core" import { Utils } from "@budibase/frontend-core"
import { TriggerStepID, ActionStepID } from "constants/backend/automations" import { TriggerStepID, ActionStepID } from "constants/backend/automations"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import { onMount } from "svelte"
export let block export let block
export let testData export let testData
@ -166,6 +168,23 @@
) )
} }
// Environment bindings
bindings = bindings.concat(
$environment.variables.map(variable => {
return {
label: `env.${variable.name}`,
path: `env.${variable.name}`,
type: "test",
icon: "Key",
category: "Environment",
display: {
type: "string",
name: variable.name,
},
}
})
)
return bindings return bindings
} }
@ -196,6 +215,10 @@
onChange({ detail: tempFilters }, defKey) onChange({ detail: tempFilters }, defKey)
drawer.hide() drawer.hide()
} }
onMount(async () => {
await environment.loadVariables()
})
</script> </script>
<div class="fields"> <div class="fields">