Merge pull request #2902 from Budibase/bug/pc-ux-fixes

Some UX fixes for datasources and automations
This commit is contained in:
Peter Clement 2021-10-06 15:53:22 +01:00 committed by GitHub
commit ac1e476352
6 changed files with 65 additions and 53 deletions

View File

@ -17,7 +17,7 @@ export default class Automation {
this.automation.testData = data this.automation.testData = data
} }
addBlock(block) { addBlock(block, idx) {
// Make sure to add trigger if doesn't exist // Make sure to add trigger if doesn't exist
if (!this.hasTrigger() && block.type === "TRIGGER") { if (!this.hasTrigger() && block.type === "TRIGGER") {
const trigger = { id: generate(), ...block } const trigger = { id: generate(), ...block }
@ -26,10 +26,7 @@ export default class Automation {
} }
const newBlock = { id: generate(), ...block } const newBlock = { id: generate(), ...block }
this.automation.definition.steps = [ this.automation.definition.steps.splice(idx, 0, newBlock)
...this.automation.definition.steps,
newBlock,
]
return newBlock return newBlock
} }

View File

@ -104,9 +104,12 @@ const automationActions = store => ({
return state return state
}) })
}, },
addBlockToAutomation: block => { addBlockToAutomation: (block, blockIdx) => {
store.update(state => { store.update(state => {
const newBlock = state.selectedAutomation.addBlock(cloneDeep(block)) const newBlock = state.selectedAutomation.addBlock(
cloneDeep(block),
blockIdx
)
state.selectedBlock = newBlock state.selectedBlock = newBlock
return state return state
}) })

View File

@ -1,10 +1,9 @@
<script> <script>
import { ModalContent, Layout, Detail, Body, Icon } from "@budibase/bbui" import { ModalContent, Layout, Detail, Body, Icon } from "@budibase/bbui"
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import { database } from "stores/backend"
import { externalActions } from "./ExternalActions" import { externalActions } from "./ExternalActions"
$: instanceId = $database._id
export let blockIdx
let selectedAction let selectedAction
let actionVal let actionVal
let actions = Object.entries($automationStore.blockDefinitions.ACTION) let actions = Object.entries($automationStore.blockDefinitions.ACTION)
@ -39,7 +38,8 @@
) )
automationStore.actions.addBlockToAutomation(newBlock) automationStore.actions.addBlockToAutomation(newBlock)
await automationStore.actions.save( await automationStore.actions.save(
$automationStore.selectedAutomation?.automation $automationStore.selectedAutomation?.automation,
blockIdx
) )
} }
</script> </script>

View File

