add environment bindings to rest query binding drawer
This commit is contained in:
parent
100571b6fe
commit
fc6d20c0b2
|
@ -21,6 +21,7 @@ import {
|
||||||
import { TableNames } from "../constants"
|
import { TableNames } from "../constants"
|
||||||
import { JSONUtils } from "@budibase/frontend-core"
|
import { JSONUtils } from "@budibase/frontend-core"
|
||||||
import ActionDefinitions from "components/design/settings/controls/ButtonActionEditor/manifest.json"
|
import ActionDefinitions from "components/design/settings/controls/ButtonActionEditor/manifest.json"
|
||||||
|
import { environment } from "stores/portal"
|
||||||
|
|
||||||
// Regex to match all instances of template strings
|
// Regex to match all instances of template strings
|
||||||
const CAPTURE_VAR_INSIDE_TEMPLATE = /{{([^}]+)}}/g
|
const CAPTURE_VAR_INSIDE_TEMPLATE = /{{([^}]+)}}/g
|
||||||
|
@ -54,7 +55,7 @@ export const getBindableProperties = (asset, componentId) => {
|
||||||
*/
|
*/
|
||||||
export const getRestBindings = () => {
|
export const getRestBindings = () => {
|
||||||
const userBindings = getUserBindings()
|
const userBindings = getUserBindings()
|
||||||
return [...userBindings, ...getAuthBindings()]
|
return [...userBindings, ...getAuthBindings(), ...getEnvironmentBindings()]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,6 +90,21 @@ export const getAuthBindings = () => {
|
||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getEnvironmentBindings = () => {
|
||||||
|
let envVars = get(environment).variables
|
||||||
|
let test = envVars.map(variable => {
|
||||||
|
return {
|
||||||
|
type: "context",
|
||||||
|
runtimeBinding: `env.${makePropSafe(variable.name)}`,
|
||||||
|
readableBinding: `env.${variable.name}`,
|
||||||
|
category: "Environment",
|
||||||
|
icon: "Key",
|
||||||
|
display: { type: "string", name: variable.name },
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return test
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility - convert a key/value map to an array of custom 'context' bindings
|
* Utility - convert a key/value map to an array of custom 'context' bindings
|
||||||
* @param {object} valueMap Key/value pairings
|
* @param {object} valueMap Key/value pairings
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
export let allowHelpers = true
|
export let allowHelpers = true
|
||||||
export let updateOnChange = true
|
export let updateOnChange = true
|
||||||
export let drawerLeft
|
export let drawerLeft
|
||||||
$: console.log(bindings)
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let bindingDrawer
|
let bindingDrawer
|
||||||
let valid = true
|
let valid = true
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { goto, params } from "@roxi/routify"
|
import { goto, params } from "@roxi/routify"
|
||||||
import { datasources, flags, integrations, queries } from "stores/backend"
|
import { datasources, flags, integrations, queries } from "stores/backend"
|
||||||
|
import { environment } from "stores/portal"
|
||||||
import {
|
import {
|
||||||
Banner,
|
Banner,
|
||||||
Body,
|
Body,
|
||||||
|
@ -362,6 +363,13 @@
|
||||||
notifications.error("Error getting datasources")
|
notifications.error("Error getting datasources")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// load the environment variables
|
||||||
|
await environment.loadVariables()
|
||||||
|
} catch (error) {
|
||||||
|
notifications.error("Error getting environment variables")
|
||||||
|
}
|
||||||
|
|
||||||
datasource = $datasources.list.find(ds => ds._id === query?.datasourceId)
|
datasource = $datasources.list.find(ds => ds._id === query?.datasourceId)
|
||||||
const datasourceUrl = datasource?.config.url
|
const datasourceUrl = datasource?.config.url
|
||||||
const qs = query?.fields.queryString
|
const qs = query?.fields.queryString
|
||||||
|
|
Loading…
Reference in New Issue