Merge branch 'feature/automation-redesign' of github.com:Budibase/budibase into feature/automation-query

This commit is contained in:
mike12345567 2021-09-15 11:44:01 +01:00
commit c0fe651419
76 changed files with 1105 additions and 1197 deletions

View File

@ -51,6 +51,7 @@ services:
INTERNAL_API_KEY: ${INTERNAL_API_KEY}
REDIS_URL: redis-service:6379
REDIS_PASSWORD: ${REDIS_PASSWORD}
ACCOUNT_PORTAL_URL: https://portal.budi.live
volumes:
- ./logs:/logs
depends_on:

View File

@ -87,6 +87,8 @@ spec:
{{ end }}
- name: SELF_HOSTED
value: {{ .Values.globals.selfHosted | quote }}
- name: ACCOUNT_PORTAL_URL
value: {{ .Values.globals.accountPortalUrl | quote }}
image: budibase/worker
imagePullPolicy: Always
name: bbworker

View File

@ -89,6 +89,7 @@ globals:
sentryDSN: ""
logLevel: info
selfHosted: 1
accountPortalUrL: ""
createSecrets: true # creates an internal API key, JWT secrets and redis password for you
# if createSecrets is set to false, you can hard-code your secrets here

View File

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

View File

@ -47,6 +47,8 @@
"release:helm": "./scripts/release_helm_chart.sh",
"multi:enable": "lerna run multi:enable",
"multi:disable": "lerna run multi:disable",
"selfhost:enable": "lerna run selfhost:enable",
"selfhost:disable": "lerna run selfhost:disable",
"postinstall": "husky install"
}
}

View File

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

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "0.9.125-alpha.5",
"version": "0.9.125-alpha.6",
"license": "AGPL-3.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",

View File

