Merge branch 'master' into develop

This commit is contained in:
Rory Powell 2021-12-01 13:46:20 +00:00
commit acf2c5d506
13 changed files with 106 additions and 41 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.0.3-alpha.0", "version": "1.0.3",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*" "packages/*"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/auth", "name": "@budibase/auth",
"version": "1.0.3-alpha.0", "version": "1.0.3",
"description": "Authentication middlewares for budibase builder and apps", "description": "Authentication middlewares for budibase builder and apps",
"main": "src/index.js", "main": "src/index.js",
"author": "Budibase", "author": "Budibase",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/bbui", "name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.", "description": "A UI solution used in the different Budibase projects.",
"version": "1.0.3-alpha.0", "version": "1.0.3",
"license": "MPL-2.0", "license": "MPL-2.0",
"svelte": "src/index.js", "svelte": "src/index.js",
"module": "dist/bbui.es.js", "module": "dist/bbui.es.js",

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/builder", "name": "@budibase/builder",
"version": "1.0.3-alpha.0", "version": "1.0.3",
"license": "GPL-3.0", "license": "GPL-3.0",
"private": true, "private": true,
"scripts": { "scripts": {
@ -65,10 +65,10 @@
} }
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.0.3-alpha.0", "@budibase/bbui": "^1.0.3",
"@budibase/client": "^1.0.3-alpha.0", "@budibase/client": "^1.0.3",
"@budibase/colorpicker": "1.1.2", "@budibase/colorpicker": "1.1.2",
"@budibase/string-templates": "^1.0.3-alpha.0", "@budibase/string-templates": "^1.0.3",
"@sentry/browser": "5.19.1", "@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1", "@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1", "@spectrum-css/vars": "^3.0.1",

View File

