This commit is contained in:
Martin McKeaveney 2021-03-15 20:53:17 +00:00
commit f6bc83c4c7
17 changed files with 119 additions and 40 deletions

View File

@ -1,12 +1,9 @@
<script> <script>
import { automationStore, backendUiStore } from "builderStore" import { automationStore } from "builderStore"
import Flowchart from "./FlowChart/FlowChart.svelte" import Flowchart from "./FlowChart/FlowChart.svelte"
import BlockList from "./BlockList.svelte" import BlockList from "./BlockList.svelte"
$: automation = $automationStore.selectedAutomation?.automation $: automation = $automationStore.selectedAutomation?.automation
$: automationLive = automation?.live
$: instanceId = $backendUiStore.selectedDatabase._id
$: automationCount = $automationStore.automations?.length ?? 0
function onSelect(block) { function onSelect(block) {
automationStore.update(state => { automationStore.update(state => {
@ -19,14 +16,4 @@
{#if automation} {#if automation}
<BlockList /> <BlockList />
<Flowchart {automation} {onSelect} /> <Flowchart {automation} {onSelect} />
{:else if automationCount === 0} {/if}
<i>Create your first automation to get started</i>
{:else}<i>Select an automation to edit</i>{/if}
<style>
i {
font-size: var(--font-size-m);
color: var(--grey-5);
margin-top: 2px;
}
</style>

View File

@ -3,7 +3,6 @@
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import { DropdownMenu, Modal } from "@budibase/bbui" import { DropdownMenu, Modal } from "@budibase/bbui"
import { DropdownContainer, DropdownItem } from "components/common/Dropdowns" import { DropdownContainer, DropdownItem } from "components/common/Dropdowns"
import analytics from "analytics"
import CreateWebhookModal from "../Shared/CreateWebhookModal.svelte" import CreateWebhookModal from "../Shared/CreateWebhookModal.svelte"
$: hasTrigger = $automationStore.selectedAutomation.hasTrigger() $: hasTrigger = $automationStore.selectedAutomation.hasTrigger()

View File

@ -1,5 +1,6 @@
<script> <script>
import { onMount } from "svelte" import { onMount } from "svelte"
import { goto } from "@sveltech/routify"
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import NavItem from "components/common/NavItem.svelte" import NavItem from "components/common/NavItem.svelte"
import EditAutomationPopover from "./EditAutomationPopover.svelte" import EditAutomationPopover from "./EditAutomationPopover.svelte"
@ -9,6 +10,10 @@
onMount(() => { onMount(() => {
automationStore.actions.fetch() automationStore.actions.fetch()
}) })
function selectAutomation(automation) {
automationStore.actions.select(automation)
$goto(`./${automation._id}`)
}
</script> </script>
<div class="automations-list"> <div class="automations-list">
@ -18,7 +23,7 @@
icon="ri-stackshare-line" icon="ri-stackshare-line"
text={automation.name} text={automation.name}
selected={automation._id === selectedAutomationId} selected={automation._id === selectedAutomationId}
on:click={() => automationStore.actions.select(automation)}> on:click={() => selectAutomation(automation)}>
<EditAutomationPopover {automation} /> <EditAutomationPopover {automation} />
</NavItem> </NavItem>
{/each} {/each}

View File

@ -1,5 +1,6 @@
<script> <script>
import { store, backendUiStore, automationStore } from "builderStore" import { backendUiStore, automationStore } from "builderStore"
import { goto } from "@sveltech/routify"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import { Input, ModalContent } from "@budibase/bbui" import { Input, ModalContent } from "@budibase/bbui"
import analytics from "analytics" import analytics from "analytics"
@ -15,6 +16,7 @@
instanceId, instanceId,
}) })
notifier.success(`Automation ${name} created.`) notifier.success(`Automation ${name} created.`)
$goto(`./${$automationStore.selectedAutomation.automation._id}`)
analytics.captureEvent("Automation Created", { name }) analytics.captureEvent("Automation Created", { name })
} }
</script> </script>

View File

@ -1,4 +1,5 @@
<script> <script>
import { goto } from "@sveltech/routify"
import { automationStore, backendUiStore } from "builderStore" import { automationStore, backendUiStore } from "builderStore"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import { DropdownMenu } from "@budibase/bbui" import { DropdownMenu } from "@budibase/bbui"
@ -23,6 +24,7 @@
automation, automation,
}) })
notifier.success("Automation deleted.") notifier.success("Automation deleted.")
$goto('../automate')
} }
</script> </script>

