Add settings and user bindings to drawer

This commit is contained in:
Peter Clement 2024-10-28 21:12:33 +00:00
parent c3bf7ed9b6
commit 931ebde3f7
3 changed files with 88 additions and 3 deletions

View File

@ -36,9 +36,16 @@
$: environmentBindings = $: environmentBindings =
automationStore.actions.buildEnvironmentBindings($memoEnvVariables) automationStore.actions.buildEnvironmentBindings($memoEnvVariables)
// Combine all bindings for the step $: userBindings = automationStore.actions.buildUserBindings()
$: bindings = [...availableBindings, ...environmentBindings] $: settingBindings = automationStore.actions.buildSettingBindings()
// Combine all bindings for the step
$: bindings = [
...availableBindings,
...environmentBindings,
...userBindings,
...settingBindings,
]
onMount(() => { onMount(() => {
// Register the trigger as the focus element for the automation // Register the trigger as the focus element for the automation
// Onload, the canvas will use the dimensions to center the step // Onload, the canvas will use the dimensions to center the step

View File

@ -614,6 +614,43 @@ const getDeviceBindings = () => {
return bindings return bindings
} }
/**
* Gets all device bindings that are globally available.
*/
export const getSettingBindings = () => {
let bindings = []
const safeSetting = makePropSafe("settings")
bindings = [
{
type: "context",
runtimeBinding: `${safeSetting}.${makePropSafe("url")}`,
readableBinding: `Settings.url`,
category: "Settings",
icon: "Settings",
display: { type: "string", name: "url" },
},
{
type: "context",
runtimeBinding: `${safeSetting}.${makePropSafe("logo")}`,
readableBinding: `Settings.logo`,
category: "Settings",
icon: "Settings",
display: { type: "string", name: "logo" },
},
{
type: "context",
runtimeBinding: `${safeSetting}.${makePropSafe("company")}`,
readableBinding: `Settings.company`,
category: "Settings",
icon: "Settings",
display: { type: "string", name: "company" },
},
]
return bindings
}
/** /**
* Gets all selected rows bindings for tables in the current asset. * Gets all selected rows bindings for tables in the current asset.
* TODO: remove in future because we don't need a separate store for this * TODO: remove in future because we don't need a separate store for this

View File

@ -6,7 +6,12 @@ import { createHistoryStore } from "stores/builder/history"
import { licensing } from "stores/portal" import { licensing } from "stores/portal"
import { tables } from "stores/builder" import { tables } from "stores/builder"
import { notifications } from "@budibase/bbui" import { notifications } from "@budibase/bbui"
import { getEnvironmentBindings, migrateReferencesInObject } from "dataBinding" import {
getEnvironmentBindings,
migrateReferencesInObject,
getUserBindings,
getSettingBindings,
} from "dataBinding"
import { import {
AutomationTriggerStepId, AutomationTriggerStepId,
AutomationEventType, AutomationEventType,
@ -334,6 +339,42 @@ const automationActions = store => ({
} }
return [] return []
}, },
/**
* Get user bindings
*
* @returns {Array<Object>} all available user bindings
*/
buildUserBindings: () => {
return getUserBindings().map(binding => {
return {
...binding,
category: "User",
display: {
...binding.display,
rank: 98,
},
}
})
},
/**
* Get user bindings
*
* @returns {Array<Object>} all available user bindings
*/
buildSettingBindings: () => {
return getSettingBindings().map(binding => {
return {
...binding,
display: {
...binding.display,
rank: 98,
},
}
})
},
/** /**
* Take the supplied step id and aggregate all bindings for every * Take the supplied step id and aggregate all bindings for every
* step preceding it. * step preceding it.