Update automation section to use spectrum

This commit is contained in:
Andrew Kingston 2021-04-22 10:58:04 +01:00
parent 7cee3018d6
commit 5a3a661f99
13 changed files with 188 additions and 174 deletions

View File

@ -10,6 +10,8 @@
export let m = false export let m = false
export let l = false export let l = false
export let xl = false export let xl = false
export let hoverable = false
export let disabled = false
$: rotation = directions.indexOf(direction) * 45 $: rotation = directions.indexOf(direction) * 45
$: useDefault = ![s, m, l, xl].includes(true) $: useDefault = ![s, m, l, xl].includes(true)
@ -17,6 +19,8 @@
<svg <svg
on:click on:click
class:hoverable
class:disabled
class:spectrum-Icon--sizeS={s} class:spectrum-Icon--sizeS={s}
class:spectrum-Icon--sizeM={m || useDefault} class:spectrum-Icon--sizeM={m || useDefault}
class:spectrum-Icon--sizeL={l} class:spectrum-Icon--sizeL={l}
@ -28,3 +32,19 @@
style={`transform: rotate(${rotation}deg)`}> style={`transform: rotate(${rotation}deg)`}>
<use xlink:href="#spectrum-icon-18-{name}" /> <use xlink:href="#spectrum-icon-18-{name}" />
</svg> </svg>
<style>
svg.hoverable {
pointer-events: all;
transition: color var(--spectrum-global-animation-duration-100, 130ms);
}
svg.hoverable:hover {
color: var(--spectrum-alias-icon-color-selected);
cursor: pointer;
}
svg.disabled {
color: var(--spectrum-global-color-gray-500) !important;
pointer-events: none !important;
}
</style>

View File