@ -61,7 +61,7 @@ export const getComponentBindableProperties = (asset, componentId) => {
/** /**
* Gets all data provider components above a component. * Gets all data provider components above a component.
*/ */
export const getDataProviderComponents = (asset, componentId) => { export const getContextProviderComponents = (asset, componentId, type) => {
if (!asset || !componentId) { if (!asset || !componentId) {
return [] return []
} }
@ -74,7 +74,18 @@ export const getDataProviderComponents = (asset, componentId) => {
// Filter by only data provider components // Filter by only data provider components
return path.filter(component => { return path.filter(component => {
const def = store.actions.components.getDefinition(component._component) const def = store.actions.components.getDefinition(component._component)
return def?.context != null if (!def?.context) {
return false
}
// If no type specified, return anything that exposes context
if (!type) {
return true
}
// Otherwise only match components with the specific context type
const contexts = Array.isArray(def.context) ? def.context : [def.context]
return contexts.find(context => context.type === type) != null
}) })
} }
@ -143,7 +154,7 @@ export const getDatasourceForProvider = (asset, component) => {
*/ */
const getContextBindings = (asset, componentId) => { const getContextBindings = (asset, componentId) => {
// Extract any components which provide data contexts // Extract any components which provide data contexts
const dataProviders = getDataProviderComponents(asset, componentId) const dataProviders = getContextProviderComponents(asset, componentId)
// Generate bindings for all matching components // Generate bindings for all matching components
return getProviderContextBindings(asset, dataProviders) return getProviderContextBindings(asset, dataProviders)

View File

@ -1,5 +1,5 @@
<script> <script>
import { getDataProviderComponents } from "builderStore/dataBinding" import { getContextProviderComponents } from "builderStore/dataBinding"
import { import {
Button, Button,
Popover, Popover,
@ -58,16 +58,19 @@
...query, ...query,
type: "query", type: "query",
})) }))
$: dataProviders = getDataProviderComponents( $: contextProviders = getContextProviderComponents(
$currentAsset, $currentAsset,
$store.selectedComponentId $store.selectedComponentId
).map(provider => ({ )
label: provider._instanceName, $: dataProviders = contextProviders
name: provider._instanceName, .filter(component => component._component?.endsWith("/dataprovider"))
providerId: provider._id, .map(provider => ({
value: `{{ literal ${safe(provider._id)} }}`, label: provider._instanceName,
type: "provider", name: provider._instanceName,
})) providerId: provider._id,
value: `{{ literal ${safe(provider._id)} }}`,
type: "provider",
}))
$: links = bindings $: links = bindings
.filter(x => x.fieldSchema?.type === "link") .filter(x => x.fieldSchema?.type === "link")
.map(binding => { .map(binding => {

View File

@ -4,6 +4,7 @@
import { notifications } from "@budibase/bbui" import { notifications } from "@budibase/bbui"
import EventEditor from "./EventEditor.svelte" import EventEditor from "./EventEditor.svelte"
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import { cloneDeep } from "lodash/fp"
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -12,17 +13,23 @@
export let bindings export let bindings
let drawer let drawer
let tmpValue
const openDrawer = () => {
tmpValue = cloneDeep(value)
drawer.show()
}
const saveEventData = async () => { const saveEventData = async () => {
// any automations that need created from event triggers // any automations that need created from event triggers
const automationsToCreate = value.filter( const automationsToCreate = tmpValue.filter(
action => action["##eventHandlerType"] === "Trigger Automation" action => action["##eventHandlerType"] === "Trigger Automation"
) )
for (let action of automationsToCreate) { for (let action of automationsToCreate) {
await createAutomation(action.parameters) await createAutomation(action.parameters)
} }
dispatch("change", value) dispatch("change", tmpValue)
notifications.success("Component actions saved.") notifications.success("Component actions saved.")
drawer.hide() drawer.hide()
} }
@ -54,11 +61,16 @@
} }
</script> </script>
<ActionButton on:click={drawer.show}>Define actions</ActionButton> <ActionButton on:click={openDrawer}>Define actions</ActionButton>
<Drawer bind:this={drawer} title={"Actions"}> <Drawer bind:this={drawer} title={"Actions"}>
<svelte:fragment slot="description"> <svelte:fragment slot="description">
Define what actions to run. Define what actions to run.
</svelte:fragment> </svelte:fragment>
<Button cta slot="buttons" on:click={saveEventData}>Save</Button> <Button cta slot="buttons" on:click={saveEventData}>Save</Button>
<EventEditor slot="body" bind:actions={value} eventType={name} {bindings} /> <EventEditor
slot="body"
bind:actions={tmpValue}
eventType={name}
{bindings}
/>
</Drawer> </Drawer>

View File

@ -3,7 +3,7 @@
import { store, currentAsset } from "builderStore" import { store, currentAsset } from "builderStore"
import { tables } from "stores/backend" import { tables } from "stores/backend"
import { import {
getDataProviderComponents, getContextProviderComponents,
getSchemaForDatasource, getSchemaForDatasource,
} from "builderStore/dataBinding" } from "builderStore/dataBinding"
import SaveFields from "./SaveFields.svelte" import SaveFields from "./SaveFields.svelte"
@ -11,13 +11,54 @@
export let parameters export let parameters
export let bindings = [] export let bindings = []
$: dataProviderComponents = getDataProviderComponents( $: formComponents = getContextProviderComponents(
$currentAsset, $currentAsset,
$store.selectedComponentId $store.selectedComponentId,
"form"
) )
$: schemaComponents = getContextProviderComponents(
$currentAsset,
$store.selectedComponentId,
"schema"
)
$: providerOptions = getProviderOptions(formComponents, schemaComponents)
$: schemaFields = getSchemaFields($currentAsset, parameters?.tableId) $: schemaFields = getSchemaFields($currentAsset, parameters?.tableId)
$: tableOptions = $tables.list || [] $: tableOptions = $tables.list || []
// Gets a context definition of a certain type from a component definition
const extractComponentContext = (component, contextType) => {
const def = store.actions.components.getDefinition(component?._component)
if (!def) {
return null
}
const contexts = Array.isArray(def.context) ? def.context : [def.context]
return contexts.find(context => context?.type === contextType)
}
// Gets options for valid context keys which provide valid data to submit
const getProviderOptions = (formComponents, schemaComponents) => {
const formContexts = formComponents.map(component => ({
component,
context: extractComponentContext(component, "form"),
}))
const schemaContexts = schemaComponents.map(component => ({
component,
context: extractComponentContext(component, "schema"),
}))
const allContexts = formContexts.concat(schemaContexts)
return allContexts.map(({ component, context }) => {
let runtimeBinding = component._id
if (context.suffix) {
runtimeBinding += `-${context.suffix}`
}
return {
label: component._instanceName,
value: runtimeBinding,
}
})
}
const getSchemaFields = (asset, tableId) => { const getSchemaFields = (asset, tableId) => {
const { schema } = getSchemaForDatasource(asset, { type: "table", tableId }) const { schema } = getSchemaForDatasource(asset, { type: "table", tableId })
return Object.values(schema || {}) return Object.values(schema || {})
@ -39,10 +80,8 @@
<Label small>Data Source</Label> <Label small>Data Source</Label>
<Select <Select
bind:value={parameters.providerId} bind:value={parameters.providerId}
options={dataProviderComponents} options={providerOptions}
placeholder="None" placeholder="None"
getOptionLabel={option => option._instanceName}
getOptionValue={option => option._id}
/> />
<Label small>Table</Label> <Label small>Table</Label>

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "1.0.3-alpha.0", "version": "1.0.3",
"description": "Budibase CLI, for developers, self hosting and migrations.", "description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js", "main": "src/index.js",
"bin": { "bin": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/client", "name": "@budibase/client",
"version": "1.0.3-alpha.0", "version": "1.0.3",
"license": "MPL-2.0", "license": "MPL-2.0",
"module": "dist/budibase-client.js", "module": "dist/budibase-client.js",
"main": "dist/budibase-client.js", "main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw" "dev:builder": "rollup -cw"
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.0.3-alpha.0", "@budibase/bbui": "^1.0.3",
"@budibase/standard-components": "^0.9.139", "@budibase/standard-components": "^0.9.139",
"@budibase/string-templates": "^1.0.3-alpha.0", "@budibase/string-templates": "^1.0.3",
"regexparam": "^1.3.0", "regexparam": "^1.3.0",
"shortid": "^2.2.15", "shortid": "^2.2.15",
"svelte-spa-router": "^3.0.5" "svelte-spa-router": "^3.0.5"

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/server", "name": "@budibase/server",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.0.3-alpha.0", "version": "1.0.3",
"description": "Budibase Web Server", "description": "Budibase Web Server",
"main": "src/index.ts", "main": "src/index.ts",
"repository": { "repository": {
@ -69,9 +69,9 @@
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@budibase/auth": "^1.0.3-alpha.0", "@budibase/auth": "^1.0.3",
"@budibase/client": "^1.0.3-alpha.0", "@budibase/client": "^1.0.3",
"@budibase/string-templates": "^1.0.3-alpha.0", "@budibase/string-templates": "^1.0.3",
"@bull-board/api": "^3.7.0", "@bull-board/api": "^3.7.0",
"@bull-board/koa": "^3.7.0", "@bull-board/koa": "^3.7.0",
"@elastic/elasticsearch": "7.10.0", "@elastic/elasticsearch": "7.10.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "1.0.3-alpha.0", "version": "1.0.3",
"description": "Handlebars wrapper for Budibase templating.", "description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs", "main": "src/index.cjs",
"module": "dist/bundle.mjs", "module": "dist/bundle.mjs",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/worker", "name": "@budibase/worker",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.0.3-alpha.0", "version": "1.0.3",
"description": "Budibase background service", "description": "Budibase background service",
"main": "src/index.js", "main": "src/index.js",
"repository": { "repository": {
@ -29,8 +29,8 @@
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@budibase/auth": "^1.0.3-alpha.0", "@budibase/auth": "^1.0.3",
"@budibase/string-templates": "^1.0.3-alpha.0", "@budibase/string-templates": "^1.0.3",
"@koa/router": "^8.0.0", "@koa/router": "^8.0.0",
"@sentry/node": "^6.0.0", "@sentry/node": "^6.0.0",
"@techpass/passport-openidconnect": "^0.3.0", "@techpass/passport-openidconnect": "^0.3.0",