Skip to content

Commit

Permalink
Merge pull request #14892 from Budibase/feat/add-new-bindings-to-drawer
Browse files Browse the repository at this point in the history
Add new bindings to drawer
  • Loading branch information
PClmnt authored Oct 29, 2024
2 parents 392dc08 + b999741 commit 3ad1cf5
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@
$: environmentBindings =
automationStore.actions.buildEnvironmentBindings($memoEnvVariables)
// Combine all bindings for the step
$: bindings = [...availableBindings, ...environmentBindings]
$: userBindings = automationStore.actions.buildUserBindings()
$: settingBindings = automationStore.actions.buildSettingBindings()
// Combine all bindings for the step
$: bindings = [
...availableBindings,
...environmentBindings,
...userBindings,
...settingBindings,
]
onMount(() => {
// Register the trigger as the focus element for the automation
// Onload, the canvas will use the dimensions to center the step
Expand Down
34 changes: 34 additions & 0 deletions packages/builder/src/dataBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,40 @@ const getDeviceBindings = () => {
return bindings
}

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.
* TODO: remove in future because we don't need a separate store for this
Expand Down
43 changes: 42 additions & 1 deletion packages/builder/src/stores/builder/automations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { createHistoryStore } from "stores/builder/history"
import { licensing } from "stores/portal"
import { tables } from "stores/builder"
import { notifications } from "@budibase/bbui"
import { getEnvironmentBindings, migrateReferencesInObject } from "dataBinding"
import {
getEnvironmentBindings,
migrateReferencesInObject,
getUserBindings,
getSettingBindings,
} from "dataBinding"
import {
AutomationTriggerStepId,
AutomationEventType,
Expand Down Expand Up @@ -334,6 +339,42 @@ const automationActions = store => ({
}
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 settings bindings
*
* @returns {Array<Object>} all available settings bindings
*/
buildSettingBindings: () => {
return getSettingBindings().map(binding => {
return {
...binding,
display: {
...binding.display,
rank: 98,
},
}
})
},

/**
* Take the supplied step id and aggregate all bindings for every
* step preceding it.
Expand Down

0 comments on commit 3ad1cf5

Please sign in to comment.