View File

@ -4,7 +4,6 @@
import { TableNames } from "constants" import { TableNames } from "constants"
import EditTablePopover from "./popovers/EditTablePopover.svelte" import EditTablePopover from "./popovers/EditTablePopover.svelte"
import EditViewPopover from "./popovers/EditViewPopover.svelte" import EditViewPopover from "./popovers/EditViewPopover.svelte"
import { Switcher } from "@budibase/bbui"
import NavItem from "components/common/NavItem.svelte" import NavItem from "components/common/NavItem.svelte"
$: selectedView = $: selectedView =

View File

@ -80,6 +80,7 @@
} }
function showErrorReasonModal(err) { function showErrorReasonModal(err) {
if (!err) return
errorReason = err errorReason = err
errorReasonModal.show() errorReasonModal.show()
} }
@ -118,13 +119,11 @@
{#if deployment.status.toLowerCase() === 'pending'} {#if deployment.status.toLowerCase() === 'pending'}
<Spinner size="10" /> <Spinner size="10" />
{/if} {/if}
<div class={`deployment-status ${deployment.status}`}> <div on:click={() => showErrorReasonModal(deployment.err)} class={`deployment-status ${deployment.status}`}>
<span> <span>
{deployment.status} {deployment.status}
{#if deployment.status === DeploymentStatus.FAILURE} {#if deployment.status === DeploymentStatus.FAILURE}
<i <i class="ri-information-line"/>
class="ri-information-line"
on:click={() => showErrorReasonModal(deployment.err)} />
{/if} {/if}
</span> </span>
</div> </div>

View File

@ -19,6 +19,7 @@
const response = await api.put(`/api/keys/${key}`, { value }) const response = await api.put(`/api/keys/${key}`, { value })
const res = await response.json() const res = await response.json()
keys = { ...keys, ...res } keys = { ...keys, ...res }
notifier.success("API Key saved.")
} }
// Get Keys // Get Keys

View File

@ -1,6 +1,15 @@
<script> <script>
import { store } from "builderStore" import { automationStore } from "builderStore"
import { params } from "@sveltech/routify" import { params } from "@sveltech/routify"
store.actions.layouts.select($params.layout) if ($params.automation) {
const automation = $automationStore.automations.find(
m => m._id === $params.automation
)
if (automation) {
automationStore.actions.select(automation)
}
}
</script> </script>
<slot />

View File

@ -0,0 +1,6 @@
<script>
import AutomationBuilder from "components/automation/AutomationBuilder/AutomationBuilder.svelte"
</script>
<AutomationBuilder />

View File

@ -1,5 +1,26 @@
<script> <script>
import AutomationBuilder from "components/automation/AutomationBuilder/AutomationBuilder.svelte" import { goto, leftover } from "@sveltech/routify"
import { onMount } from 'svelte'
import { automationStore } from "builderStore"
onMount(async () => {
// navigate to first automation in list, if not already selected
if (
!$leftover &&
$automationStore.automations.length > 0 &&
(!$automationStore.selectedAutomation || !$automationStore.selectedAutomation?.automation?._id)
) {
$goto(`../${$automationStore.automations[0]._id}`)
}
})
</script> </script>
<AutomationBuilder /> <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,6 +1,6 @@
<script> <script>
import { params } from "@sveltech/routify" import { isActive, goto } from "@sveltech/routify"
import { Button, Switcher, Modal } from "@budibase/bbui" import { Switcher, Modal } from "@budibase/bbui"
import TableNavigator from "components/backend/TableNavigator/TableNavigator.svelte" import TableNavigator from "components/backend/TableNavigator/TableNavigator.svelte"
import DatasourceNavigator from "components/backend/DatasourceNavigator/DatasourceNavigator.svelte" import DatasourceNavigator from "components/backend/DatasourceNavigator/DatasourceNavigator.svelte"
import CreateDatasourceModal from "components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte" import CreateDatasourceModal from "components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte"
@ -17,7 +17,16 @@
}, },
] ]
let tab = $params.selectedDatasource ? "datasource" : "table" let tab = $isActive('./datasource') ? "datasource" : "table"
function selectFirstTableOrSource({ detail }) {
const type = detail.heading.key
if (type === 'datasource') {
$goto("./datasource")
} else {
$goto("./table")
}
}
let modal let modal
</script> </script>
@ -25,7 +34,7 @@
<!-- routify:options index=0 --> <!-- routify:options index=0 -->
<div class="root"> <div class="root">
<div class="nav"> <div class="nav">
<Switcher headings={tabs} bind:value={tab}> <Switcher headings={tabs} bind:value={tab} on:change={selectFirstTableOrSource}>
<div class="title"> <div class="title">
<i <i
data-cy={`new-${tab}`} data-cy={`new-${tab}`}

