Update automations page to use new modal
This commit is contained in:
parent
50d8d12d5e
commit
927fc40454
|
@ -1,32 +1,23 @@
|
||||||
<script>
|
<script>
|
||||||
import Modal from "svelte-simple-modal"
|
import { onMount } from "svelte"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { automationStore } from "builderStore"
|
||||||
import { onMount, getContext } from "svelte"
|
|
||||||
import { backendUiStore, automationStore } from "builderStore"
|
|
||||||
import CreateAutomationModal from "./CreateAutomationModal.svelte"
|
import CreateAutomationModal from "./CreateAutomationModal.svelte"
|
||||||
import { Button } from "@budibase/bbui"
|
import { Button } from "@budibase/bbui"
|
||||||
|
import { Modal } from "components/common/Modal"
|
||||||
|
|
||||||
const { open, close } = getContext("simple-modal")
|
let modal
|
||||||
|
|
||||||
$: selectedAutomationId = $automationStore.selectedAutomation?.automation?._id
|
$: selectedAutomationId = $automationStore.selectedAutomation?.automation?._id
|
||||||
|
|
||||||
function newAutomation() {
|
|
||||||
open(
|
|
||||||
CreateAutomationModal,
|
|
||||||
{
|
|
||||||
onClosed: close,
|
|
||||||
},
|
|
||||||
{ styleContent: { padding: "0" } }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
automationStore.actions.fetch()
|
automationStore.actions.fetch()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<Button primary wide on:click={newAutomation}>Create New Automation</Button>
|
<Button primary wide on:click={() => modal.show()}>
|
||||||
|
Create New Automation
|
||||||
|
</Button>
|
||||||
<ul>
|
<ul>
|
||||||
{#each $automationStore.automations as automation}
|
{#each $automationStore.automations as automation}
|
||||||
<li
|
<li
|
||||||
|
@ -39,6 +30,9 @@
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
<Modal bind:this={modal}>
|
||||||
|
<CreateAutomationModal />
|
||||||
|
</Modal>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
section {
|
section {
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
import { store, backendUiStore, automationStore } from "builderStore"
|
import { store, backendUiStore, automationStore } from "builderStore"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import ActionButton from "components/common/ActionButton.svelte"
|
|
||||||
import { Input } from "@budibase/bbui"
|
import { Input } from "@budibase/bbui"
|
||||||
import analytics from "analytics"
|
import analytics from "analytics"
|
||||||
|
import { ModalTitle, ModalFooter } from "components/common/Modal"
|
||||||
export let onClosed
|
|
||||||
|
|
||||||
let name
|
let name
|
||||||
|
|
||||||
|
@ -13,71 +11,38 @@
|
||||||
$: instanceId = $backendUiStore.selectedDatabase._id
|
$: instanceId = $backendUiStore.selectedDatabase._id
|
||||||
$: appId = $store.appId
|
$: appId = $store.appId
|
||||||
|
|
||||||
|
function sleep(ms) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
setTimeout(resolve, ms)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function createAutomation() {
|
async function createAutomation() {
|
||||||
await automationStore.actions.create({
|
await automationStore.actions.create({
|
||||||
name,
|
name,
|
||||||
instanceId,
|
instanceId,
|
||||||
})
|
})
|
||||||
onClosed()
|
|
||||||
notifier.success(`Automation ${name} created.`)
|
notifier.success(`Automation ${name} created.`)
|
||||||
analytics.captureEvent("Automation Created", { name })
|
analytics.captureEvent("Automation Created", { name })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<ModalTitle>Create Automation</ModalTitle>
|
||||||
<header>
|
<Input bind:value={name} label="Name" />
|
||||||
<i class="ri-stackshare-line" />
|
<ModalFooter
|
||||||
<h3>Create Automation</h3>
|
confirmText="Create"
|
||||||
</header>
|
onConfirm={createAutomation}
|
||||||
<div class="content">
|
disabled={!valid}>
|
||||||
<Input bind:value={name} label="Name" />
|
<a
|
||||||
</div>
|
target="_blank"
|
||||||
<footer>
|
href="https://docs.budibase.com/automate/introduction-to-automate">
|
||||||
<a href="https://docs.budibase.com">
|
<i class="ri-information-line" />
|
||||||
<i class="ri-information-line" />
|
<span>Learn about automations</span>
|
||||||
<span>Learn about automations</span>
|
</a>
|
||||||
</a>
|
</ModalFooter>
|
||||||
<ActionButton secondary on:click={onClosed}>Cancel</ActionButton>
|
|
||||||
<ActionButton disabled={!valid} on:click={createAutomation}>
|
|
||||||
Save
|
|
||||||
</ActionButton>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.container {
|
a {
|
||||||
padding: var(--spacing-xl);
|
|
||||||
}
|
|
||||||
|
|
||||||
header {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: flex-start;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
header h3 {
|
|
||||||
font-size: var(--font-size-xl);
|
|
||||||
color: var(--ink);
|
|
||||||
font-weight: 600;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
header i {
|
|
||||||
margin-right: var(--spacing-m);
|
|
||||||
font-size: 28px;
|
|
||||||
color: var(--grey-6);
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
padding: var(--spacing-xl) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
display: grid;
|
|
||||||
grid-auto-flow: column;
|
|
||||||
grid-gap: var(--spacing-m);
|
|
||||||
grid-auto-columns: 3fr 1fr 1fr;
|
|
||||||
}
|
|
||||||
footer a {
|
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
@ -85,10 +50,10 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
footer a span {
|
a span {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
footer i {
|
i {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
margin-right: var(--spacing-m);
|
margin-right: var(--spacing-m);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
Loading…
Reference in New Issue