@ -12,6 +12,7 @@
export let dataCy = null
export let size = "M"
export let active = false
export let fullWidth = false
function longPress(element) {
if (!longPressable) return
@ -40,6 +41,7 @@
class:spectrum-ActionButton--quiet={quiet}
class:spectrum-ActionButton--emphasized={emphasized}
class:is-selected={selected}
class:fullWidth
class="spectrum-ActionButton spectrum-ActionButton--size{size}"
class:active
{disabled}
@ -71,6 +73,9 @@
</button>
<style>
.fullWidth {
width: 100%;
}
.active,
.active svg {
color: var(--spectrum-global-color-blue-600);

View File

@ -7,6 +7,7 @@
export let orange = false
export let yellow = false
export let seafoam = false
export let green = false
export let active = false
export let inactive = false
</script>
@ -17,6 +18,7 @@
class:spectrum-Label--large={size === "L"}
class:spectrum-Label--grey={grey}
class:spectrum-Label--red={red}
class:spectrum-Label--green={green}
class:spectrum-Label--orange={orange}
class:spectrum-Label--yellow={yellow}
class:spectrum-Label--seafoam={seafoam}

View File

@ -46,8 +46,10 @@
<h1
class="spectrum-Dialog-heading spectrum-Dialog-heading--noHeader"
class:noDivider={!showDivider}
class:header-spacing={$$slots.header}
>
{title}
<slot name="header" />
</h1>
{#if showDivider}
<Divider size="M" />
@ -120,4 +122,9 @@
.close-icon :global(svg) {
margin-right: 0;
}
.header-spacing {
display: flex;
justify-content: space-between;
}
</style>

View File

@ -0,0 +1,10 @@
<svg width="71" height="55" viewBox="0 0 71 55" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0)">
<path d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z" fill="#5865F2"/>
</g>
<defs>
<clipPath id="clip0">
<rect width="71" height="55" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 270 270" style="enable-background:new 0 0 270 270;" xml:space="preserve">
<style type="text/css">
.st0{fill:#E01E5A;}
.st1{fill:#36C5F0;}
.st2{fill:#2EB67D;}
.st3{fill:#ECB22E;}
</style>
<g>
<g>
<path class="st0" d="M99.4,151.2c0,7.1-5.8,12.9-12.9,12.9c-7.1,0-12.9-5.8-12.9-12.9c0-7.1,5.8-12.9,12.9-12.9h12.9V151.2z"/>
<path class="st0" d="M105.9,151.2c0-7.1,5.8-12.9,12.9-12.9s12.9,5.8,12.9,12.9v32.3c0,7.1-5.8,12.9-12.9,12.9
s-12.9-5.8-12.9-12.9V151.2z"/>
</g>
<g>
<path class="st1" d="M118.8,99.4c-7.1,0-12.9-5.8-12.9-12.9c0-7.1,5.8-12.9,12.9-12.9s12.9,5.8,12.9,12.9v12.9H118.8z"/>
<path class="st1" d="M118.8,105.9c7.1,0,12.9,5.8,12.9,12.9s-5.8,12.9-12.9,12.9H86.5c-7.1,0-12.9-5.8-12.9-12.9
s5.8-12.9,12.9-12.9H118.8z"/>
</g>
<g>
<path class="st2" d="M170.6,118.8c0-7.1,5.8-12.9,12.9-12.9c7.1,0,12.9,5.8,12.9,12.9s-5.8,12.9-12.9,12.9h-12.9V118.8z"/>
<path class="st2" d="M164.1,118.8c0,7.1-5.8,12.9-12.9,12.9c-7.1,0-12.9-5.8-12.9-12.9V86.5c0-7.1,5.8-12.9,12.9-12.9
c7.1,0,12.9,5.8,12.9,12.9V118.8z"/>
</g>
<g>
<path class="st3" d="M151.2,170.6c7.1,0,12.9,5.8,12.9,12.9c0,7.1-5.8,12.9-12.9,12.9c-7.1,0-12.9-5.8-12.9-12.9v-12.9H151.2z"/>
<path class="st3" d="M151.2,164.1c-7.1,0-12.9-5.8-12.9-12.9c0-7.1,5.8-12.9,12.9-12.9h32.3c7.1,0,12.9,5.8,12.9,12.9
c0,7.1-5.8,12.9-12.9,12.9H151.2z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

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

View File

@ -13,6 +13,10 @@ export default class Automation {
return this.automation.definition.trigger
}
addTestData(data) {
this.automation.testData = data
}
addBlock(block) {
// Make sure to add trigger if doesn't exist
if (!this.hasTrigger() && block.type === "TRIGGER") {

View File

@ -17,7 +17,6 @@ const automationActions = store => ({
state.blockDefinitions = {
TRIGGER: jsonResponses[1].trigger,
ACTION: jsonResponses[1].action,
LOGIC: jsonResponses[1].logic,
}
// if previously selected find the new obj and select it
if (selected) {
@ -80,9 +79,14 @@ const automationActions = store => ({
const { _id } = automation
return await api.post(`/api/automations/${_id}/trigger`)
},
test: async ({ automation }) => {
test: async ({ automation }, testData) => {
const { _id } = automation
return await api.post(`/api/automations/${_id}/test`)
const response = await api.post(`/api/automations/${_id}/test`, testData)
const json = await response.json()
store.update(state => {
state.selectedAutomation.testResults = json
return state
})
},
select: automation => {
store.update(state => {
@ -91,6 +95,12 @@ const automationActions = store => ({
return state
})
},
addTestDataToAutomation: data => {
store.update(state => {
state.selectedAutomation.addTestData(data)
return state
})
},
addBlockToAutomation: block => {
store.update(state => {
const newBlock = state.selectedAutomation.addBlock(cloneDeep(block))
@ -132,7 +142,6 @@ export const getAutomationStore = () => {
blockDefinitions: {
TRIGGER: [],
ACTION: [],
LOGIC: [],
},
selectedAutomation: null,
}

View File

@ -1,10 +1,8 @@
<script>
import { automationStore } from "builderStore"
import Flowchart from "./FlowChart/FlowChart.svelte"
import BlockList from "./BlockList.svelte"
$: automation = $automationStore.selectedAutomation?.automation
function onSelect(block) {
automationStore.update(state => {
state.selectedBlock = block
@ -14,6 +12,5 @@
</script>
{#if automation}
<BlockList />
<Flowchart {automation} {onSelect} />
{/if}

View File

@ -1,114 +0,0 @@
<script>
import { sortBy } from "lodash/fp"
import { automationStore } from "builderStore"
import { ActionButton, Popover, Modal } from "@budibase/bbui"
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns"
import CreateWebhookModal from "../Shared/CreateWebhookModal.svelte"
$: hasTrigger = $automationStore.selectedAutomation.hasTrigger()
$: tabs = [
{
label: "Trigger",
value: "TRIGGER",
icon: "Algorithm",
disabled: hasTrigger,
},
{
label: "Internal",
value: "ACTION",
internal: true,
icon: "Actions",
disabled: !hasTrigger,
},
{
label: "External",
value: "ACTION",
internal: false,
icon: "Extension",
disabled: !hasTrigger,
},
]
let selectedIndex
let anchors = []
let popover
let webhookModal
$: selectedTab = selectedIndex == null ? null : tabs[selectedIndex].value
$: selectedInternal =
selectedIndex == null ? null : tabs[selectedIndex].internal
$: anchor = selectedIndex === -1 ? null : anchors[selectedIndex]
$: blocks = sortBy(entry => entry[1].name)(
Object.entries($automationStore.blockDefinitions[selectedTab] ?? {})
).filter(
entry => selectedInternal == null || entry[1].internal === selectedInternal
)
function onChangeTab(idx) {
selectedIndex = idx
popover.show()
}
function closePopover() {
selectedIndex = null
popover.hide()
}
function addBlockToAutomation(stepId, blockDefinition) {
const newBlock = $automationStore.selectedAutomation.constructBlock(
selectedTab,
stepId,
blockDefinition
)
automationStore.actions.addBlockToAutomation(newBlock)
closePopover()
if (stepId === "WEBHOOK") {
webhookModal.show()
}
}
</script>
<div class="tab-container">
{#each tabs as tab, idx}
<div bind:this={anchors[idx]}>
<ActionButton
quiet
size="S"
icon={tab.icon}
disabled={tab.disabled}
on:click={tab.disabled ? null : () => onChangeTab(idx)}
>
{tab.label}
</ActionButton>
</div>
{/each}
</div>
<Popover
on:close={() => (selectedIndex = null)}
bind:this={popover}
{anchor}
align="left"
>
<DropdownContainer>
{#each blocks as [stepId, blockDefinition]}
<DropdownItem
icon={blockDefinition.icon}
title={blockDefinition.name}
subtitle={blockDefinition.description}
on:click={() => addBlockToAutomation(stepId, blockDefinition)}
/>
{/each}
</DropdownContainer>
</Popover>
<Modal bind:this={webhookModal} width="30%">
<CreateWebhookModal />
</Modal>
<style>
.tab-container {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
min-height: 24px;
}
</style>

View File

@ -0,0 +1,149 @@
<script>
import { ModalContent, Layout, Detail, Body, Icon } from "@budibase/bbui"
import { automationStore } from "builderStore"
import DiscordLogo from "assets/discord.svg"
import ZapierLogo from "assets/zapier.png"
import IntegromatLogo from "assets/integromat.png"
import SlackLogo from "assets/slack.svg"
import n8nlogo from "assets/n8n.png"
import { database } from "stores/backend"
$: instanceId = $database._id
let selectedAction
let actionVal
export let blockComplete
let externalActionsPredicate = [
{ name: "zapier", logo: ZapierLogo },
{ name: "discord", logo: DiscordLogo },
{ name: "slack", logo: SlackLogo },
{ name: "integromat", logo: IntegromatLogo },
{ name: "n8n", logo: n8nlogo },
]
let actions = Object.entries($automationStore.blockDefinitions.ACTION)
const externalActions = actions.reduce((acc, elm) => {
const [k, v] = elm
if (externalActionsPredicate.some(pred => pred.name === k)) {
acc[k] = v
}
return acc
}, {})
const internalActions = actions.reduce((acc, elm) => {
const [k, v] = elm
if (!externalActionsPredicate.some(pred => pred.name === k)) {
acc[k] = v
}
return acc
}, {})
const selectAction = action => {
actionVal = action
selectedAction = action.name
}
async function addBlockToAutomation() {
const newBlock = $automationStore.selectedAutomation.constructBlock(
"ACTION",
actionVal.stepId,
actionVal
)
automationStore.actions.addBlockToAutomation(newBlock)
await automationStore.actions.save({
instanceId,
automation: $automationStore.selectedAutomation?.automation,
})
}
</script>
<ModalContent
title="Create Automation"
confirmText="Save"
size="M"
disabled={!selectedAction}
onConfirm={() => {
blockComplete = true
addBlockToAutomation()
}}
>
<Body size="XS">Select an app or event.</Body>
<Layout noPadding>
<Body size="S">Apps</Body>
<div class="item-list">
{#each Object.entries(externalActions) as [idx, action]}
<div
class="item"
class:selected={selectedAction === action.name}
on:click={() => selectAction(action)}
>
<div class="item-body">
<img
width="20"
height="20"
src={externalActionsPredicate.find(val => val.name === idx).logo}
alt="zapier"
/>
<span class="icon-spacing">
<Body size="XS">{idx.charAt(0).toUpperCase() + idx.slice(1)}</Body
></span
>
</div>
</div>
{/each}
</div>
<Detail size="S">Actions</Detail>
<div class="item-list">
{#each Object.entries(internalActions) as [idx, action]}
<div
class="item"
class:selected={selectedAction === action.name}
on:click={() => selectAction(action)}
>
<div class="item-body">
<Icon name={action.icon} />
<span class="icon-spacing">
<Body size="XS">{action.name}</Body></span
>
</div>
</div>
{/each}
</div>
</Layout>
</ModalContent>
<style>
.icon-spacing {
margin-left: var(--spacing-m);
}
.item-body {
display: flex;
margin-left: var(--spacing-m);
}
.item-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
grid-gap: var(--spectrum-alias-grid-baseline);
}
.item {
cursor: pointer;
display: grid;
grid-gap: var(--spectrum-alias-grid-margin-xsmall);
padding: var(--spectrum-alias-item-padding-s);
background: var(--spectrum-alias-background-color-secondary);
transition: 0.3s all;
border: solid #3b3d3c;
border-radius: 5px;
box-sizing: border-box;
border-width: 2px;
}
.item:hover,
.selected {
background: var(--spectrum-alias-background-color-tertiary);
}
</style>

View File

@ -6,6 +6,7 @@
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-dasharray="5,5"
d="M5.0625 70H9L4.5 75L0 70H3.9375V65H5.0625V70Z"
fill="var(--grey-5)"
/>

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 353 B

View File

@ -0,0 +1,13 @@
import DiscordLogo from "assets/discord.svg"
import ZapierLogo from "assets/zapier.png"
import IntegromatLogo from "assets/integromat.png"
import SlackLogo from "assets/slack.svg"
import n8nlogo from "assets/n8n.png"
export const externalActions = {
zapier: { name: "zapier", icon: ZapierLogo },
discord: { name: "discord", icon: DiscordLogo },
slack: { name: "slack", icon: SlackLogo },
integromat: { name: "integromat", icon: IntegromatLogo },
n8n: { name: "n8n", icon: n8nlogo },
}

View File

@ -1,13 +1,27 @@
<script>
import { automationStore } from "builderStore"
import FlowItem from "./FlowItem.svelte"
import Arrow from "./Arrow.svelte"
import TestDataModal from "./TestDataModal.svelte"
import { flip } from "svelte/animate"
import { fade, fly } from "svelte/transition"
import {
Detail,
Icon,
ActionButton,
notifications,
Modal,
} from "@budibase/bbui"
import { database } from "stores/backend"
export let automation
export let onSelect
let testDataModal
let blocks
$: instanceId = $database._id
$: {
blocks = []
if (automation) {
@ -17,37 +31,89 @@
blocks = blocks.concat(automation.definition.steps || [])
}
}
async function deleteAutomation() {
await automationStore.actions.delete({
instanceId,
automation: $automationStore.selectedAutomation?.automation,
})
}
async function testAutomation() {
const result = await automationStore.actions.trigger({
automation: $automationStore.selectedAutomation.automation,
})
if (result.status === 200) {
notifications.success(
`Automation ${$automationStore.selectedAutomation.automation.name} triggered successfully.`
)
} else {
notifications.error(
`Failed to trigger automation ${$automationStore.selectedAutomation.automation.name}.`
)
}
return result
}
</script>
{#if !blocks.length}<i>Add a trigger to your automation to get started</i>{/if}
<section class="canvas">
{#each blocks as block, idx (block.id)}
<div
class="block"
animate:flip={{ duration: 600 }}
in:fade|local
out:fly|local={{ x: 100 }}
>
<FlowItem {onSelect} {block} />
{#if idx !== blocks.length - 1}
<Arrow />
{/if}
<div class="canvas">
<div class="content">
<div class="title">
<div class="subtitle">
<Detail size="L">{automation.name}</Detail>
<div
style="display:flex;
color: var(--spectrum-global-color-gray-400);"
>
<span on:click={() => deleteAutomation()} class="iconPadding">
<Icon name="DeleteOutline" />
</span>
<ActionButton
on:click={() => testDataModal.show()}
icon="MultipleCheck"
size="S">Run test</ActionButton
>
</div>
</div>
</div>
{/each}
</section>
{#each blocks as block, idx (block.id)}
<div
class="block"
animate:flip={{ duration: 800 }}
in:fade|local
out:fly|local={{ x: 500 }}
>
<FlowItem {testDataModal} {testAutomation} {onSelect} {block} />
{#if idx !== blocks.length - 1}
<div class="separator" />
<Icon name="AddCircle" size="S" />
<div class="separator" />
{/if}
</div>
{/each}
</div>
<Modal bind:this={testDataModal} width="30%">
<TestDataModal {testAutomation} />
</Modal>
</div>
<style>
section {
.separator {
width: 1px;
height: 25px;
border-left: 1px dashed var(--grey-4);
color: var(--grey-4);
/* center horizontally */
align-self: center;
}
.canvas {
margin: 0 -40px calc(-1 * var(--spacing-l)) -40px;
padding: var(--spacing-l) 40px 0 40px;
display: flex;
align-items: center;
flex-direction: column;
overflow-y: auto;
flex: 1 1 auto;
text-align: center;
height: 100%;
}
/* Fix for firefox not respecting bottom padding in scrolling containers */
section > *:last-child {
.canvas > *:last-child {
padding-bottom: 40px;
}
@ -58,8 +124,24 @@
align-items: center;
}
i {
font-size: var(--font-size-m);
color: var(--grey-5);
.content {
display: inline-block;
text-align: left;
}
.title {
padding-bottom: var(--spacing-xl);
}
.subtitle {
padding-bottom: var(--spacing-xl);
display: flex;
justify-content: space-between;
}
.iconPadding {
cursor: pointer;
display: flex;
padding-right: var(--spacing-m);
}
</style>

View File

@ -1,86 +1,200 @@
<script>
import { automationStore } from "builderStore"
import AutomationBlockTagline from "./AutomationBlockTagline.svelte"
import { Icon } from "@budibase/bbui"
import {
Icon,
Divider,
Layout,
Body,
Detail,
Modal,
Button,
StatusLight,
} from "@budibase/bbui"
import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte"
import CreateWebhookModal from "components/automation/shared/CreateWebhookModal.svelte"
import ResultsModal from "./ResultsModal.svelte"
import ActionModal from "./ActionModal.svelte"
import { database } from "stores/backend"
import { externalActions } from "./ExternalActions"
export let onSelect
export let block
export let testDataModal
let selected
let webhookModal
let actionModal
let resultsModal
let setupToggled
let blockComplete
$: testResult = $automationStore.selectedAutomation.testResults?.steps.filter(
step => step.stepId === block.stepId
)
$: instanceId = $database._id
$: isTrigger = block.type === "TRIGGER"
$: selected = $automationStore.selectedBlock?.id === block.id
$: steps =
$automationStore.selectedAutomation?.automation?.definition?.steps ?? []
$: blockIdx = steps.findIndex(step => step.id === block.id)
$: allowDeleteTrigger = !steps.length
function deleteStep() {
$: blockIdx = steps.findIndex(step => step.id === block.id)
$: lastStep = !isTrigger && blockIdx + 1 === steps.length
// Logic for hiding / showing the add button.first we check if it has a child
// then we check to see whether its inputs have been commpleted
$: disableAddButton = isTrigger
? $automationStore.selectedAutomation?.automation?.definition?.steps
.length > 0
: !isTrigger && steps.length - blockIdx > 1
$: hasCompletedInputs = Object.keys(
block.schema?.inputs?.properties || {}
).every(x => block?.inputs[x])
async function deleteStep() {
automationStore.actions.deleteAutomationBlock(block)
await automationStore.actions.save({
instanceId,
automation: $automationStore.selectedAutomation?.automation,
})
}
</script>
<div
class={`block ${block.type} hoverable`}
class:selected
on:click={() => onSelect(block)}
on:click={() => {
onSelect(block)
}}
>
<header>
{#if block.type === "TRIGGER"}
<Icon name="Light" />
<span>When this happens...</span>
{:else if block.type === "ACTION"}
<Icon name="FlashOn" />
<span>Do this...</span>
{:else if block.type === "LOGIC"}
<Icon name="Branch2" />
<span>Only continue if...</span>
{/if}
<div class="label">
{#if block.type === "TRIGGER"}Trigger{:else}Step {blockIdx + 1}{/if}
<div class="blockSection">
<div
on:click={() => {
blockComplete = !blockComplete
}}
class="splitHeader"
>
<div style="display: flex;">
{#if externalActions[block.stepId]}
<img
alt={externalActions[block.stepId].name}
width="35px"
height="35px"
src={externalActions[block.stepId].icon}
/>
{:else}
<svg
width="35px"
height="35px"
class="spectrum-Icon"
style="color:grey;"
focusable="false"
>
<use xlink:href="#spectrum-icon-18-{block.icon}" />
</svg>
{/if}
<div class="iconAlign">
<Body size="XS">When this happens:</Body>
<Detail size="S">{block?.name?.toUpperCase() || ""}</Detail>
</div>
</div>
{#if testResult}
<span on:click={() => resultsModal.show()}>
<StatusLight
positive={isTrigger || testResult[0].outputs?.success}
negative={!testResult[0].outputs?.success}
><Body size="XS">View response</Body></StatusLight
>
</span>
{/if}
</div>
{#if block.type !== "TRIGGER" || allowDeleteTrigger}
<div on:click|stopPropagation={deleteStep}><Icon name="Close" /></div>
{/if}
</header>
<hr />
<p>
<AutomationBlockTagline {block} />
</p>
</div>
{#if !blockComplete}
<Divider noMargin />
<div class="blockSection">
<Layout noPadding gap="S">
<div class="splitHeader">
<div
on:click|stopPropagation={() => {
setupToggled = !setupToggled
}}
class="toggle"
>
{#if setupToggled}
<Icon size="M" name="ChevronDown" />
{:else}
<Icon size="M" name="ChevronRight" />
{/if}
<Detail size="S">Setup</Detail>
</div>
{#if !isTrigger}
<div on:click={() => deleteStep()}>
<Icon name="DeleteOutline" />
</div>
{/if}
</div>
{#if setupToggled}
<AutomationBlockSetup
schemaProperties={Object.entries(block.schema.inputs.properties)}
{block}
{webhookModal}
/>
{#if lastStep}
<Button on:click={() => testDataModal.show()} cta
>Continue and test automation</Button
>
{/if}
<Button
disabled={disableAddButton ? true : !hasCompletedInputs}
on:click={() => {
setupToggled = false
actionModal.show()
}}
primary={!isTrigger}
cta={isTrigger}>Add Action</Button
>
{/if}
</Layout>
</div>
{/if}
<Modal bind:this={resultsModal} width="30%">
<ResultsModal {isTrigger} {testResult} />
</Modal>
<Modal bind:this={actionModal} width="30%">
<ActionModal bind:blockComplete />
</Modal>
<Modal bind:this={webhookModal} width="30%">
<CreateWebhookModal />
</Modal>
</div>
<style>
.toggle {
display: flex;
align-items: center;
}
.splitHeader {
display: flex;
justify-content: space-between;
}
.iconAlign {
padding: 0 0 0 var(--spacing-m);
display: inline-block;
}
.block {
width: 360px;
padding: 20px;
border-radius: var(--border-radius-m);
transition: 0.3s all ease;
box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.08);
font-size: 16px;
background-color: var(--spectrum-global-color-gray-50);
background-color: var(--spectrum-alias-background-color-secondary);
color: var(--grey-9);
}
.block.selected,
.block:hover {
transform: scale(1.1);
box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.15);
border: 1px solid var(--spectrum-global-color-gray-300);
border-radius: 4px 4px 4px 4px;
}
header {
font-size: 16px;
font-weight: 600;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
gap: var(--spacing-xs);
}
header span {
flex: 1 1 auto;
}
header .label {
font-size: 14px;
padding: var(--spacing-s);
border-radius: var(--border-radius-m);
background-color: var(--grey-2);
color: var(--grey-8);
.blockSection {
padding: var(--spacing-xl);
}
</style>

View File

@ -0,0 +1,88 @@
<script>
import { ModalContent, Icon, Detail, Badge, TextArea } from "@budibase/bbui"
export let testResult
export let isTrigger
let inputToggled
let outputToggled
</script>
<ModalContent
showCloseIcon={false}
showConfirmButton={false}
title="Test Automation"
cancelText="Close"
>
<div slot="header">
<div style="float: right;">
{#if isTrigger || testResult[0].outputs.success}
<Badge green><Icon size="S" name="CheckmarkCircle" /></Badge>
{:else}
<Badge red><Icon size="S" name="CloseCircle" /></Badge>
{/if}
</div>
</div>
<div
on:click={() => {
inputToggled = !inputToggled
}}
class="toggle splitHeader"
>
<div>
<div style="display: flex; align-items: center;">
<span style="padding-left: var(--spacing-s);">
<Detail size="S">Input</Detail>
</span>
</div>
</div>
<div>
{#if inputToggled}
<Icon size="M" name="ChevronDown" />
{:else}
<Icon size="M" name="ChevronRight" />
{/if}
</div>
</div>
{#if inputToggled}
<TextArea disabled value={JSON.stringify(testResult[0].inputs, null, 2)} />
{/if}
<div
on:click={() => {
outputToggled = !outputToggled
}}
class="toggle splitHeader"
>
<div>
<div style="display: flex; align-items: center;">
<span style="padding-left: var(--spacing-s);">
<Detail size="S">Output</Detail>
</span>
</div>
</div>
<div>
{#if outputToggled}
<Icon size="M" name="ChevronDown" />
{:else}
<Icon size="M" name="ChevronRight" />
{/if}
</div>
</div>
{#if outputToggled}
<TextArea disabled value={JSON.stringify(testResult[0].outputs, null, 2)} />
{/if}
</ModalContent>
<style>
.splitHeader {
cursor: pointer;
display: flex;
justify-content: space-between;
}
.toggle {
display: flex;
align-items: center;
}
</style>

View File

@ -0,0 +1,70 @@
<script>
import { ModalContent, Tabs, Tab, TextArea, Label } from "@budibase/bbui"
import { automationStore } from "builderStore"
import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte"
import { cloneDeep } from "lodash/fp"
let failedParse = null
// clone the trigger so we're not mutating the reference
let trigger = cloneDeep(
$automationStore.selectedAutomation.automation.definition.trigger
)
if (!$automationStore.selectedAutomation.automation.testData) {
$automationStore.selectedAutomation.automation.testData = {}
}
// get the outputs so we can define the fields
let schemaProperties = Object.entries(trigger.schema.outputs.properties || {})
// check to see if there is existing test data in the store
$: testData = $automationStore.selectedAutomation.automation.testData
// Checj the schema to see if required fields have been entered
$: isError = !trigger.schema.outputs.required.every(
required => testData[required]
)
function parseTestJSON(e) {
try {
const obj = JSON.parse(e.detail)
failedParse = null
automationStore.actions.addTestDataToAutomation(obj)
} catch (e) {
failedParse = "Invalid JSON"
}
}
</script>
<ModalContent
title="Add test data"
confirmText="Test"
showConfirmButton={true}
disabled={isError}
onConfirm={() => {
automationStore.actions.addTestDataToAutomation(testData)
automationStore.actions.test($automationStore.selectedAutomation, testData)
}}
cancelText="Cancel"
>
<Tabs selected="Form" quiet
><Tab icon="Form" title="Form"
><AutomationBlockSetup
bind:testData
{schemaProperties}
block={trigger}
/></Tab
>
<Tab icon="FileJson" title="JSON">
<Label>JSON</Label><TextArea
value={JSON.stringify(
$automationStore.selectedAutomation.automation.testData,
null,
2
)}
error={failedParse}
on:change={e => parseTestJSON(e)}
/>
</Tab>
</Tabs>
</ModalContent>

View File

@ -6,7 +6,6 @@
import EditAutomationPopover from "./EditAutomationPopover.svelte"
$: selectedAutomationId = $automationStore.selectedAutomation?.automation?._id
onMount(() => {
automationStore.actions.fetch()
})

View File

@ -2,7 +2,9 @@
import AutomationList from "./AutomationList.svelte"
import CreateAutomationModal from "./CreateAutomationModal.svelte"
import { Icon, Modal, Tabs, Tab } from "@budibase/bbui"
let modal
export let modal
export let webhookModal
</script>
<div class="title">
@ -11,7 +13,7 @@
<div class="tab-content-padding">
<AutomationList />
<Modal bind:this={modal}>
<CreateAutomationModal />
<CreateAutomationModal {webhookModal} />
</Modal>
</div>
</Tab>

View File

@ -3,12 +3,14 @@
import { database } from "stores/backend"
import { automationStore } from "builderStore"
import { notifications } from "@budibase/bbui"
import { Icon, Input, ModalContent } from "@budibase/bbui"
import { Input, ModalContent, Layout, Body, Icon } from "@budibase/bbui"
import analytics from "analytics"
let name
let selectedTrigger
let triggerVal
export let webhookModal
$: valid = !!name
$: instanceId = $database._id
async function createAutomation() {
@ -16,41 +18,97 @@
name,
instanceId,
})
const newBlock = $automationStore.selectedAutomation.constructBlock(
"TRIGGER",
triggerVal.stepId,
triggerVal
)
automationStore.actions.addBlockToAutomation(newBlock)
if (triggerVal.stepId === "WEBHOOK") {
webhookModal.show
}
await automationStore.actions.save({
instanceId,
automation: $automationStore.selectedAutomation?.automation,
})
notifications.success(`Automation ${name} created.`)
$goto(`./${$automationStore.selectedAutomation.automation._id}`)
analytics.captureEvent("Automation Created", { name })
}
$: triggers = Object.entries($automationStore.blockDefinitions.TRIGGER)
const selectTrigger = trigger => {
triggerVal = trigger
selectedTrigger = trigger.name
}
</script>
<ModalContent
title="Create Automation"
confirmText="Create"
size="L"
confirmText="Save"
size="M"
onConfirm={createAutomation}
disabled={!valid}
disabled={!selectedTrigger}
>
<Body size="XS"
>Please name your automation, then select a trigger. Every automation must
start with a trigger.
</Body>
<Input bind:value={name} label="Name" />
<a
slot="footer"
target="_blank"
href="https://docs.budibase.com/automate/introduction-to-automate"
>
<Icon name="InfoOutline" />
<span>Learn about automations</span>
</a>
<Layout noPadding>
<Body size="S">Triggers</Body>
<div class="item-list">
{#each triggers as [idx, trigger]}
<div
class="item"
class:selected={selectedTrigger === trigger.name}
on:click={() => selectTrigger(trigger)}
>
<div class="item-body">
<Icon name={trigger.icon} />
<span class="icon-spacing">
<Body size="S">{trigger.name}</Body></span
>
</div>
</div>
{/each}
</div>
</Layout>
</ModalContent>
<style>
a {
color: var(--ink);
font-size: 14px;
vertical-align: middle;
display: flex;
align-items: center;
text-decoration: none;
.icon-spacing {
margin-left: var(--spacing-m);
}
a span {
text-decoration: underline;
margin-left: var(--spectrum-alias-item-padding-s);
.item-body {
display: flex;
margin-left: var(--spacing-m);
}
.item-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
grid-gap: var(--spectrum-alias-grid-baseline);
}
.item {
cursor: pointer;
display: grid;
grid-gap: var(--spectrum-alias-grid-margin-xsmall);
padding: var(--spectrum-alias-item-padding-s);
background: var(--spectrum-alias-background-color-secondary);
transition: 0.3s all;
border: solid #3b3d3c;
border-radius: 5px;
box-sizing: border-box;
border-width: 2px;
}
.selected {
background: var(--spectrum-alias-background-color-tertiary);
}
</style>

View File

@ -12,15 +12,34 @@
import QueryParamSelector from "./QueryParamSelector.svelte"
import CronBuilder from "./CronBuilder.svelte"
import Editor from "components/integration/QueryEditor.svelte"
import { database } from "stores/backend"
import { debounce } from "lodash"
import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte"
export let block
export let webhookModal
$: inputs = Object.entries(block.schema?.inputs?.properties || {})
export let testData
export let schemaProperties
$: stepId = block.stepId
$: bindings = getAvailableBindings(
block,
block || $automationStore.selectedBlock,
$automationStore.selectedAutomation?.automation?.definition
)
$: instanceId = $database._id
$: inputData = testData ? testData : block.inputs
const onChange = debounce(async function (e, key) {
if (testData) {
testData[key] = e.detail
} else {
block.inputs[key] = e.detail
await automationStore.actions.save({
instanceId,
automation: $automationStore.selectedAutomation?.automation,
})
}
}, 800)
function getAvailableBindings(block, automation) {
if (!block || !automation) {
@ -55,61 +74,102 @@
</script>
<div class="fields">
<div class="block-label">{block.name}</div>
{#each inputs as [key, value]}
{#each schemaProperties as [key, value]}
<div class="block-field">
<Label>{value.title}</Label>
<Label>{value.title || key}</Label>
{#if value.type === "string" && value.enum}
<Select
bind:value={block.inputs[key]}
on:change={e => onChange(e, key)}
value={inputData[key]}
options={value.enum}
getOptionLabel={(x, idx) => (value.pretty ? value.pretty[idx] : x)}
/>
{:else if value.customType === "password"}
<Input type="password" bind:value={block.inputs[key]} />
<Input
type="password"
on:change={e => onChange(e, key)}
value={inputData[key]}
/>
{:else if value.customType === "email"}
<DrawerBindableInput
title={value.title}
panel={AutomationBindingPanel}
type="email"
value={block.inputs[key]}
on:change={e => (block.inputs[key] = e.detail)}
{#if testData}
<ModalBindableInput
title={value.title}
value={inputData[key]}
panel={AutomationBindingPanel}
type="email"
on:change={e => onChange(e, key)}
{bindings}
/>
{:else}
<DrawerBindableInput
title={value.title}
panel={AutomationBindingPanel}
type="email"
value={inputData[key]}
on:change={e => onChange(e, key)}
{bindings}
/>
{/if}
{:else if value.customType === "query"}
<QuerySelector
on:change={e => onChange(e, key)}
value={inputData[key]}
/>
{:else if value.customType === "cron"}
<CronBuilder on:change={e => onChange(e, key)} value={inputData[key]} />
{:else if value.customType === "queryParams"}
<QueryParamSelector
on:change={e => onChange(e, key)}
value={inputData[key]}
{bindings}
/>
{:else if value.customType === "query"}
<QuerySelector bind:value={block.inputs[key]} />
{:else if value.customType === "cron"}
<CronBuilder bind:value={block.inputs[key]} />
{:else if value.customType === "queryParams"}
<QueryParamSelector bind:value={block.inputs[key]} {bindings} />
{:else if value.customType === "table"}
<TableSelector bind:value={block.inputs[key]} />
<TableSelector
value={inputData[key]}
on:change={e => onChange(e, key)}
/>
{:else if value.customType === "row"}
<RowSelector bind:value={block.inputs[key]} {bindings} />
<RowSelector
value={inputData[key]}
on:change={e => onChange(e, key)}
{bindings}
/>
{:else if value.customType === "webhookUrl"}
<WebhookDisplay value={block.inputs[key]} />
<WebhookDisplay value={inputData[key]} />
{:else if value.customType === "triggerSchema"}
<SchemaSetup bind:value={block.inputs[key]} />
<SchemaSetup on:change={e => onChange(e, key)} value={value[key]} />
{:else if value.customType === "code"}
<CodeEditorModal>
<pre>{JSON.stringify(bindings, null, 2)}</pre>
<Editor
mode="javascript"
on:change={e => {
block.inputs[key] = e.detail.value
onChange(e, key)
inputData[key] = e.detail.value
}}
value={block.inputs[key]}
value={inputData[key]}
/>
</CodeEditorModal>
{:else if value.type === "string" || value.type === "number"}
<DrawerBindableInput
title={value.title}
panel={AutomationBindingPanel}
type={value.customType}
value={block.inputs[key]}
on:change={e => (block.inputs[key] = e.detail)}
{bindings}
/>
{#if testData}
<ModalBindableInput
title={value.title}
value={inputData[key]}
panel={AutomationBindingPanel}
type={value.customType}
on:change={e => onChange(e, key)}
{bindings}
/>
{:else}
<DrawerBindableInput
title={value.title}
panel={AutomationBindingPanel}
type={value.customType}
value={inputData[key]}
on:change={e => onChange(e, key)}
{bindings}
/>
{/if}
{/if}
</div>
{/each}
@ -131,10 +191,4 @@
display: grid;
grid-gap: 5px;
}
.block-label {
font-weight: 600;
font-size: var(--font-size-s);
color: var(--grey-7);
}
</style>

View File

@ -1,7 +1,13 @@
<script>
import { Button, Select, Input } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
export let value
const onChange = e => {
value = e.detail
dispatch("change", e.detail)
}
let presets = false
@ -30,7 +36,7 @@
</script>
<div class="block-field">
<Input bind:value />
<Input on:change={onChange} {value} />
<div class="presets">
<Button on:click={() => (presets = !presets)}
@ -38,7 +44,8 @@
>
{#if presets}
<Select
bind:value
on:change={onChange}
{value}
secondary
extraThin
label="Presets"

View File

@ -3,12 +3,25 @@
import { Select } from "@budibase/bbui"
import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte"
import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte"
import { createEventDispatcher } from "svelte"
import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte"
import { automationStore } from "builderStore"
const dispatch = createEventDispatcher()
export let value
export let bindings
$: table = $tables.list.find(table => table._id === value?.tableId)
$: schemaFields = Object.entries(table?.schema ?? {})
const onChangeTable = e => {
value = { tableId: e.detail }
dispatch("change", value)
}
const onChange = (e, field) => {
value[field] = e.detail
dispatch("change", value)
}
// Ensure any nullish tableId values get set to empty string so
// that the select works
@ -20,7 +33,8 @@
</script>
<Select
bind:value={value.tableId}
on:change={onChangeTable}
value={value.tableId}
options={$tables.list}
getOptionLabel={table => table.name}
getOptionValue={table => table._id}
@ -32,19 +46,31 @@
{#if !schema.autocolumn}
{#if schemaHasOptions(schema)}
<Select
on:change={e => onChange(e, field)}
label={field}
bind:value={value[field]}
value={value[field]}
options={schema.constraints.inclusion}
/>
{:else if schema.type === "string" || schema.type === "number"}
<DrawerBindableInput
panel={AutomationBindingPanel}
value={value[field]}
on:change={e => (value[field] = e.detail)}
label={field}
type="string"
{bindings}
/>
{#if $automationStore.selectedAutomation.automation.testData}
<ModalBindableInput
value={value[field]}
panel={AutomationBindingPanel}
label={field}
type={value.customType}
on:change={e => onChange(e, field)}
{bindings}
/>
{:else}
<DrawerBindableInput
panel={AutomationBindingPanel}
value={value[field]}
on:change={e => onChange(e, field)}
label={field}
type="string"
{bindings}
/>
{/if}
{/if}
{/if}
{/each}

View File

@ -1,5 +1,8 @@
<script>
import { Input, Select } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
export let value = {}
$: fieldsArray = Object.entries(value).map(([name, type]) => ({
@ -28,13 +31,13 @@
function addField() {
const newValue = { ...value }
newValue[""] = "string"
value = newValue
dispatch("change", newValue)
}
function removeField(name) {
const newValues = { ...value }
delete newValues[name]
value = newValues
dispatch("change", newValues)
}
const fieldNameChanged = originalName => e => {
@ -50,6 +53,7 @@
newVals[current.name] = current.type
return newVals
}, {})
dispatch("change", value)
}
</script>
@ -68,7 +72,10 @@
/>
<Select
value={field.type}
on:change={e => (value[field.name] = e.target.value)}
on:change={e => {
value[field.name] = e.target.value
dispatch("change", value)
}}
options={typeOptions}
/>
<i

View File

@ -1,96 +0,0 @@
<script>
import { automationStore } from "builderStore"
import { database } from "stores/backend"
import { notifications, Button, Modal, Heading, Toggle } from "@budibase/bbui"
import AutomationBlockSetup from "./AutomationBlockSetup.svelte"
import CreateWebookModal from "../Shared/CreateWebhookModal.svelte"
let webhookModal
$: instanceId = $database._id
$: automation = $automationStore.selectedAutomation?.automation
$: automationLive = automation?.live
function setAutomationLive(live) {
if (automationLive === live) {
return
}
automation.live = live
automationStore.actions.save({ instanceId, automation })
if (live) {
notifications.info(`Automation ${automation.name} enabled.`)
} else {
notifications.error(`Automation ${automation.name} disabled.`)
}
}
async function testAutomation() {
const result = await automationStore.actions.test({
automation: $automationStore.selectedAutomation.automation,
})
if (result.status === 200) {
notifications.success(
`Automation ${automation.name} triggered successfully.`
)
} else {
notifications.error(`Failed to trigger automation ${automation.name}.`)
}
}
async function saveAutomation() {
await automationStore.actions.save({
instanceId,
automation,
})
notifications.success(`Automation ${automation.name} saved.`)
}
</script>
<div class="title">
<Heading size="S">Setup</Heading>
<Toggle
value={automationLive}
on:change={() => setAutomationLive(!automationLive)}
dataCy="activate-automation"
text="Live"
/>
</div>
{#if $automationStore.selectedBlock}
<AutomationBlockSetup
bind:block={$automationStore.selectedBlock}
{webhookModal}
/>
{:else if automation}
<div class="block-label">{automation.name}</div>
<Button secondary on:click={testAutomation}>Test Automation</Button>
{/if}
<Button
secondary
wide
data-cy="save-automation-setup"
on:click={saveAutomation}
>
Save Automation
</Button>
<Modal bind:this={webhookModal} width="30%">
<CreateWebookModal />
</Modal>
<style>
.title {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: var(--spacing-xs);
}
.title :global(h1) {
flex: 1 1 auto;
}
.block-label {
font-size: var(--spectrum-global-dimension-font-size-75);
font-weight: 600;
color: var(--grey-7);
}
</style>

View File

@ -1,11 +1,20 @@
<script>
import { tables } from "stores/backend"
import { Select } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
export let value
const onChange = e => {
value = e.detail
dispatch("change", e.detail)
}
</script>
<Select
on:change={onChange}
bind:value
options={$tables.list}
getOptionLabel={table => table.name}

View File

@ -92,7 +92,7 @@
<ActionGroup />
</div>
<div class="toprightnav">
{#if $admin.sandbox}
{#if $admin.cloud}
<UpgradeModal />
{/if}
<VersionModal />

View File

@ -1,22 +1,50 @@
<script>
import { Heading, Body, Layout, Button, Modal } from "@budibase/bbui"
import { automationStore } from "builderStore"
import AutomationPanel from "components/automation/AutomationPanel/AutomationPanel.svelte"
import SetupPanel from "components/automation/SetupPanel/SetupPanel.svelte"
import CreateAutomationModal from "components/automation/AutomationPanel/CreateAutomationModal.svelte"
import CreateWebhookModal from "components/automation/shared/CreateWebhookModal.svelte"
$: automation = $automationStore.automations[0]
let modal
let webhookModal
</script>
<!-- routify:options index=3 -->
<div class="root">
<div class="nav">
<AutomationPanel />
<AutomationPanel {modal} {webhookModal} />
</div>
<div class="content">
<slot />
{#if automation}
<slot />
{:else}
<div class="centered">
<div class="main">
<Layout gap="S" justifyItems="center">
<svg
width="60px"
height="60px"
class="spectrum-Icon"
focusable="false"
>
<use xlink:href="#spectrum-icon-18-WorkflowAdd" />
</svg>
<Heading size="S">You have no automations</Heading>
<Body size="S">Let's fix that. Call the bots!</Body>
<Button on:click={() => modal.show()} size="S" cta
>Create automation</Button
>
</Layout>
</div>
</div>
{/if}
</div>
{#if $automationStore.selectedAutomation}
<div class="setup">
<SetupPanel />
</div>
{/if}
<Modal bind:this={modal}>
<CreateAutomationModal {webhookModal} />
</Modal>
<Modal bind:this={webhookModal} width="30%">
<CreateWebhookModal />
</Modal>
</div>
<style>
@ -24,7 +52,7 @@
flex: 1 1 auto;
height: 0;
display: grid;
grid-template-columns: 260px minmax(510px, 1fr) 260px;
grid-template-columns: 260px minmax(510px, 1fr);
}
.nav {
@ -48,16 +76,20 @@
gap: var(--spacing-l);
overflow: hidden;
}
.setup {
padding: var(--spectrum-global-dimension-size-200);
border-left: var(--border-light);
.centered {
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
gap: var(--spacing-l);
background-color: var(--background);
overflow-y: auto;
justify-content: center;
align-items: center;
}
.main {
width: 300px;
}
</style>

View File

@ -15,13 +15,3 @@
}
})
</script>
<i>Create your first automation to get started</i>
<style>
i {
font-size: var(--font-size-m);
color: var(--grey-5);
margin-top: 2px;
}
</style>

View File

@ -1,5 +1,5 @@
<script>
import { auth } from "stores/portal"
import { auth, admin } from "stores/portal"
import { onMount } from "svelte"
import { redirect } from "@roxi/routify"
@ -10,6 +10,11 @@
if ($auth.user && !$auth.user.forceResetPassword) {
$redirect("../")
}
// redirect to account portal for authentication in the cloud
if ($admin.cloud && $admin.accountPortalUrl) {
window.location.href = $admin.accountPortalUrl
}
})
</script>

View File

@ -12,6 +12,7 @@
} from "@budibase/bbui"
import ConfigChecklist from "components/common/ConfigChecklist.svelte"
import { organisation, auth } from "stores/portal"
import { admin as adminStore } from "stores/portal"
import { onMount } from "svelte"
import UpdateUserInfoModal from "components/settings/UpdateUserInfoModal.svelte"
import ChangePasswordModal from "components/settings/ChangePasswordModal.svelte"
@ -57,6 +58,16 @@
},
])
}
// add link to account portal if the user has access
if ($auth?.user?.account) {
menu = menu.concat([
{
title: "Account",
href: $adminStore.accountPortalUrl,
},
])
}
return menu
}

View File

@ -6,7 +6,8 @@ export function createAdminStore() {
const DEFAULT_CONFIG = {
loaded: false,
multiTenancy: false,
sandbox: false,
cloud: false,
accountPortalUrl: "",
onboardingProgress: 0,
checklist: {
apps: { checked: false },
@ -28,7 +29,7 @@ export function createAdminStore() {
const totalSteps = Object.keys(json).length
const completedSteps = Object.values(json).filter(x => x?.checked).length
await getFlags()
await getEnvironment()
admin.update(store => {
store.loaded = true
store.checklist = json
@ -43,20 +44,23 @@ export function createAdminStore() {
}
}
async function getFlags() {
async function getEnvironment() {
let multiTenancyEnabled = false
let sandbox = false
let cloud = false
let accountPortalUrl = ""
try {
const response = await api.get(`/api/system/flags`)
const response = await api.get(`/api/system/environment`)
const json = await response.json()
multiTenancyEnabled = json.multiTenancy
sandbox = json.sandbox
cloud = json.cloud
accountPortalUrl = json.accountPortalUrl
} catch (err) {
// just let it stay disabled
}
admin.update(store => {
store.multiTenancy = multiTenancyEnabled
store.sandbox = sandbox
store.cloud = cloud
store.accountPortalUrl = accountPortalUrl
return store
})
}

View File

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

View File

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

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "0.9.125-alpha.5",
"version": "0.9.125-alpha.6",
"description": "Budibase Web Server",
"main": "src/index.js",
"repository": {
@ -24,7 +24,9 @@
"lint": "eslint --fix src/",
"lint:fix": "yarn run format && yarn run lint",
"multi:enable": "node scripts/multiTenancy.js enable",
"multi:disable": "node scripts/multiTenancy.js disable"
"multi:disable": "node scripts/multiTenancy.js disable",
"selfhost:enable": "node scripts/selfhost.js enable",
"selfhost:disable": "node scripts/selfhost.js disable"
},
"jest": {
"preset": "ts-jest",
@ -61,9 +63,9 @@
"author": "Budibase",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@budibase/auth": "^0.9.125-alpha.5",
"@budibase/client": "^0.9.125-alpha.5",
"@budibase/string-templates": "^0.9.125-alpha.5",
"@budibase/auth": "^0.9.125-alpha.6",
"@budibase/client": "^0.9.125-alpha.6",
"@budibase/string-templates": "^0.9.125-alpha.6",
"@elastic/elasticsearch": "7.10.0",
"@koa/router": "8.0.0",
"@sendgrid/mail": "7.1.1",

View File

@ -0,0 +1,8 @@
#!/usr/bin/env node
const updateDotEnv = require("update-dotenv")
const arg = process.argv.slice(2)[0]
updateDotEnv({
SELF_HOSTED: arg === "enable" ? "1" : "0",
}).then(() => console.log("Updated server!"))

View File

@ -4,7 +4,7 @@ const { processStringSync } = require("@budibase/string-templates")
exports.definition = {
name: "Bash Scripting",
tagline: "Execute a bash command",
icon: "ri-terminal-box-line",
icon: "JourneyEvent",
description: "Run a bash script",
type: "ACTION",
internal: true,

View File

@ -6,7 +6,7 @@ const usage = require("../../utilities/usageQuota")
exports.definition = {
name: "Create Row",
tagline: "Create a {{inputs.enriched.table.name}} row",
icon: "ri-save-3-line",
icon: "SaveFloppy",
description: "Add a row to your database",
type: "ACTION",
internal: true,

View File

@ -2,7 +2,7 @@ let { wait } = require("../../utilities")
exports.definition = {
name: "Delay",
icon: "ri-time-line",
icon: "Clock",
tagline: "Delay for {{inputs.time}} milliseconds",
description: "Delay the automation until an amount of time has passed",
stepId: "DELAY",

View File

@ -4,7 +4,7 @@ const usage = require("../../utilities/usageQuota")
exports.definition = {
description: "Delete a row from your database",
icon: "ri-delete-bin-line",
icon: "DeleteOutline",
name: "Delete Row",
tagline: "Delete a {{inputs.enriched.table.name}} row",
type: "ACTION",

View File

@ -4,7 +4,7 @@ const { buildCtx } = require("./utils")
exports.definition = {
name: "External Data Connector",
tagline: "Execute Data Connector",
icon: "ri-database-2-line",
icon: "Data",
description: "Execute a query in an external data connector",
type: "ACTION",
stepId: "EXECUTE_QUERY",

View File

@ -4,7 +4,7 @@ const { buildCtx } = require("./utils")
exports.definition = {
name: "JS Scripting",
tagline: "Execute JavaScript Code",
icon: "ri-terminal-box-line",
icon: "Code",
description: "Run a piece of JavaScript code in your automation",
type: "ACTION",
internal: true,

View File

@ -18,7 +18,7 @@ exports.PrettyFilterConditions = PrettyFilterConditions
exports.definition = {
name: "Filter",
tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
icon: "ri-git-branch-line",
icon: "Branch2",
description: "Filter any automations which do not meet certain conditions",
type: "LOGIC",
internal: true,

View File

@ -20,7 +20,7 @@ const BODY_REQUESTS = [RequestType.POST, RequestType.PUT, RequestType.PATCH]
exports.definition = {
name: "Outgoing webhook",
tagline: "Send a {{inputs.requestMethod}} request",
icon: "ri-send-plane-line",
icon: "Send",
description: "Send a request of specified method to a URL",
type: "ACTION",
internal: true,

View File

@ -3,7 +3,7 @@ const { sendSmtpEmail } = require("../../utilities/workerRequests")
exports.definition = {
description: "Send an email using SMTP",
tagline: "Send SMTP email to {{inputs.to}}",
icon: "ri-mail-open-line",
icon: "Email",
name: "Send Email (SMTP)",
type: "ACTION",
internal: true,

View File

@ -7,7 +7,7 @@
exports.definition = {
name: "Backend log",
tagline: "Console log a value in the backend",
icon: "ri-server-line",
icon: "Monitoring",
description: "Logs the given text to the server (using console.log)",
type: "ACTION",
internal: true,

View File

@ -4,7 +4,7 @@ const automationUtils = require("../automationUtils")
exports.definition = {
name: "Update Row",
tagline: "Update a {{inputs.enriched.table.name}} row",
icon: "ri-refresh-line",
icon: "Refresh",
description: "Update a row in your database",
type: "ACTION",
internal: true,

View File

@ -1,7 +1,7 @@
exports.definition = {
name: "App Action",
event: "app:trigger",
icon: "ri-window-fill",
icon: "Apps",
tagline: "Automation fired from the frontend",
description: "Trigger an automation from an action inside your app",
stepId: "APP",

View File

@ -1,7 +1,7 @@
exports.definition = {
name: "Cron Trigger",
event: "cron:trigger",
icon: "ri-timer-line",
icon: "Clock",
tagline: "Cron Trigger (<b>{{inputs.cron}}</b>)",
description: "Triggers automation on a cron schedule.",
stepId: "CRON",

View File

@ -1,7 +1,7 @@
exports.definition = {
name: "Row Deleted",
event: "row:delete",
icon: "ri-delete-bin-line",
icon: "Delete",
tagline: "Row is deleted from {{inputs.enriched.table.name}}",
description: "Fired when a row is deleted from your database",
stepId: "ROW_DELETED",

View File

@ -1,7 +1,7 @@
exports.definition = {
name: "Row Created",
event: "row:save",
icon: "ri-save-line",
icon: "SaveFloppy",
tagline: "Row is added to {{inputs.enriched.table.name}}",
description: "Fired when a row is added to your database",
stepId: "ROW_SAVED",

View File

@ -1,7 +1,7 @@
exports.definition = {
name: "Row Updated",
event: "row:update",
icon: "ri-refresh-line",
icon: "Refresh",
tagline: "Row is updated in {{inputs.enriched.table.name}}",
description: "Fired when a row is updated in your database",
stepId: "ROW_UPDATED",

View File

@ -1,7 +1,7 @@
exports.definition = {
name: "Webhook",
event: "web:trigger",
icon: "ri-global-line",
icon: "Send",
tagline: "Webhook endpoint is hit",
description: "Trigger an automation when a HTTP POST webhook is hit",
stepId: "WEBHOOK",

View File

@ -152,7 +152,7 @@ module MySQLModule {
false
)
const tableNames = tablesResp.map(
(obj: any) => obj[`Tables_in_${database}`]
(obj: any) => obj[`Tables_in_${database.toLowerCase()}`]
)
for (let tableName of tableNames) {
const primaryKeys = []

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "0.9.125-alpha.5",
"version": "0.9.125-alpha.6",
"description": "Budibase background service",
"main": "src/index.js",
"repository": {
@ -18,13 +18,15 @@
"dev:builder": "npm run dev:stack:init && nodemon src/index.js",
"test": "jest --runInBand",
"multi:enable": "node scripts/multiTenancy.js enable",
"multi:disable": "node scripts/multiTenancy.js disable"
"multi:disable": "node scripts/multiTenancy.js disable",
"selfhost:enable": "node scripts/selfhost.js enable",
"selfhost:disable": "node scripts/selfhost.js disable"
},
"author": "Budibase",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@budibase/auth": "^0.9.125-alpha.5",
"@budibase/string-templates": "^0.9.125-alpha.5",
"@budibase/auth": "^0.9.125-alpha.6",
"@budibase/string-templates": "^0.9.125-alpha.6",
"@koa/router": "^8.0.0",
"@techpass/passport-openidconnect": "^0.3.0",
"aws-sdk": "^2.811.0",

View File

@ -21,6 +21,7 @@ async function init() {
COUCH_DB_PASSWORD: "budibase",
// empty string is false
MULTI_TENANCY: "",
ACCOUNT_PORTAL_URL: "http://localhost:3001",
}
let envFile = ""
Object.keys(envFileJson).forEach(key => {

View File

@ -0,0 +1,8 @@
#!/usr/bin/env node
const updateDotEnv = require("update-dotenv")
const arg = process.argv.slice(2)[0]
updateDotEnv({
SELF_HOSTED: arg === "enable" ? "1" : "0",
}).then(() => console.log("Updated worker!"))

View File

@ -196,6 +196,11 @@ exports.getSelf = async ctx => {
}
// this will set the body
await exports.find(ctx)
// append the account portal session information if present
if (ctx.user.account) {
ctx.body.account = ctx.user.account
}
}
exports.updateSelf = async ctx => {

View File

@ -3,6 +3,7 @@ const env = require("../../../environment")
exports.fetch = async ctx => {
ctx.body = {
multiTenancy: !!env.MULTI_TENANCY,
sandbox: !!env.SANDBOX,
cloud: !(env.SELF_HOSTED === "1"),
accountPortalUrl: env.ACCOUNT_PORTAL_URL,
}
}

View File

@ -44,7 +44,7 @@ const PUBLIC_ENDPOINTS = [
method: "POST",
},
{
route: "api/system/flags",
route: "api/system/environment",
method: "GET",
},
{

View File

@ -6,7 +6,7 @@ const emailRoutes = require("./global/email")
const authRoutes = require("./global/auth")
const roleRoutes = require("./global/roles")
const sessionRoutes = require("./global/sessions")
const flagRoutes = require("./system/flags")
const environmentRoutes = require("./system/environment")
const tenantsRoutes = require("./system/tenants")
const appRoutes = require("./app")
@ -21,5 +21,5 @@ exports.routes = [
emailRoutes,
sessionRoutes,
roleRoutes,
flagRoutes,
environmentRoutes,
]

View File

@ -0,0 +1,8 @@
const Router = require("@koa/router")
const controller = require("../../controllers/system/environment")
const router = Router()
router.get("/api/system/environment", controller.fetch)
module.exports = router

View File

@ -1,8 +0,0 @@
const Router = require("@koa/router")
const controller = require("../../controllers/system/flags")
const router = Router()
router.get("/api/system/flags", controller.fetch)
module.exports = router

View File

@ -32,7 +32,7 @@ module.exports = {
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
MULTI_TENANCY: process.env.MULTI_TENANCY,
SANDBOX: process.env.SANDBOX,
ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
_set(key, value) {
process.env[key] = value
module.exports[key] = value