Merge pull request #7809 from Budibase/fix/missing-rest-binding-category-names
Fix/missing rest binding category names
This commit is contained in:
commit
f1d5f37e9c
|
@ -9,14 +9,14 @@ import {
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import {
|
import {
|
||||||
queries as queriesStores,
|
queries as queriesStores,
|
||||||
roles as rolesStore,
|
|
||||||
tables as tablesStore,
|
tables as tablesStore,
|
||||||
|
roles as rolesStore,
|
||||||
} from "stores/backend"
|
} from "stores/backend"
|
||||||
import {
|
import {
|
||||||
|
makePropSafe,
|
||||||
|
isJSBinding,
|
||||||
decodeJSBinding,
|
decodeJSBinding,
|
||||||
encodeJSBinding,
|
encodeJSBinding,
|
||||||
isJSBinding,
|
|
||||||
makePropSafe,
|
|
||||||
} from "@budibase/string-templates"
|
} from "@budibase/string-templates"
|
||||||
import { TableNames } from "../constants"
|
import { TableNames } from "../constants"
|
||||||
import { JSONUtils } from "@budibase/frontend-core"
|
import { JSONUtils } from "@budibase/frontend-core"
|
||||||
|
@ -71,17 +71,19 @@ export const getAuthBindings = () => {
|
||||||
runtime: `${safeUser}.${safeOAuth2}.${safeAccessToken}`,
|
runtime: `${safeUser}.${safeOAuth2}.${safeAccessToken}`,
|
||||||
readable: `Current User.OAuthToken`,
|
readable: `Current User.OAuthToken`,
|
||||||
key: "accessToken",
|
key: "accessToken",
|
||||||
|
display: { name: "OAuthToken" },
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
bindings = Object.keys(authBindings).map(key => {
|
bindings = authBindings.map(fieldBinding => {
|
||||||
const fieldBinding = authBindings[key]
|
|
||||||
return {
|
return {
|
||||||
type: "context",
|
type: "context",
|
||||||
runtimeBinding: fieldBinding.runtime,
|
runtimeBinding: fieldBinding.runtime,
|
||||||
readableBinding: fieldBinding.readable,
|
readableBinding: fieldBinding.readable,
|
||||||
fieldSchema: { type: "string", name: fieldBinding.key },
|
fieldSchema: { type: "string", name: fieldBinding.key },
|
||||||
providerId: "user",
|
providerId: "user",
|
||||||
|
category: "Current User",
|
||||||
|
display: fieldBinding.display,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return bindings
|
return bindings
|
||||||
|
@ -93,7 +95,7 @@ export const getAuthBindings = () => {
|
||||||
* @param {string} prefix A contextual string prefix/path for a user readable binding
|
* @param {string} prefix A contextual string prefix/path for a user readable binding
|
||||||
* @return {object[]} An array containing readable/runtime binding objects
|
* @return {object[]} An array containing readable/runtime binding objects
|
||||||
*/
|
*/
|
||||||
export const toBindingsArray = (valueMap, prefix) => {
|
export const toBindingsArray = (valueMap, prefix, category) => {
|
||||||
if (!valueMap) {
|
if (!valueMap) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
@ -101,11 +103,20 @@ export const toBindingsArray = (valueMap, prefix) => {
|
||||||
if (!binding || !valueMap[binding]) {
|
if (!binding || !valueMap[binding]) {
|
||||||
return acc
|
return acc
|
||||||
}
|
}
|
||||||
acc.push({
|
|
||||||
|
let config = {
|
||||||
type: "context",
|
type: "context",
|
||||||
runtimeBinding: binding,
|
runtimeBinding: binding,
|
||||||
readableBinding: `${prefix}.${binding}`,
|
readableBinding: `${prefix}.${binding}`,
|
||||||
})
|
icon: "Brackets",
|
||||||
|
}
|
||||||
|
|
||||||
|
if (category) {
|
||||||
|
config.category = category
|
||||||
|
}
|
||||||
|
|
||||||
|
acc.push(config)
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
}, [])
|
}, [])
|
||||||
}
|
}
|
||||||
|
@ -382,21 +393,25 @@ export const getUserBindings = () => {
|
||||||
const { schema } = getSchemaForTable(TableNames.USERS)
|
const { schema } = getSchemaForTable(TableNames.USERS)
|
||||||
const keys = Object.keys(schema).sort()
|
const keys = Object.keys(schema).sort()
|
||||||
const safeUser = makePropSafe("user")
|
const safeUser = makePropSafe("user")
|
||||||
keys.forEach(key => {
|
|
||||||
|
bindings = keys.reduce((acc, key) => {
|
||||||
const fieldSchema = schema[key]
|
const fieldSchema = schema[key]
|
||||||
bindings.push({
|
if (fieldSchema.type !== "link") {
|
||||||
type: "context",
|
acc.push({
|
||||||
runtimeBinding: `${safeUser}.${makePropSafe(key)}`,
|
type: "context",
|
||||||
readableBinding: `Current User.${key}`,
|
runtimeBinding: `${safeUser}.${makePropSafe(key)}`,
|
||||||
// Field schema and provider are required to construct relationship
|
readableBinding: `Current User.${key}`,
|
||||||
// datasource options, based on bindable properties
|
// Field schema and provider are required to construct relationship
|
||||||
fieldSchema,
|
// datasource options, based on bindable properties
|
||||||
providerId: "user",
|
fieldSchema,
|
||||||
category: "Current User",
|
providerId: "user",
|
||||||
icon: "User",
|
category: "Current User",
|
||||||
display: fieldSchema,
|
icon: "User",
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
return acc
|
||||||
|
}, [])
|
||||||
|
|
||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,14 +60,20 @@
|
||||||
|
|
||||||
$: staticVariables = datasource?.config?.staticVariables || {}
|
$: staticVariables = datasource?.config?.staticVariables || {}
|
||||||
|
|
||||||
$: customRequestBindings = toBindingsArray(requestBindings, "Binding")
|
$: customRequestBindings = toBindingsArray(
|
||||||
|
requestBindings,
|
||||||
|
"Binding",
|
||||||
|
"Bindings"
|
||||||
|
)
|
||||||
$: globalDynamicRequestBindings = toBindingsArray(
|
$: globalDynamicRequestBindings = toBindingsArray(
|
||||||
globalDynamicBindings,
|
globalDynamicBindings,
|
||||||
|
"Dynamic",
|
||||||
"Dynamic"
|
"Dynamic"
|
||||||
)
|
)
|
||||||
$: dataSourceStaticBindings = toBindingsArray(
|
$: dataSourceStaticBindings = toBindingsArray(
|
||||||
staticVariables,
|
staticVariables,
|
||||||
"Datasource.Static"
|
"Datasource.Static",
|
||||||
|
"Datasource Static"
|
||||||
)
|
)
|
||||||
|
|
||||||
$: mergedBindings = [
|
$: mergedBindings = [
|
||||||
|
|
Loading…
Reference in New Issue