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-06-24 13:41:26 +02:00
|
|
|
import { notifier } from "builderStore/store/notifications"
|
2020-05-28 21:20:03 +02:00
|
|
|
import WorkflowBlockSetup from "./WorkflowBlockSetup.svelte"
|
|
|
|
import DeleteWorkflowModal from "./DeleteWorkflowModal.svelte"
|
2020-06-26 15:32:45 +02:00
|
|
|
import { Button } from "@budibase/bbui"
|
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-24 12:22:18 +02:00
|
|
|
canExecute: true,
|
|
|
|
editable: false,
|
2020-06-02 12:08:53 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Power User",
|
2020-06-02 12:40:33 +02:00
|
|
|
key: "POWER_USER",
|
2020-06-24 12:22:18 +02:00
|
|
|
canExecute: true,
|
|
|
|
editable: false,
|
2020-06-02 12:40:33 +02:00
|
|
|
},
|
|
|
|
]
|
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}
|
2020-06-26 15:32:45 +02:00
|
|
|
<Button secondary wide on:click={testWorkflow}>
|
|
|
|
Test Workflow
|
|
|
|
</Button>
|
2020-06-01 22:26:32 +02:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{#if selectedTab === 'SETUP'}
|
|
|
|
{#if workflowBlock}
|
|
|
|
<WorkflowBlockSetup {workflowBlock} />
|
2020-06-04 20:27:25 +02:00
|
|
|
<div class="buttons">
|
2020-06-26 15:32:45 +02:00
|
|
|
<Button
|
|
|
|
green wide
|
2020-06-11 16:40:07 +02:00
|
|
|
data-cy="save-workflow-setup"
|
|
|
|
on:click={saveWorkflow}>
|
2020-06-04 21:23:46 +02:00
|
|
|
Save Workflow
|
2020-06-26 15:32:45 +02:00
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
red wide
|
2020-06-04 20:30:44 +02:00
|
|
|
on:click={deleteWorkflowBlock}>
|
2020-06-04 20:27:25 +02:00
|
|
|
Delete Block
|
2020-06-26 15:32:45 +02:00
|
|
|
</Button>
|
2020-06-04 20:27:25 +02:00
|
|
|
</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">
|
2020-06-24 12:22:18 +02:00
|
|
|
{#each ACCESS_LEVELS as level}
|
2020-06-04 20:27:25 +02:00
|
|
|
<span class="access-level">
|
2020-06-24 12:22:18 +02:00
|
|
|
<label>{level.name}</label>
|
2020-06-25 17:02:30 +02:00
|
|
|
<input
|
|
|
|
class="uk-checkbox"
|
|
|
|
type="checkbox"
|
|
|
|
disabled={!level.editable}
|
|
|
|
bind:checked={level.canExecute} />
|
2020-06-04 20:27:25 +02:00
|
|
|
</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">
|
2020-06-26 15:32:45 +02:00
|
|
|
<Button green wide
|
2020-06-24 12:26:46 +02:00
|
|
|
data-cy="save-workflow-setup"
|
|
|
|
on:click={saveWorkflow}>
|
|
|
|
Save Workflow
|
2020-06-26 15:32:45 +02:00
|
|
|
</Button>
|
|
|
|
<Button red wide on:click={deleteWorkflow}>
|
2020-06-04 20:27:25 +02:00
|
|
|
Delete Workflow
|
2020-06-26 15:32:45 +02:00
|
|
|
</Button>
|
2020-06-04 20:27:25 +02:00
|
|
|
</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 {
|
2020-06-26 15:32:45 +02:00
|
|
|
font-size: 18px;
|
2020-06-23 09:19:16 +02:00
|
|
|
font-weight: 600;
|
2020-06-26 15:32:45 +02:00
|
|
|
font-family: inter;
|
2020-05-27 22:51:32 +02:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-06-26 15:32:45 +02:00
|
|
|
margin-bottom: 20px;
|
2020-06-04 20:27:25 +02:00
|
|
|
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;
|
2020-06-26 15:32:45 +02:00
|
|
|
color: var(--grey-7);
|
|
|
|
margin-bottom: 20px;
|
2020-05-27 22:51:32 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 22:26:32 +02:00
|
|
|
.config-item {
|
2020-06-26 15:32:45 +02:00
|
|
|
margin-bottom: 20px;
|
2020-06-01 22:26:32 +02:00
|
|
|
}
|
|
|
|
|
2020-06-04 20:27:25 +02:00
|
|
|
.budibase_input {
|
2020-06-24 16:06:28 +02:00
|
|
|
height: 36px;
|
2020-06-23 22:29:18 +02:00
|
|
|
width: 244px;
|
2020-06-04 20:27:25 +02:00
|
|
|
border-radius: 3px;
|
2020-06-23 22:29:18 +02:00
|
|
|
background-color: var(--grey-2);
|
|
|
|
border: 1px solid var(--grey-2);
|
2020-06-04 20:27:25 +02:00
|
|
|
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-23 09:19:16 +02:00
|
|
|
color: var(--grey-5);
|
2020-06-01 22:26:32 +02:00
|
|
|
margin-right: 20px;
|
2020-06-26 15:32:45 +02:00
|
|
|
cursor: pointer;
|
2020-06-01 22:26:32 +02:00
|
|
|
}
|
|
|
|
|
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;
|
2020-06-26 15:32:45 +02:00
|
|
|
bottom: 20px;
|
|
|
|
display: grid;
|
2020-05-27 22:51:32 +02:00
|
|
|
width: 100%;
|
2020-06-26 15:32:45 +02:00
|
|
|
gap: 12px;
|
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-26 15:32:45 +02:00
|
|
|
background: var(--green);
|
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>
|