Filter 'link' fields from the Current User bindings

This commit is contained in:
Dean 2022-09-20 11:09:58 +01:00
parent e387ee2591
commit 5f7cfb5731
1 changed files with 18 additions and 13 deletions

View File

@ -393,20 +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",
}) icon: "User",
}) })
}
return acc
}, [])
return bindings return bindings
} }