2020-05-27 22:51:32 +02:00
|
|
|
<script>
|
2020-06-01 22:31:55 +02:00
|
|
|
import { fade } from "svelte/transition"
|
2020-05-28 21:20:03 +02:00
|
|
|
import { onMount, getContext } from "svelte"
|
2020-05-27 22:51:32 +02:00
|
|
|
import { backendUiStore, workflowStore } from "builderStore"
|
2020-05-29 17:06:23 +02:00
|
|
|
import { notifier } from "@beyonk/svelte-notifications"
|
2020-05-27 22:51:32 +02:00
|
|
|
import api from "builderStore/api"
|
2020-05-28 21:20:03 +02:00
|
|
|
import WorkflowBlockSetup from "./WorkflowBlockSetup.svelte"
|
|
|
|
import DeleteWorkflowModal from "./DeleteWorkflowModal.svelte"
|
2020-05-27 22:51:32 +02:00
|
|
|
|
2020-05-28 21:20:03 +02:00
|
|
|
const { open, close } = getContext("simple-modal")
|
|
|
|
|
2020-06-02 12:08:53 +02:00
|
|
|
const ACCESS_LEVELS = [
|
|
|
|
{
|
|
|
|
name: "Admin",
|
2020-06-02 12:40:33 +02:00
|
|
|
key: "ADMIN",
|
2020-06-02 12:08:53 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Power User",
|
2020-06-02 12:40:33 +02:00
|
|
|
key: "POWER_USER",
|
|
|
|
},
|
|
|
|
]
|
2020-06-02 12:08:53 +02:00
|
|
|
|
2020-06-01 22:26:32 +02:00
|
|
|
let selectedTab = "SETUP"
|
|
|
|
let testResult
|
|
|
|
|
2020-05-29 17:06:23 +02:00
|
|
|
$: workflow =
|
|
|
|
$workflowStore.currentWorkflow && $workflowStore.currentWorkflow.workflow
|
2020-05-27 22:51:32 +02:00
|
|
|
$: workflowBlock = $workflowStore.selectedWorkflowBlock
|
|
|
|
|
|
|
|
function deleteWorkflow() {
|
2020-05-28 21:20:03 +02:00
|
|
|
open(
|
|
|
|
DeleteWorkflowModal,
|
|
|
|
{
|
|
|
|
onClosed: close,
|
|
|
|
},
|
|
|
|
{ styleContent: { padding: "0" } }
|
|
|
|
)
|
2020-05-27 22:51:32 +02:00
|
|
|
}
|
2020-05-28 21:20:03 +02:00
|
|
|
|
2020-05-27 22:51:32 +02:00
|
|
|
function deleteWorkflowBlock() {
|
|
|
|
workflowStore.actions.deleteWorkflowBlock(workflowBlock)
|
2020-05-29 17:06:23 +02:00
|
|
|
notifier.info("Workflow block deleted.")
|
2020-05-27 22:51:32 +02:00
|
|
|
}
|
2020-06-01 22:26:32 +02:00
|
|
|
|
|
|
|
function testWorkflow() {
|
|
|
|
testResult = "PASSED"
|
|
|
|
}
|
2020-06-04 21:23:46 +02:00
|
|
|
|
|
|
|
async function saveWorkflow() {
|
|
|
|
const workflow = $workflowStore.currentWorkflow.workflow
|
|
|
|
await workflowStore.actions.save({
|
|
|
|
instanceId: $backendUiStore.selectedDatabase._id,
|
|
|
|
workflow,
|
|
|
|
})
|
|
|
|
notifier.success(`Workflow ${workflow.name} saved.`)
|
|
|
|
}
|
2020-05-27 22:51:32 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<header>
|
2020-06-01 22:26:32 +02:00
|
|
|
<span
|
|
|
|
class="hoverable"
|
|
|
|
class:selected={selectedTab === 'SETUP'}
|
2020-06-01 22:31:55 +02:00
|
|
|
on:click={() => {
|
2020-06-01 22:26:32 +02:00
|
|
|
selectedTab = 'SETUP'
|
|
|
|
testResult = null
|
|
|
|
}}>
|
|
|
|
Setup
|
|
|
|
</span>
|
|
|
|
{#if !workflowBlock}
|
|
|
|
<span
|
2020-06-04 20:27:25 +02:00
|
|
|
class="test-tab"
|
2020-06-01 22:26:32 +02:00
|
|
|
class:selected={selectedTab === 'TEST'}
|
|
|
|
on:click={() => (selectedTab = 'TEST')}>
|
|
|
|
Test
|
|
|
|
</span>
|
|
|
|
{/if}
|
2020-05-27 22:51:32 +02:00
|
|
|
</header>
|
2020-06-01 22:26:32 +02:00
|
|
|
{#if selectedTab === 'TEST'}
|
|
|
|
<div class="uk-margin config-item">
|
|
|
|
{#if testResult}
|
|
|
|
<button
|
|
|
|
transition:fade
|
|
|
|
class:passed={testResult === 'PASSED'}
|
|
|
|
class:failed={testResult === 'FAILED'}
|
|
|
|
class="test-result">
|
|
|
|
{testResult}
|
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
<button class="workflow-button hoverable" on:click={testWorkflow}>
|
|
|
|
Test
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{#if selectedTab === 'SETUP'}
|
|
|
|
{#if workflowBlock}
|
|
|
|
<WorkflowBlockSetup {workflowBlock} />
|
2020-06-04 20:27:25 +02:00
|
|
|
<div class="buttons">
|
2020-06-04 21:23:46 +02:00
|
|
|
<button class="workflow-button hoverable" on:click={saveWorkflow}>
|
|
|
|
Save Workflow
|
|
|
|
</button>
|
2020-06-04 20:30:44 +02:00
|
|
|
<button
|
|
|
|
class="delete-workflow-button hoverable"
|
|
|
|
on:click={deleteWorkflowBlock}>
|
2020-06-04 20:27:25 +02:00
|
|
|
Delete Block
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-06-01 22:26:32 +02:00
|
|
|
{:else if $workflowStore.currentWorkflow}
|
2020-06-04 20:27:25 +02:00
|
|
|
<div class="panel">
|
|
|
|
<div class="panel-body">
|
|
|
|
<div class="block-label">Workflow: {workflow.name}</div>
|
|
|
|
<div class="config-item">
|
|
|
|
<label>Name</label>
|
|
|
|
<div class="form">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="budibase_input"
|
|
|
|
bind:value={workflow.name} />
|
|
|
|
</div>
|
2020-06-01 22:26:32 +02:00
|
|
|
</div>
|
2020-06-04 20:27:25 +02:00
|
|
|
<div class="config-item">
|
|
|
|
<label class="uk-form-label">User Access</label>
|
|
|
|
<div class="access-levels">
|
|
|
|
{#each ACCESS_LEVELS as { name, key }}
|
|
|
|
<span class="access-level">
|
|
|
|
<label>{name}</label>
|
|
|
|
<input class="uk-checkbox" type="checkbox" />
|
|
|
|
</span>
|
|
|
|
{/each}
|
|
|
|
</div>
|
2020-06-02 12:08:53 +02:00
|
|
|
</div>
|
2020-05-27 22:51:32 +02:00
|
|
|
</div>
|
2020-06-04 20:27:25 +02:00
|
|
|
<div class="buttons">
|
|
|
|
<button class="delete-workflow-button" on:click={deleteWorkflow}>
|
|
|
|
Delete Workflow
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-05-27 22:51:32 +02:00
|
|
|
</div>
|
2020-06-01 22:26:32 +02:00
|
|
|
{/if}
|
2020-05-29 17:06:23 +02:00
|
|
|
{/if}
|
2020-05-27 22:51:32 +02:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
section {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2020-05-29 17:06:23 +02:00
|
|
|
height: 100%;
|
2020-06-04 20:27:25 +02:00
|
|
|
justify-content: space-between;
|
2020-05-29 17:06:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.panel-body {
|
|
|
|
flex: 1;
|
2020-05-27 22:51:32 +02:00
|
|
|
}
|
|
|
|
|
2020-06-04 20:27:25 +02:00
|
|
|
.panel {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
|
|
|
|
2020-05-27 22:51:32 +02:00
|
|
|
header {
|
|
|
|
font-size: 20px;
|
2020-06-04 20:27:25 +02:00
|
|
|
font-weight: 700;
|
2020-05-27 22:51:32 +02:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-06-04 20:27:25 +02:00
|
|
|
margin-bottom: 18px;
|
|
|
|
color: var(--ink);
|
2020-05-27 22:51:32 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 22:26:32 +02:00
|
|
|
.selected {
|
2020-06-04 20:27:25 +02:00
|
|
|
color: var(--ink);
|
|
|
|
}
|
|
|
|
|
|
|
|
.block-label {
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 14px;
|
|
|
|
color: var(--ink);
|
|
|
|
margin: 0px 0px 16px 0px;
|
2020-05-27 22:51:32 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 22:26:32 +02:00
|
|
|
.config-item {
|
2020-06-04 20:27:25 +02:00
|
|
|
margin: 0px 0px 4px 0px;
|
|
|
|
padding: 12px;
|
2020-06-01 22:26:32 +02:00
|
|
|
background: var(--light-grey);
|
|
|
|
}
|
|
|
|
|
2020-06-04 20:27:25 +02:00
|
|
|
.budibase_input {
|
|
|
|
height: 35px;
|
|
|
|
width: 220px;
|
|
|
|
border-radius: 3px;
|
|
|
|
border: 1px solid var(--grey-dark);
|
|
|
|
text-align: left;
|
|
|
|
color: var(--ink);
|
|
|
|
font-size: 14px;
|
|
|
|
padding-left: 12px;
|
2020-06-04 20:30:44 +02:00
|
|
|
}
|
2020-06-04 20:27:25 +02:00
|
|
|
|
2020-06-01 22:26:32 +02:00
|
|
|
header > span {
|
2020-06-04 20:27:25 +02:00
|
|
|
color: var(--ink-lighter);
|
2020-06-01 22:26:32 +02:00
|
|
|
margin-right: 20px;
|
|
|
|
}
|
|
|
|
|
2020-06-04 20:27:25 +02:00
|
|
|
.form {
|
|
|
|
margin-top: 12px;
|
|
|
|
}
|
|
|
|
|
2020-05-27 22:51:32 +02:00
|
|
|
label {
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 14px;
|
2020-06-04 20:27:25 +02:00
|
|
|
color: var(--ink);
|
|
|
|
}
|
|
|
|
|
|
|
|
.buttons {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.delete-workflow-button {
|
|
|
|
cursor: pointer;
|
|
|
|
border: 1px solid var(--red);
|
|
|
|
border-radius: 3px;
|
|
|
|
width: 260px;
|
|
|
|
padding: 8px 16px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
background: var(--white);
|
|
|
|
color: var(--red);
|
|
|
|
font-size: 14px;
|
|
|
|
font-weight: 500;
|
|
|
|
transition: all 2ms;
|
|
|
|
align-self: flex-end;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.delete-workflow-button:hover {
|
|
|
|
background: var(--red);
|
|
|
|
border: 1px solid var(--red);
|
|
|
|
color: var(--white);
|
2020-05-27 22:51:32 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 22:26:32 +02:00
|
|
|
.workflow-button {
|
2020-06-04 20:27:25 +02:00
|
|
|
cursor: pointer;
|
|
|
|
border: 1px solid var(--grey-dark);
|
|
|
|
border-radius: 3px;
|
2020-05-27 22:51:32 +02:00
|
|
|
width: 100%;
|
2020-06-04 20:27:25 +02:00
|
|
|
padding: 8px 16px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
background: white;
|
|
|
|
color: var(--ink);
|
|
|
|
font-size: 14px;
|
2020-05-27 22:51:32 +02:00
|
|
|
font-weight: 500;
|
2020-06-04 20:27:25 +02:00
|
|
|
transition: all 2ms;
|
2020-06-04 21:23:46 +02:00
|
|
|
margin-bottom: 10px;
|
2020-05-27 22:51:32 +02:00
|
|
|
}
|
2020-06-01 22:26:32 +02:00
|
|
|
|
2020-06-02 12:08:53 +02:00
|
|
|
.workflow-button:hover {
|
2020-06-04 20:27:25 +02:00
|
|
|
background: var(--grey-light);
|
2020-06-02 12:08:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.access-level {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
margin-top: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.access-level label {
|
|
|
|
font-weight: normal;
|
2020-06-04 20:27:25 +02:00
|
|
|
color: var(--ink);
|
2020-06-02 12:08:53 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 22:26:32 +02:00
|
|
|
.test-result {
|
|
|
|
border: none;
|
|
|
|
width: 100%;
|
2020-06-04 20:27:25 +02:00
|
|
|
border-radius: 3px;
|
2020-06-01 22:26:32 +02:00
|
|
|
height: 32px;
|
2020-06-04 20:27:25 +02:00
|
|
|
font-size: 14px;
|
2020-06-01 22:26:32 +02:00
|
|
|
font-weight: 500;
|
|
|
|
color: var(--white);
|
|
|
|
text-align: center;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.passed {
|
2020-06-04 20:30:44 +02:00
|
|
|
background: #84c991;
|
2020-06-01 22:26:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.failed {
|
2020-06-04 20:27:25 +02:00
|
|
|
background: var(--red);
|
2020-06-01 22:26:32 +02:00
|
|
|
}
|
2020-05-27 22:51:32 +02:00
|
|
|
</style>
|