@ -4,9 +4,9 @@
import FlowItem from "./FlowItem.svelte" import FlowItem from "./FlowItem.svelte"
import TestDataModal from "./TestDataModal.svelte" import TestDataModal from "./TestDataModal.svelte"
import { flip } from "svelte/animate" import { flip } from "svelte/animate"
import { fade, fly } from "svelte/transition" import { fly } from "svelte/transition"
import { import {
Detail, Heading,
Icon, Icon,
ActionButton, ActionButton,
notifications, notifications,
@ -57,26 +57,24 @@
<div class="content"> <div class="content">
<div class="title"> <div class="title">
<div class="subtitle"> <div class="subtitle">
<Detail size="L">{automation.name}</Detail> <Heading size="S">{automation.name}</Heading>
<div <div style="display:flex;">
style="display:flex; <div class="iconPadding">
color: var(--spectrum-global-color-gray-400);"
>
<span class="iconPadding">
<div class="icon"> <div class="icon">
<Icon <Icon
on:click={confirmDeleteDialog.show} on:click={confirmDeleteDialog.show}
hoverable hoverable
size="M"
name="DeleteOutline" name="DeleteOutline"
/> />
</div> </div>
</span> </div>
<ActionButton <ActionButton
on:click={() => { on:click={() => {
testDataModal.show() testDataModal.show()
}} }}
icon="MultipleCheck" icon="MultipleCheck"
size="S">Run test</ActionButton size="M">Run test</ActionButton
> >
</div> </div>
</div> </div>
@ -84,16 +82,11 @@
{#each blocks as block, idx (block.id)} {#each blocks as block, idx (block.id)}
<div <div
class="block" class="block"
animate:flip={{ duration: 800 }} animate:flip={{ duration: 500 }}
in:fade|local in:fly|local={{ x: 500, duration: 1500 }}
out:fly|local={{ x: 500 }} out:fly|local={{ x: 500, duration: 800 }}
> >
<FlowItem {testDataModal} {testAutomation} {onSelect} {block} /> <FlowItem {testDataModal} {testAutomation} {onSelect} {block} />
{#if idx !== blocks.length - 1}
<div class="separator" />
<Icon name="AddCircle" size="S" />
<div class="separator" />
{/if}
</div> </div>
{/each} {/each}
</div> </div>
@ -114,14 +107,6 @@
</div> </div>
<style> <style>
.separator {
width: 1px;
height: 25px;
border-left: 1px dashed var(--grey-4);
color: var(--grey-4);
/* center horizontally */
align-self: center;
}
.canvas { .canvas {
margin: 0 -40px calc(-1 * var(--spacing-l)) -40px; margin: 0 -40px calc(-1 * var(--spacing-l)) -40px;
overflow-y: auto; overflow-y: auto;
@ -153,11 +138,14 @@
padding-bottom: var(--spacing-xl); padding-bottom: var(--spacing-xl);
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center;
}
.iconPadding {
padding-top: var(--spacing-s);
} }
.icon { .icon {
cursor: pointer; cursor: pointer;
display: flex;
padding-right: var(--spacing-m); padding-right: var(--spacing-m);
} }
</style> </style>

View File

@ -14,7 +14,6 @@
import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte"
import ResultsModal from "./ResultsModal.svelte" import ResultsModal from "./ResultsModal.svelte"
import ActionModal from "./ActionModal.svelte" import ActionModal from "./ActionModal.svelte"
import { database } from "stores/backend"
import { externalActions } from "./ExternalActions" import { externalActions } from "./ExternalActions"
export let onSelect export let onSelect
@ -29,7 +28,6 @@
$: testResult = $automationStore.selectedAutomation.testResults?.steps.filter( $: testResult = $automationStore.selectedAutomation.testResults?.steps.filter(
step => step.stepId === block.stepId step => step.stepId === block.stepId
) )
$: instanceId = $database._id
$: isTrigger = block.type === "TRIGGER" $: isTrigger = block.type === "TRIGGER"
@ -40,6 +38,10 @@
$: blockIdx = steps.findIndex(step => step.id === block.id) $: blockIdx = steps.findIndex(step => step.id === block.id)
$: lastStep = !isTrigger && blockIdx + 1 === steps.length $: lastStep = !isTrigger && blockIdx + 1 === steps.length
$: totalBlocks =
$automationStore.selectedAutomation?.automation?.definition?.steps.length +
1
// Logic for hiding / showing the add button.first we check if it has a child // 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 // then we check to see whether its inputs have been commpleted
$: disableAddButton = isTrigger $: disableAddButton = isTrigger
@ -167,13 +169,24 @@
</Modal> </Modal>
<Modal bind:this={actionModal} width="30%"> <Modal bind:this={actionModal} width="30%">
<ActionModal bind:blockComplete /> <ActionModal {blockIdx} bind:blockComplete />
</Modal> </Modal>
<Modal bind:this={webhookModal} width="30%"> <Modal bind:this={webhookModal} width="30%">
<CreateWebhookModal /> <CreateWebhookModal />
</Modal> </Modal>
</div> </div>
<div class="separator" />
<Icon
on:click={() => actionModal.show()}
disabled={!hasCompletedInputs}
hoverable
name="AddCircle"
size="S"
/>
{#if isTrigger ? totalBlocks > 1 : blockIdx !== totalBlocks - 2}
<div class="separator" />
{/if}
<style> <style>
.center-items { .center-items {
@ -191,8 +204,7 @@
.block { .block {
width: 360px; width: 360px;
font-size: 16px; font-size: 16px;
background-color: var(--spectrum-alias-background-color-secondary); background-color: var(--background);
color: var(--grey-9);
border: 1px solid var(--spectrum-global-color-gray-300); border: 1px solid var(--spectrum-global-color-gray-300);
border-radius: 4px 4px 4px 4px; border-radius: 4px 4px 4px 4px;
} }
@ -200,4 +212,13 @@
.blockSection { .blockSection {
padding: var(--spacing-xl); padding: var(--spacing-xl);
} }
.separator {
width: 1px;
height: 25px;
border-left: 1px dashed var(--grey-4);
color: var(--grey-4);
/* center horizontally */
align-self: center;
}
</style> </style>

View File

@ -5,24 +5,29 @@
import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte" import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte"
import { datasources } from "stores/backend" import { datasources } from "stores/backend"
import { IntegrationNames } from "constants" import { IntegrationNames } from "constants"
import cloneDeep from "lodash/cloneDeepWith"
export let integration export let integration
export let modal
// kill the reference so the input isn't saved
let config = cloneDeep(integration)
function prepareData() { function prepareData() {
let datasource = {} let datasource = {}
let existingTypeCount = $datasources.list.filter( let existingTypeCount = $datasources.list.filter(
ds => ds.source == integration.type ds => ds.source == config.type
).length ).length
let baseName = IntegrationNames[integration.type] let baseName = IntegrationNames[config.type]
let name = let name =
existingTypeCount == 0 ? baseName : `${baseName}-${existingTypeCount + 1}` existingTypeCount == 0 ? baseName : `${baseName}-${existingTypeCount + 1}`
datasource.type = "datasource" datasource.type = "datasource"
datasource.source = integration.type datasource.source = config.type
datasource.config = integration.config datasource.config = config.config
datasource.name = name datasource.name = name
datasource.plus = integration.plus datasource.plus = config.plus
return datasource return datasource
} }
@ -48,9 +53,10 @@
</script> </script>
<ModalContent <ModalContent
title={`Connect to ${IntegrationNames[integration.type]}`} title={`Connect to ${IntegrationNames[config.type]}`}
onConfirm={() => saveDatasource()} onConfirm={() => saveDatasource()}
confirmText={integration.plus onCancel={() => modal.show()}
confirmText={config.plus
? "Fetch tables from database" ? "Fetch tables from database"
: "Save and continue to query"} : "Save and continue to query"}
cancelText="Back" cancelText="Back"
@ -62,10 +68,7 @@
</Body> </Body>
</Layout> </Layout>
<IntegrationConfigForm <IntegrationConfigForm schema={config.schema} integration={config.config} />
schema={integration.schema}
bind:integration={integration.config}
/>
</ModalContent> </ModalContent>
<style> <style>