@ -52,9 +52,9 @@
border-radius: var(--border-radius-m); border-radius: var(--border-radius-m);
transition: 0.3s all ease; transition: 0.3s all ease;
box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.08); box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.08);
background-color: var(--ink);
font-size: 16px; font-size: 16px;
color: var(--background); background-color: var(--spectrum-global-color-gray-50);
color: var(--grey-9);
} }
.block.selected, .block.selected,
.block:hover { .block:hover {
@ -77,9 +77,9 @@
header .label { header .label {
font-size: 14px; font-size: 14px;
padding: var(--spacing-s); padding: var(--spacing-s);
color: var(--grey-8);
border-radius: var(--border-radius-m); border-radius: var(--border-radius-m);
background-color: rgba(0, 0, 0, 0.05); background-color: var(--grey-2);
color: var(--grey-8);
} }
header i { header i {
font-size: 20px; font-size: 20px;
@ -93,22 +93,12 @@
} }
.ACTION { .ACTION {
background-color: var(--background);
color: var(--ink);
} }
.TRIGGER { .TRIGGER {
background-color: var(--ink);
color: var(--background);
}
.TRIGGER header .label {
background-color: var(--grey-9);
color: var(--grey-5);
} }
.LOGIC { .LOGIC {
background-color: var(--background);
color: var(--ink);
} }
p { p {

View File

@ -29,14 +29,13 @@
onConfirm={createAutomation} onConfirm={createAutomation}
disabled={!valid}> disabled={!valid}>
<Input bind:value={name} label="Name" /> <Input bind:value={name} label="Name" />
<div slot="footer">
<a <a
slot="footer"
target="_blank" target="_blank"
href="https://docs.budibase.com/automate/introduction-to-automate"> href="https://docs.budibase.com/automate/introduction-to-automate">
<i class="ri-information-line" /> <i class="ri-information-line" />
<span>Learn about automations</span> <span>Learn about automations</span>
</a> </a>
</div>
</ModalContent> </ModalContent>
<style> <style>

View File

@ -49,26 +49,22 @@
} }
</script> </script>
<div class="fields">
<div class="block-label">{block.name}</div> <div class="block-label">{block.name}</div>
{#each inputs as [key, value]} {#each inputs as [key, value]}
<div class="block-field"> <div class="block-field">
<Label extraSmall grey>{value.title}</Label> <Label>{value.title}</Label>
{#if value.type === 'string' && value.enum} {#if value.type === 'string' && value.enum}
<Select bind:value={block.inputs[key]} extraThin secondary> <Select
<option value="">Choose an option</option> bind:value={block.inputs[key]}
{#each value.enum as option, idx} options={value.enum}
<option value={option}> getOptionLabel={(x, idx) => (value.pretty ? value.pretty[idx] : x)} />
{value.pretty ? value.pretty[idx] : option}
</option>
{/each}
</Select>
{:else if value.customType === 'password'} {:else if value.customType === 'password'}
<Input type="password" extraThin bind:value={block.inputs[key]} /> <Input type="password" bind:value={block.inputs[key]} />
{:else if value.customType === 'email'} {:else if value.customType === 'email'}
<DrawerBindableInput <DrawerBindableInput
panel={AutomationBindingPanel} panel={AutomationBindingPanel}
type={'email'} type={'email'}
extraThin
value={block.inputs[key]} value={block.inputs[key]}
on:change={e => (block.inputs[key] = e.detail)} on:change={e => (block.inputs[key] = e.detail)}
{bindings} /> {bindings} />
@ -84,27 +80,33 @@
<DrawerBindableInput <DrawerBindableInput
panel={AutomationBindingPanel} panel={AutomationBindingPanel}
type={value.customType} type={value.customType}
extraThin
value={block.inputs[key]} value={block.inputs[key]}
on:change={e => (block.inputs[key] = e.detail)} on:change={e => (block.inputs[key] = e.detail)}
{bindings} /> {bindings} />
{/if} {/if}
</div> </div>
{/each} {/each}
</div>
{#if stepId === 'WEBHOOK'} {#if stepId === 'WEBHOOK'}
<Button secondary on:click={() => webhookModal.show()}> <Button secondary on:click={() => webhookModal.show()}>Set Up Webhook</Button>
Set Up Webhook
</Button>
{/if} {/if}
<style> <style>
.fields {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
gap: var(--spacing-s);
}
.block-field { .block-field {
display: grid; display: grid;
} }
.block-label { .block-label {
font-weight: 500; font-weight: 500;
font-size: var(--font-size-xs); font-size: var(--font-size-s);
color: var(--grey-7); color: var(--grey-7);
} }
</style> </style>

View File

@ -19,30 +19,24 @@
} }
</script> </script>
<div class="block-field"> <Select
<Select bind:value={value.tableId} extraThin secondary> bind:value={value.tableId}
<option value="">Choose an option</option> options={$tables.list}
{#each $tables.list as table} getOptionLabel={table => table.name}
<option value={table._id}>{table.name}</option> getOptionValue={table => table._id} />
{/each}
</Select>
</div>
{#if schemaFields.length} {#if schemaFields.length}
<div class="schema-fields"> <div class="schema-fields">
{#each schemaFields as [field, schema]} {#each schemaFields as [field, schema]}
{#if !schema.autocolumn} {#if !schema.autocolumn}
{#if schemaHasOptions(schema)} {#if schemaHasOptions(schema)}
<Select label={field} extraThin secondary bind:value={value[field]}> <Select
<option value="">Choose an option</option> label={field}
{#each schema.constraints.inclusion as option} bind:value={value[field]}
<option value={option}>{option}</option> options={schema.constraints.inclusion} />
{/each}
</Select>
{:else if schema.type === 'string' || schema.type === 'number'} {:else if schema.type === 'string' || schema.type === 'number'}
<DrawerBindableInput <DrawerBindableInput
panel={AutomationBindingPanel} panel={AutomationBindingPanel}
extraThin
value={value[field]} value={value[field]}
on:change={e => (value[field] = e.detail)} on:change={e => (value[field] = e.detail)}
label={field} label={field}
@ -57,8 +51,8 @@
<style> <style>
.schema-fields { .schema-fields {
display: grid; display: grid;
grid-gap: var(--spacing-xl); grid-gap: var(--spacing-s);
margin-top: var(--spacing-xl); margin-top: var(--spacing-s);
} }
.schema-fields :global(label) { .schema-fields :global(label) {
text-transform: capitalize; text-transform: capitalize;

View File

@ -6,6 +6,24 @@
name, name,
type, type,
})) }))
const typeOptions = [
{
label: "Text",
value: "string",
},
{
label: "Number",
value: "number",
},
{
label: "Boolean",
value: "boolean",
},
{
label: "DateTime",
value: "datetime",
},
]
function addField() { function addField() {
const newValue = { ...value } const newValue = { ...value }
@ -22,7 +40,7 @@
const fieldNameChanged = originalName => e => { const fieldNameChanged = originalName => e => {
// reconstruct using fieldsArray, so field order is preserved // reconstruct using fieldsArray, so field order is preserved
let entries = [...fieldsArray] let entries = [...fieldsArray]
const newName = e.target.value const newName = e.detail
if (newName) { if (newName) {
entries.find(f => f.name === originalName).name = newName entries.find(f => f.name === originalName).name = newName
} else { } else {
@ -46,16 +64,9 @@
placeholder="Enter field name" placeholder="Enter field name"
on:change={fieldNameChanged(field.name)} /> on:change={fieldNameChanged(field.name)} />
<Select <Select
secondary
extraThin
value={field.type} value={field.type}
on:blur={e => (value[field.name] = e.target.value)}> on:change={e => (value[field.name] = e.target.value)}
<option>string</option> options={typeOptions} />
<option>number</option>
<option>boolean</option>
<option>datetime</option>
</Select>
<i <i
class="remove-field ri-delete-bin-line" class="remove-field ri-delete-bin-line"
on:click={() => removeField(field.name)} /> on:click={() => removeField(field.name)} />

View File

@ -1,9 +1,8 @@
<script> <script>
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import { database } from "stores/backend" import { database } from "stores/backend"
import { notifications } from "@budibase/bbui" import { notifications, Icon, Button, Modal } from "@budibase/bbui"
import AutomationBlockSetup from "./AutomationBlockSetup.svelte" import AutomationBlockSetup from "./AutomationBlockSetup.svelte"
import { Button, Modal } from "@budibase/bbui"
import CreateWebookModal from "../Shared/CreateWebhookModal.svelte" import CreateWebookModal from "../Shared/CreateWebhookModal.svelte"
let webhookModal let webhookModal
@ -30,7 +29,9 @@
automation: $automationStore.selectedAutomation.automation, automation: $automationStore.selectedAutomation.automation,
}) })
if (result.status === 200) { if (result.status === 200) {
notifications.success(`Automation ${automation.name} triggered successfully.`) notifications.success(
`Automation ${automation.name} triggered successfully.`
)
} else { } else {
notifications.error(`Failed to trigger automation ${automation.name}.`) notifications.error(`Failed to trigger automation ${automation.name}.`)
} }
@ -47,17 +48,19 @@
<div class="title"> <div class="title">
<h1>Setup</h1> <h1>Setup</h1>
<i <Icon
class:highlighted={automationLive} l
class:hoverable={automationLive} disabled={!automationLive}
on:click={() => setAutomationLive(false)} hoverable={automationLive}
class="ri-stop-circle-fill" /> name="PauseCircle"
<i on:click={() => setAutomationLive(false)} />
class:highlighted={!automationLive} <Icon
class:hoverable={!automationLive} l
name="PlayCircle"
disabled={automationLive}
hoverable={!automationLive}
data-cy="activate-automation" data-cy="activate-automation"
on:click={() => setAutomationLive(true)} on:click={() => setAutomationLive(true)} />
class="ri-play-circle-fill" />
</div> </div>
{#if $automationStore.selectedBlock} {#if $automationStore.selectedBlock}
<AutomationBlockSetup <AutomationBlockSetup
@ -92,29 +95,10 @@
margin: 0; margin: 0;
flex: 1 1 auto; flex: 1 1 auto;
} }
.title i {
font-size: 20px;
color: var(--grey-5);
}
.title i.highlighted {
color: var(--ink);
}
.title i.hoverable:hover {
cursor: pointer;
color: var(--blue);
}
.block-label { .block-label {
font-size: var(--font-size-xs); font-size: var(--font-size-xs);
font-weight: 500; font-weight: 500;
color: var(--grey-7); color: var(--grey-7);
} }
.footer {
flex: 1 1 auto;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: stretch;
}
</style> </style>

View File

@ -5,11 +5,8 @@
export let value export let value
</script> </script>
<div class="block-field"> <Select
<Select bind:value secondary extraThin> bind:value
<option value="">Choose an option</option> options={$tables.list}
{#each $tables.list as table} getOptionLabel={table => table.name}
<option value={table._id}>{table.name}</option> getOptionValue={table => table._id} />
{/each}
</Select>
</div>

View File

@ -58,12 +58,13 @@
bindable value{propCount > 1 ? 's' : ''}. bindable value{propCount > 1 ? 's' : ''}.
</p> </p>
{/if} {/if}
<div slot="footer"> <a
<a target="_blank" href="https://docs.budibase.com/automate/steps/triggers"> slot="footer"
target="_blank"
href="https://docs.budibase.com/automate/steps/triggers">
<i class="ri-information-line" /> <i class="ri-information-line" />
<span>Learn about webhooks</span> <span>Learn about webhooks</span>
</a> </a>
</div>
</ModalContent> </ModalContent>
<style> <style>

View File

@ -1,6 +1,5 @@
<script> <script>
import { notifications } from "@budibase/bbui" import { Input, Icon, notifications } from "@budibase/bbui"
import { Input } from "@budibase/bbui"
import { store, hostingStore } from "builderStore" import { store, hostingStore } from "builderStore"
export let value export let value
@ -29,10 +28,10 @@
</script> </script>
<div> <div>
<Input disabled="true" thin value={fullWebhookURL(value)} /> <Input readonly value={fullWebhookURL(value)} />
<span on:click={() => copyToClipboard()}> <div class="icon" on:click={() => copyToClipboard()}>
<i class="ri-clipboard-line copy-icon" /> <Icon s name="Copy" />
</span> </div>
</div> </div>
<style> <style>
@ -40,26 +39,31 @@
position: relative; position: relative;
} }
div :global(input:disabled) { .icon {
color: var(--grey-7); right: 1px;
} bottom: 1px;
span {
position: absolute; position: absolute;
border: none;
border-radius: 50%;
height: 24px;
width: 24px;
background: var(--background);
right: var(--spacing-s);
bottom: 9px;
display: flex;
flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
display: flex;
flex-direction: row;
box-sizing: border-box;
border-left: 1px solid var(--spectrum-alias-border-color);
border-top-right-radius: var(--spectrum-alias-border-radius-regular);
border-bottom-right-radius: var(--spectrum-alias-border-radius-regular);
width: 31px;
color: var(--spectrum-alias-text-color);
background-color: var(--spectrum-global-color-gray-75);
transition: background-color
var(--spectrum-global-animation-duration-100, 130ms),
box-shadow var(--spectrum-global-animation-duration-100, 130ms),
border-color var(--spectrum-global-animation-duration-100, 130ms);
height: calc(var(--spectrum-alias-item-height-m) - 2px);
} }
.icon:hover {
span:hover { cursor: pointer;
background-color: var(--grey-3); color: var(--spectrum-alias-text-color-hover);
background-color: var(--spectrum-global-color-gray-50);
border-color: var(--spectrum-alias-border-color-hover);
} }
</style> </style>

View File

@ -6,7 +6,6 @@
} from "builderStore/dataBinding" } from "builderStore/dataBinding"
import BindingPanel from "components/design/PropertiesPanel/BindingPanel.svelte" import BindingPanel from "components/design/PropertiesPanel/BindingPanel.svelte"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
export let panel = BindingPanel export let panel = BindingPanel
export let value = "" export let value = ""
@ -14,9 +13,10 @@
export let thin = true export let thin = true
export let title = "Bindings" export let title = "Bindings"
export let placeholder export let placeholder
export let label
const dispatch = createEventDispatcher()
let bindingDrawer let bindingDrawer
$: tempValue = value $: tempValue = value
$: readableValue = runtimeToReadableBinding(bindings, value) $: readableValue = runtimeToReadableBinding(bindings, value)
@ -32,6 +32,7 @@
<div class="control"> <div class="control">
<Input <Input
{label}
value={readableValue} value={readableValue}
on:change={event => onChange(event.detail)} on:change={event => onChange(event.detail)}
{placeholder} /> {placeholder} />
@ -66,7 +67,6 @@
.icon { .icon {
right: 1px; right: 1px;
top: 1px;
bottom: 1px; bottom: 1px;
position: absolute; position: absolute;
justify-content: center; justify-content: center;
@ -84,6 +84,7 @@
var(--spectrum-global-animation-duration-100, 130ms), var(--spectrum-global-animation-duration-100, 130ms),
box-shadow var(--spectrum-global-animation-duration-100, 130ms), box-shadow var(--spectrum-global-animation-duration-100, 130ms),
border-color var(--spectrum-global-animation-duration-100, 130ms); border-color var(--spectrum-global-animation-duration-100, 130ms);
height: calc(var(--spectrum-alias-item-height-m) - 2px);
} }
.icon:hover { .icon:hover {
cursor: pointer; cursor: pointer;

View File

@ -37,12 +37,13 @@
{#if webhookUrls.length === 0} {#if webhookUrls.length === 0}
<h5>No webhooks found.</h5> <h5>No webhooks found.</h5>
{/if} {/if}
<div slot="footer"> <a
<a target="_blank" href="https://docs.budibase.com/automate/steps/triggers"> slot="footer"
target="_blank"
href="https://docs.budibase.com/automate/steps/triggers">
<i class="ri-information-line" /> <i class="ri-information-line" />
<span>Learn about webhooks</span> <span>Learn about webhooks</span>
</a> </a>
</div>
</ModalContent> </ModalContent>
<style> <style>

View File

@ -13,7 +13,7 @@
<slot /> <slot />
</div> </div>
{#if $automationStore.selectedAutomation} {#if $automationStore.selectedAutomation}
<div class="nav setup"> <div class="setup">
<SetupPanel /> <SetupPanel />
</div> </div>
{/if} {/if}
@ -45,4 +45,14 @@
gap: var(--spacing-l); gap: var(--spacing-l);
overflow: hidden; overflow: hidden;
} }
.setup {
padding: var(--spectrum-global-dimension-size-200);
border-left: var(--border-light);
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
gap: var(--spacing-l);
}
</style> </style>