convert automation icons into toggle

This commit is contained in:
Maurits Lourens 2021-07-27 14:29:06 +02:00
parent 0dbec1f1a4
commit 0c006e1339
1 changed files with 7 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<script> <script>
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import { database } from "stores/backend" import { database } from "stores/backend"
import { notifications, Icon, Button, Modal, Heading } from "@budibase/bbui" import { notifications, Button, Modal, Heading, Toggle } from "@budibase/bbui"
import AutomationBlockSetup from "./AutomationBlockSetup.svelte" import AutomationBlockSetup from "./AutomationBlockSetup.svelte"
import CreateWebookModal from "../Shared/CreateWebhookModal.svelte" import CreateWebookModal from "../Shared/CreateWebhookModal.svelte"
@ -12,10 +12,10 @@
$: automationLive = automation?.live $: automationLive = automation?.live
function setAutomationLive(live) { function setAutomationLive(live) {
if (automation.live === live) { if (automationLive === live) {
return return
} }
automation.live = live automation.live = live;
automationStore.actions.save({ instanceId, automation }) automationStore.actions.save({ instanceId, automation })
if (live) { if (live) {
notifications.info(`Automation ${automation.name} enabled.`) notifications.info(`Automation ${automation.name} enabled.`)
@ -48,20 +48,11 @@
<div class="title"> <div class="title">
<Heading size="S">Setup</Heading> <Heading size="S">Setup</Heading>
<Icon <Toggle
l value={automationLive}
disabled={!automationLive} on:change={() => setAutomationLive(!automationLive)}
hoverable={automationLive}
name="PauseCircle"
on:click={() => setAutomationLive(false)}
/>
<Icon
l
name="PlayCircle"
disabled={automationLive}
hoverable={!automationLive}
data-cy="activate-automation" data-cy="activate-automation"
on:click={() => setAutomationLive(true)} text="Live"
/> />
</div> </div>
{#if $automationStore.selectedBlock} {#if $automationStore.selectedBlock}