Show notification when testing workflow rather than feedback box

This commit is contained in:
Andrew Kingston 2020-09-14 11:49:29 +01:00
parent 8db6122416
commit 5141353b33
1 changed files with 6 additions and 37 deletions

View File

@ -1,5 +1,4 @@
<script> <script>
import { fade } from "svelte/transition"
import { getContext } from "svelte" import { getContext } from "svelte"
import { backendUiStore, workflowStore } from "builderStore" import { backendUiStore, workflowStore } from "builderStore"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
@ -10,7 +9,6 @@
const { open, close } = getContext("simple-modal") const { open, close } = getContext("simple-modal")
let selectedTab = "SETUP" let selectedTab = "SETUP"
let testResult
$: workflow = $: workflow =
$workflowStore.selectedWorkflow && $workflowStore.selectedWorkflow.workflow $workflowStore.selectedWorkflow && $workflowStore.selectedWorkflow.workflow
@ -25,14 +23,17 @@
function deleteWorkflowBlock() { function deleteWorkflowBlock() {
workflowStore.actions.deleteWorkflowBlock($workflowStore.selectedBlock) workflowStore.actions.deleteWorkflowBlock($workflowStore.selectedBlock)
notifier.info("Workflow block deleted.")
} }
async function testWorkflow() { async function testWorkflow() {
const result = await workflowStore.actions.trigger({ const result = await workflowStore.actions.trigger({
workflow: $workflowStore.selectedWorkflow.workflow, workflow: $workflowStore.selectedWorkflow.workflow,
}) })
testResult = "Workflow passed" if (result.status === 200) {
notifier.success(`Workflow ${workflow.name} triggered successfully.`)
} else {
notifier.danger(`Failed to trigger workflow ${workflow.name}.`)
}
} }
async function saveWorkflow() { async function saveWorkflow() {
@ -49,10 +50,7 @@
<span <span
class="hoverable" class="hoverable"
class:selected={selectedTab === 'SETUP'} class:selected={selectedTab === 'SETUP'}
on:click={() => { on:click={() => (selectedTab = 'SETUP')}>
selectedTab = 'SETUP'
testResult = null
}}>
Setup Setup
</span> </span>
</header> </header>
@ -72,15 +70,6 @@
<b>{workflow.name}</b> <b>{workflow.name}</b>
</div> </div>
</div> </div>
{#if testResult}
<button
transition:fade|local
class:passed={true}
class:failed={false}
class="test-result">
{testResult}
</button>
{/if}
<Button secondary wide on:click={testWorkflow}>Test Workflow</Button> <Button secondary wide on:click={testWorkflow}>Test Workflow</Button>
<div class="buttons"> <div class="buttons">
<Button <Button
@ -159,24 +148,4 @@
font-weight: normal; font-weight: normal;
color: var(--ink); color: var(--ink);
} }
.test-result {
border: none;
width: 100%;
border-radius: 3px;
height: 32px;
font-size: 14px;
font-weight: 500;
color: var(--white);
text-align: center;
margin-bottom: 10px;
}
.passed {
background: var(--green);
}
.failed {
background: var(--red);
}
</style> </style>