View File

@ -0,0 +1,15 @@
<script>
import { params } from "@sveltech/routify"
import { backendUiStore } from "builderStore"
if ($params.query) {
const query = $backendUiStore.queries.find(
m => m._id === $params.query
)
if (query) {
backendUiStore.actions.queries.select(query)
}
}
</script>
<slot />

View File

@ -2,12 +2,12 @@
import { params } from "@sveltech/routify" import { params } from "@sveltech/routify"
import { backendUiStore } from "builderStore" import { backendUiStore } from "builderStore"
if ($params.selectedDatasourceId) { if ($params.selectedDatasource) {
const datasource = $backendUiStore.datasources.find( const datasource = $backendUiStore.datasources.find(
m => m._id === $params.selectedDatasource m => m._id === $params.selectedDatasource
) )
if (datasource) { if (datasource) {
backendUiStore.actions.datasources.select(datasource) backendUiStore.actions.datasources.select(datasource._id)
} }
} }
</script> </script>

View File

@ -1,6 +1,6 @@
<script> <script>
import { goto, beforeUrlChange } from "@sveltech/routify" import { goto, beforeUrlChange } from "@sveltech/routify"
import { Button, Heading, Body, Spacer, Icon } from "@budibase/bbui" import { Button, Heading, Body, Spacer } from "@budibase/bbui"
import { backendUiStore } from "builderStore" import { backendUiStore } from "builderStore"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte" import IntegrationConfigForm from "components/backend/DatasourceNavigator/TableIntegrationMenu/IntegrationConfigForm.svelte"

View File

@ -0,0 +1,29 @@
<script>
import { backendUiStore } from "builderStore"
import { goto, leftover } from "@sveltech/routify"
import { onMount } from "svelte"
onMount(async () => {
// navigate to first table in list, if not already selected
// and this is the final url (i.e. no selectedTable)
if (
!$leftover &&
$backendUiStore.datasources.length > 0 && !$backendUiStore.selectedDatasourceId
) {
// this file routes as .../tables/index, so, go up one.
$goto(`../${$backendUiStore.datasources[0]._id}`)
}
})
</script>
{#if $backendUiStore.tables.length === 0}
<i>Connect your first datasource to start building.</i>
{:else}<i>Select a datasource to edit</i>{/if}
<style>
i {
font-size: var(--font-size-m);
color: var(--grey-5);
margin-top: 2px;
}
</style>

View File

@ -1,12 +1,8 @@
<script> <script>
import { store, backendUiStore } from "builderStore" import { backendUiStore } from "builderStore"
import { goto, leftover } from "@sveltech/routify" import { goto, leftover } from "@sveltech/routify"
import { onMount } from "svelte" import { onMount } from "svelte"
async function selectTable(table) {
backendUiStore.actions.tables.select(table)
}
onMount(async () => { onMount(async () => {
// navigate to first table in list, if not already selected // navigate to first table in list, if not already selected
// and this is the final url (i.e. no selectedTable) // and this is the final url (i.e. no selectedTable)