@widgetic/workflows 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +122 -0
- package/README.md +304 -2
- package/dist/api/apiContext.d.ts +4 -0
- package/dist/api/apiContext.js +17 -0
- package/dist/api/types.d.ts +168 -0
- package/dist/api/types.js +3 -0
- package/dist/api/workflowsApi.d.ts +109 -0
- package/dist/api/workflowsApi.js +657 -0
- package/dist/components/Workflows.svelte +131 -0
- package/dist/components/Workflows.svelte.d.ts +4 -0
- package/dist/components/WorkflowsEmptyState.svelte +32 -0
- package/dist/components/WorkflowsEmptyState.svelte.d.ts +7 -0
- package/dist/components/WorkflowsHeader.svelte +14 -0
- package/dist/components/WorkflowsHeader.svelte.d.ts +18 -0
- package/dist/components/WorkflowsWorkspace.svelte +87 -0
- package/dist/components/WorkflowsWorkspace.svelte.d.ts +14 -0
- package/dist/components/canvas/AddBlockMenu.svelte +101 -0
- package/dist/components/canvas/AddBlockMenu.svelte.d.ts +5 -0
- package/dist/components/canvas/CanvasToolbar.svelte +95 -0
- package/dist/components/canvas/CanvasToolbar.svelte.d.ts +9 -0
- package/dist/components/canvas/CompositionNodeView.svelte +125 -0
- package/dist/components/canvas/CompositionNodeView.svelte.d.ts +5 -0
- package/dist/components/canvas/ConditionNodeView.svelte +95 -0
- package/dist/components/canvas/ConditionNodeView.svelte.d.ts +5 -0
- package/dist/components/canvas/HandlePoint.svelte +32 -0
- package/dist/components/canvas/HandlePoint.svelte.d.ts +14 -0
- package/dist/components/canvas/TriggerNodeView.svelte +75 -0
- package/dist/components/canvas/TriggerNodeView.svelte.d.ts +5 -0
- package/dist/components/canvas/WorkflowCanvas.svelte +380 -0
- package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +25 -0
- package/dist/components/canvas/WorkflowEdgeView.svelte +58 -0
- package/dist/components/canvas/WorkflowEdgeView.svelte.d.ts +4 -0
- package/dist/components/editor/EditorBanners.svelte +143 -0
- package/dist/components/editor/EditorBanners.svelte.d.ts +7 -0
- package/dist/components/editor/EditorCanvasArea.svelte +85 -0
- package/dist/components/editor/EditorCanvasArea.svelte.d.ts +3 -0
- package/dist/components/editor/EditorTabs.svelte +81 -0
- package/dist/components/editor/EditorTabs.svelte.d.ts +7 -0
- package/dist/components/editor/EditorTopBar.svelte +132 -0
- package/dist/components/editor/EditorTopBar.svelte.d.ts +9 -0
- package/dist/components/editor/RunsTab.svelte +256 -0
- package/dist/components/editor/RunsTab.svelte.d.ts +3 -0
- package/dist/components/editor/SettingsTab.svelte +180 -0
- package/dist/components/editor/SettingsTab.svelte.d.ts +7 -0
- package/dist/components/editor/WorkflowEditor.svelte +185 -0
- package/dist/components/editor/WorkflowEditor.svelte.d.ts +15 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/list/CreateWorkflowDialog.svelte +89 -0
- package/dist/components/list/CreateWorkflowDialog.svelte.d.ts +9 -0
- package/dist/components/list/WorkflowList.svelte +204 -0
- package/dist/components/list/WorkflowList.svelte.d.ts +12 -0
- package/dist/components/list/WorkflowRow.svelte +191 -0
- package/dist/components/list/WorkflowRow.svelte.d.ts +10 -0
- package/dist/components/panel/BlockProblems.svelte +47 -0
- package/dist/components/panel/BlockProblems.svelte.d.ts +6 -0
- package/dist/components/panel/CompositionForm.svelte +127 -0
- package/dist/components/panel/CompositionForm.svelte.d.ts +7 -0
- package/dist/components/panel/CompositionPicker.svelte +179 -0
- package/dist/components/panel/CompositionPicker.svelte.d.ts +14 -0
- package/dist/components/panel/ConditionForm.svelte +105 -0
- package/dist/components/panel/ConditionForm.svelte.d.ts +7 -0
- package/dist/components/panel/EventValueRow.svelte +85 -0
- package/dist/components/panel/EventValueRow.svelte.d.ts +12 -0
- package/dist/components/panel/NextStepSelect.svelte +70 -0
- package/dist/components/panel/NextStepSelect.svelte.d.ts +12 -0
- package/dist/components/panel/ProblemsList.svelte +101 -0
- package/dist/components/panel/ProblemsList.svelte.d.ts +3 -0
- package/dist/components/panel/RuleCard.svelte +191 -0
- package/dist/components/panel/RuleCard.svelte.d.ts +13 -0
- package/dist/components/panel/SidePanel.svelte +82 -0
- package/dist/components/panel/SidePanel.svelte.d.ts +3 -0
- package/dist/components/panel/TestRow.svelte +150 -0
- package/dist/components/panel/TestRow.svelte.d.ts +15 -0
- package/dist/components/panel/TestRunPanel.svelte +85 -0
- package/dist/components/panel/TestRunPanel.svelte.d.ts +3 -0
- package/dist/components/panel/TestTriggerCard.svelte +121 -0
- package/dist/components/panel/TestTriggerCard.svelte.d.ts +7 -0
- package/dist/components/panel/TriggerForm.svelte +385 -0
- package/dist/components/panel/TriggerForm.svelte.d.ts +7 -0
- package/dist/components/panel/VersionHistory.svelte +123 -0
- package/dist/components/panel/VersionHistory.svelte.d.ts +3 -0
- package/dist/components/ui/ActionButton.svelte +85 -0
- package/dist/components/ui/ActionButton.svelte.d.ts +27 -0
- package/dist/components/ui/ConfirmDialog.svelte +52 -0
- package/dist/components/ui/ConfirmDialog.svelte.d.ts +16 -0
- package/dist/components/ui/Icon.svelte +32 -0
- package/dist/components/ui/Icon.svelte.d.ts +9 -0
- package/dist/components/ui/Menu.svelte +211 -0
- package/dist/components/ui/Menu.svelte.d.ts +21 -0
- package/dist/components/ui/Modal.svelte +129 -0
- package/dist/components/ui/Modal.svelte.d.ts +13 -0
- package/dist/components/ui/Notice.svelte +36 -0
- package/dist/components/ui/Notice.svelte.d.ts +11 -0
- package/dist/components/ui/SelectField.svelte +74 -0
- package/dist/components/ui/SelectField.svelte.d.ts +16 -0
- package/dist/components/ui/StatusBadge.svelte +41 -0
- package/dist/components/ui/StatusBadge.svelte.d.ts +9 -0
- package/dist/components/ui/TextField.svelte +97 -0
- package/dist/components/ui/TextField.svelte.d.ts +29 -0
- package/dist/components/ui/icons.d.ts +34 -0
- package/dist/components/ui/icons.js +54 -0
- package/dist/components/ui/types.d.ts +26 -0
- package/dist/components/ui/types.js +1 -0
- package/dist/editor/apiErrorText.d.ts +10 -0
- package/dist/editor/apiErrorText.js +53 -0
- package/dist/editor/autosave.d.ts +47 -0
- package/dist/editor/autosave.js +119 -0
- package/dist/editor/blockLabels.d.ts +91 -0
- package/dist/editor/blockLabels.js +196 -0
- package/dist/editor/canvasContext.d.ts +52 -0
- package/dist/editor/canvasContext.js +37 -0
- package/dist/editor/canvasWords.d.ts +24 -0
- package/dist/editor/canvasWords.js +40 -0
- package/dist/editor/capabilityModel.d.ts +46 -0
- package/dist/editor/capabilityModel.js +113 -0
- package/dist/editor/editorState.svelte.d.ts +220 -0
- package/dist/editor/editorState.svelte.js +713 -0
- package/dist/editor/flowAdapter.d.ts +59 -0
- package/dist/editor/flowAdapter.js +166 -0
- package/dist/editor/formatCount.d.ts +5 -0
- package/dist/editor/formatCount.js +15 -0
- package/dist/editor/graphDiff.d.ts +27 -0
- package/dist/editor/graphDiff.js +64 -0
- package/dist/editor/graphModel.d.ts +154 -0
- package/dist/editor/graphModel.js +457 -0
- package/dist/editor/issueText.d.ts +64 -0
- package/dist/editor/issueText.js +101 -0
- package/dist/editor/listState.svelte.d.ts +82 -0
- package/dist/editor/listState.svelte.js +250 -0
- package/dist/editor/statsRange.d.ts +26 -0
- package/dist/editor/statsRange.js +41 -0
- package/dist/editor/testRun.d.ts +36 -0
- package/dist/editor/testRun.js +74 -0
- package/dist/editor/zonedTime.d.ts +20 -0
- package/dist/editor/zonedTime.js +134 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/language.d.ts +22 -0
- package/dist/i18n/language.js +34 -0
- package/dist/i18n/messages.d.ts +423 -0
- package/dist/i18n/messages.js +446 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/types/index.d.ts +66 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.js +35 -0
- package/package.json +103 -5
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The line between two blocks. It is the one kind of line the canvas draws, and the reason it exists: kaykay's own line opens
|
|
3
|
+
a colour-and-style menu that is added to the end of the page, outside this screen's language, direction and styles. This
|
|
4
|
+
one only draws the line (kaykay's `BaseEdge`) and says what is true of it:
|
|
5
|
+
|
|
6
|
+
- a line the check found a problem with is red,
|
|
7
|
+
- the line that is selected, or that a test visitor followed, is green and a little thicker,
|
|
8
|
+
- in the Runs tab, the line is drawn thicker the more visitors followed it, with their number on it.
|
|
9
|
+
|
|
10
|
+
Colours are the palette's custom properties (`--color-*`), which the page or a ui-sdk theme sets, so the line follows the
|
|
11
|
+
theme like everything else on the screen.
|
|
12
|
+
-->
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import { BaseEdge } from 'kaykay';
|
|
15
|
+
import type { EdgeProps } from 'kaykay';
|
|
16
|
+
import { useCanvasContext } from '../../editor/canvasContext.js';
|
|
17
|
+
import { formatCount } from '../../editor/formatCount.js';
|
|
18
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
19
|
+
|
|
20
|
+
let { edge, path, selected, label_position, onselect }: EdgeProps = $props();
|
|
21
|
+
|
|
22
|
+
const { locale } = useWorkflowsLanguage();
|
|
23
|
+
const readContext = useCanvasContext();
|
|
24
|
+
|
|
25
|
+
const marks = $derived(readContext().marks);
|
|
26
|
+
const hasProblem = $derived(marks.hasEdgeProblem(edge.id));
|
|
27
|
+
const isTaken = $derived(marks.isEdgeTaken(edge.id));
|
|
28
|
+
const followCount = $derived(marks.followCountOf(edge.id));
|
|
29
|
+
|
|
30
|
+
const color = $derived(
|
|
31
|
+
hasProblem
|
|
32
|
+
? 'var(--color-error)'
|
|
33
|
+
: selected || isTaken
|
|
34
|
+
? 'var(--color-primary-green)'
|
|
35
|
+
: 'var(--color-ink-subtle)'
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
/** 2 pixels, 3 for a followed line; with counts, one more pixel for every power of ten of visitors, up to 6. */
|
|
39
|
+
const strokeWidth = $derived.by(() => {
|
|
40
|
+
if (followCount !== null)
|
|
41
|
+
return followCount <= 0 ? 2 : Math.min(6, 2 + Math.log10(followCount + 1));
|
|
42
|
+
return isTaken ? 3 : 2;
|
|
43
|
+
});
|
|
44
|
+
const label = $derived(
|
|
45
|
+
followCount !== null && followCount > 0 ? formatCount(followCount, $locale) : undefined
|
|
46
|
+
);
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<BaseEdge
|
|
50
|
+
{path}
|
|
51
|
+
{selected}
|
|
52
|
+
{color}
|
|
53
|
+
stroke_width={strokeWidth}
|
|
54
|
+
{label}
|
|
55
|
+
{label_position}
|
|
56
|
+
label_background={label !== undefined}
|
|
57
|
+
onclick={onselect}
|
|
58
|
+
/>
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The lines above the canvas that say where the workflow stands and what can be done about it: something went wrong with
|
|
3
|
+
saving, a version is being looked at, the workflow is archived or paused, the draft holds changes that are not live yet, or
|
|
4
|
+
it was never published. Each line that asks for an answer has its button at its end.
|
|
5
|
+
|
|
6
|
+
A line that tells what just happened (published, restored) goes away by itself after a few seconds, and can be closed.
|
|
7
|
+
-->
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
10
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
11
|
+
import ActionButton from '../ui/ActionButton.svelte';
|
|
12
|
+
import ConfirmDialog from '../ui/ConfirmDialog.svelte';
|
|
13
|
+
import Notice from '../ui/Notice.svelte';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
/** The person pressed "Publish changes". */
|
|
17
|
+
onpublish: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let { onpublish }: Props = $props();
|
|
21
|
+
|
|
22
|
+
const editor = useEditorState();
|
|
23
|
+
const { t } = useWorkflowsLanguage();
|
|
24
|
+
|
|
25
|
+
let isAskingToDiscard = $state(false);
|
|
26
|
+
|
|
27
|
+
const hasUnpublishedChanges = $derived(
|
|
28
|
+
(editor.status === 'live' || editor.status === 'paused') &&
|
|
29
|
+
editor.hasChangesToPublish &&
|
|
30
|
+
editor.viewing === null
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
async function discard(): Promise<void> {
|
|
34
|
+
await editor.discardChanges();
|
|
35
|
+
isAskingToDiscard = false;
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<div class="flex flex-col gap-2">
|
|
40
|
+
{#if editor.notice}
|
|
41
|
+
{@const notice = editor.notice}
|
|
42
|
+
<Notice tone={notice.tone}>
|
|
43
|
+
{$t(notice.messageKey, notice.values)}
|
|
44
|
+
{#snippet action()}
|
|
45
|
+
<ActionButton variant="ghost" size="small" onclick={() => editor.dismissNotice()}
|
|
46
|
+
>{$t('workflows.common.dismiss')}</ActionButton
|
|
47
|
+
>
|
|
48
|
+
{/snippet}
|
|
49
|
+
</Notice>
|
|
50
|
+
{/if}
|
|
51
|
+
|
|
52
|
+
{#if editor.saveState === 'conflict'}
|
|
53
|
+
<Notice tone="problem">
|
|
54
|
+
{$t('workflows.banner.conflict')}
|
|
55
|
+
{#snippet action()}
|
|
56
|
+
<ActionButton size="small" onclick={() => void editor.reloadDraft()}
|
|
57
|
+
>{$t('workflows.banner.reload')}</ActionButton
|
|
58
|
+
>
|
|
59
|
+
{/snippet}
|
|
60
|
+
</Notice>
|
|
61
|
+
{:else if editor.saveState === 'failed'}
|
|
62
|
+
<Notice tone="problem">
|
|
63
|
+
{$t(editor.saveFailure ?? 'workflows.error.generic')}
|
|
64
|
+
{#snippet action()}
|
|
65
|
+
<ActionButton size="small" onclick={() => editor.retrySave()}
|
|
66
|
+
>{$t('workflows.error.retry')}</ActionButton
|
|
67
|
+
>
|
|
68
|
+
{/snippet}
|
|
69
|
+
</Notice>
|
|
70
|
+
{/if}
|
|
71
|
+
|
|
72
|
+
{#if editor.viewing}
|
|
73
|
+
<Notice>
|
|
74
|
+
{$t('workflows.history.viewing', { number: editor.viewing.versionNumber })}
|
|
75
|
+
{#snippet action()}
|
|
76
|
+
<ActionButton size="small" onclick={() => editor.leaveVersion()}
|
|
77
|
+
>{$t('workflows.history.backToDraft')}</ActionButton
|
|
78
|
+
>
|
|
79
|
+
{/snippet}
|
|
80
|
+
</Notice>
|
|
81
|
+
{:else if editor.status === 'archived'}
|
|
82
|
+
<Notice>
|
|
83
|
+
{$t('workflows.banner.archived')}
|
|
84
|
+
{#snippet action()}
|
|
85
|
+
<ActionButton
|
|
86
|
+
size="small"
|
|
87
|
+
disabled={editor.busy !== null}
|
|
88
|
+
onclick={() => void editor.changeState('unarchive')}
|
|
89
|
+
>{$t('workflows.settings.unarchive')}</ActionButton
|
|
90
|
+
>
|
|
91
|
+
{/snippet}
|
|
92
|
+
</Notice>
|
|
93
|
+
{:else if editor.status === 'paused'}
|
|
94
|
+
<Notice>
|
|
95
|
+
{$t('workflows.banner.paused')}
|
|
96
|
+
{#snippet action()}
|
|
97
|
+
<ActionButton
|
|
98
|
+
size="small"
|
|
99
|
+
disabled={editor.busy !== null}
|
|
100
|
+
onclick={() => void editor.changeState('resume')}
|
|
101
|
+
>{$t('workflows.settings.resume')}</ActionButton
|
|
102
|
+
>
|
|
103
|
+
{/snippet}
|
|
104
|
+
</Notice>
|
|
105
|
+
{/if}
|
|
106
|
+
|
|
107
|
+
{#if hasUnpublishedChanges}
|
|
108
|
+
<Notice>
|
|
109
|
+
{$t('workflows.banner.unpublishedChanges')}
|
|
110
|
+
{#snippet action()}
|
|
111
|
+
<ActionButton
|
|
112
|
+
size="small"
|
|
113
|
+
disabled={editor.busy !== null}
|
|
114
|
+
onclick={() => (isAskingToDiscard = true)}>{$t('workflows.banner.discard')}</ActionButton
|
|
115
|
+
>
|
|
116
|
+
<ActionButton
|
|
117
|
+
variant="primary"
|
|
118
|
+
size="small"
|
|
119
|
+
disabled={!editor.canTryPublish}
|
|
120
|
+
onclick={onpublish}>{$t('workflows.banner.publishChanges')}</ActionButton
|
|
121
|
+
>
|
|
122
|
+
{/snippet}
|
|
123
|
+
</Notice>
|
|
124
|
+
{:else if editor.status === 'draft' && editor.viewing === null}
|
|
125
|
+
<Notice>{$t('workflows.banner.neverPublished')}</Notice>
|
|
126
|
+
{/if}
|
|
127
|
+
|
|
128
|
+
{#if editor.canvasTouchOnly && editor.tab === 'editor' && !editor.isReadOnly}
|
|
129
|
+
<Notice>{$t('workflows.banner.touchOnly')}</Notice>
|
|
130
|
+
{/if}
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
{#if isAskingToDiscard}
|
|
134
|
+
<ConfirmDialog
|
|
135
|
+
title={$t('workflows.banner.discardTitle')}
|
|
136
|
+
message={$t('workflows.banner.discardMessage')}
|
|
137
|
+
confirmLabel={$t('workflows.banner.discard')}
|
|
138
|
+
tone="danger"
|
|
139
|
+
busy={editor.busy === 'discarding'}
|
|
140
|
+
onconfirm={() => void discard()}
|
|
141
|
+
oncancel={() => (isAskingToDiscard = false)}
|
|
142
|
+
/>
|
|
143
|
+
{/if}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The Editor tab: the canvas with its tools laid over it, and the side panel beside it (below it on a narrow screen).
|
|
3
|
+
|
|
4
|
+
The canvas gives the editor a handle once it is on the screen; the editor uses it to apply changes made in the panel
|
|
5
|
+
and the menu, so those are steps that Undo takes back like a drag. What the blocks need to say in words, and the marks
|
|
6
|
+
on them (the start, problems, where the test visitor is), come from here.
|
|
7
|
+
-->
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import type { NodeStatus } from 'kaykay';
|
|
10
|
+
import type { CanvasContext, CanvasMarks } from '../../editor/canvasContext.js';
|
|
11
|
+
import { makeCanvasWords } from '../../editor/canvasWords.js';
|
|
12
|
+
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
13
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
14
|
+
import CanvasToolbar from '../canvas/CanvasToolbar.svelte';
|
|
15
|
+
import WorkflowCanvas from '../canvas/WorkflowCanvas.svelte';
|
|
16
|
+
import SidePanel from '../panel/SidePanel.svelte';
|
|
17
|
+
|
|
18
|
+
const editor = useEditorState();
|
|
19
|
+
const { t, locale } = useWorkflowsLanguage();
|
|
20
|
+
|
|
21
|
+
let toolbar = $state<ReturnType<typeof CanvasToolbar>>();
|
|
22
|
+
|
|
23
|
+
const words = $derived(
|
|
24
|
+
makeCanvasWords({
|
|
25
|
+
graph: editor.graph,
|
|
26
|
+
options: editor.options,
|
|
27
|
+
timeZone: editor.timezone,
|
|
28
|
+
locale: $locale,
|
|
29
|
+
t: $t
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
/** What the blocks and lines read; each answer is read while a block is drawn, so a change redraws only what shows it. */
|
|
34
|
+
const marks: CanvasMarks = {
|
|
35
|
+
get startNodeId() {
|
|
36
|
+
return editor.startNodeId;
|
|
37
|
+
},
|
|
38
|
+
problemCountOf: (nodeId) => editor.issuesOnCanvas.byNode.get(nodeId)?.length ?? 0,
|
|
39
|
+
hasEdgeProblem: (edgeId) => editor.issuesOnCanvas.byEdge.has(edgeId),
|
|
40
|
+
isEdgeTaken: (edgeId) => editor.testTakenEdgeIds.has(edgeId),
|
|
41
|
+
entryCountOf: () => null,
|
|
42
|
+
followCountOf: () => null,
|
|
43
|
+
failureCountOf: () => 0
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const context = $derived<CanvasContext>({ marks, words, readOnly: !editor.canEditCanvas });
|
|
47
|
+
|
|
48
|
+
/** Outlines: red for a block with a problem once a publish was tried, where the test visitor is, and what they passed. */
|
|
49
|
+
const statuses = $derived.by<Record<string, NodeStatus>>(() => {
|
|
50
|
+
const result: Record<string, NodeStatus> = {};
|
|
51
|
+
if (editor.problemsRevealed) {
|
|
52
|
+
for (const [nodeId, issues] of editor.issuesOnCanvas.byNode) {
|
|
53
|
+
if (issues.some((issue) => issue.severity === 'error')) result[nodeId] = 'error';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (const nodeId of editor.testPassedIds) result[nodeId] = 'completed';
|
|
57
|
+
const testNodeId = editor.testRun?.currentNodeId;
|
|
58
|
+
if (testNodeId) result[testNodeId] = 'running';
|
|
59
|
+
return result;
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<div class="flex min-h-0 flex-1 flex-col @3xl:flex-row">
|
|
64
|
+
<div class="min-h-80 min-w-0 flex-1 p-3">
|
|
65
|
+
<!-- The tools are laid over the canvas, in its own corner. -->
|
|
66
|
+
<div class="relative h-full min-h-0 w-full">
|
|
67
|
+
<WorkflowCanvas
|
|
68
|
+
initialGraph={editor.graph}
|
|
69
|
+
readContext={() => context}
|
|
70
|
+
readOnly={!editor.canEditCanvas}
|
|
71
|
+
{statuses}
|
|
72
|
+
onGraphChange={(graph) => editor.acceptCanvasGraph(graph)}
|
|
73
|
+
onSelectionChange={(nodeIds, edgeIds) => editor.followSelection(nodeIds, edgeIds)}
|
|
74
|
+
onAddBlockShortcut={() => toolbar?.openAddBlock()}
|
|
75
|
+
onReady={(handle) => (editor.canvas = handle)}
|
|
76
|
+
/>
|
|
77
|
+
<CanvasToolbar bind:this={toolbar} canEdit={!editor.isReadOnly} />
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
<div
|
|
81
|
+
class="flex max-h-[60%] min-h-0 shrink-0 flex-col border-t border-grey2 @3xl:max-h-none @3xl:w-96 @3xl:border-s @3xl:border-t-0"
|
|
82
|
+
>
|
|
83
|
+
<SidePanel />
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The three tabs of an open workflow: Editor (the canvas and its panel), Runs (how many visitors went where) and Settings
|
|
3
|
+
(time zone, pausing, archiving, the embed code).
|
|
4
|
+
|
|
5
|
+
It is a tab list by the book: one tab is in the tab order, the arrows move between tabs (and follow the way the page is
|
|
6
|
+
read, so in a right-to-left language the arrow that points at the next tab is the left one), Home and End go to the first
|
|
7
|
+
and the last, and a tab opens as soon as it is reached.
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import type { EditorTab } from '../../editor/editorState.svelte.js';
|
|
11
|
+
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
12
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
13
|
+
import type { WorkflowsMessageKey } from '../../i18n/messages.js';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
/** The id of the panel the tabs control; each tab's id is made from it. */
|
|
17
|
+
panelId: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let { panelId }: Props = $props();
|
|
21
|
+
|
|
22
|
+
const editor = useEditorState();
|
|
23
|
+
const { t } = useWorkflowsLanguage();
|
|
24
|
+
|
|
25
|
+
const TABS: ReadonlyArray<{ tab: EditorTab; labelKey: WorkflowsMessageKey }> = [
|
|
26
|
+
{ tab: 'editor', labelKey: 'workflows.tabs.editor' },
|
|
27
|
+
{ tab: 'runs', labelKey: 'workflows.tabs.runs' },
|
|
28
|
+
{ tab: 'settings', labelKey: 'workflows.tabs.settings' }
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
let tabListElement = $state<HTMLDivElement>();
|
|
32
|
+
|
|
33
|
+
function open(tab: EditorTab): void {
|
|
34
|
+
if (tab !== 'editor' && editor.viewing) editor.leaveVersion();
|
|
35
|
+
editor.tab = tab;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function handleKeydown(event: KeyboardEvent, index: number): void {
|
|
39
|
+
const isRightToLeft = tabListElement
|
|
40
|
+
? getComputedStyle(tabListElement).direction === 'rtl'
|
|
41
|
+
: false;
|
|
42
|
+
let nextIndex: number | null = null;
|
|
43
|
+
if (event.key === 'ArrowRight') nextIndex = index + (isRightToLeft ? -1 : 1);
|
|
44
|
+
else if (event.key === 'ArrowLeft') nextIndex = index + (isRightToLeft ? 1 : -1);
|
|
45
|
+
else if (event.key === 'Home') nextIndex = 0;
|
|
46
|
+
else if (event.key === 'End') nextIndex = TABS.length - 1;
|
|
47
|
+
if (nextIndex === null) return;
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
const target = TABS[(nextIndex + TABS.length) % TABS.length];
|
|
50
|
+
if (!target) return;
|
|
51
|
+
open(target.tab);
|
|
52
|
+
tabListElement?.querySelector<HTMLButtonElement>(`[data-tab="${target.tab}"]`)?.focus();
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<div
|
|
57
|
+
bind:this={tabListElement}
|
|
58
|
+
role="tablist"
|
|
59
|
+
aria-label={$t('workflows.tabs.label')}
|
|
60
|
+
class="flex gap-1 border-b border-grey2 px-4"
|
|
61
|
+
>
|
|
62
|
+
{#each TABS as item, index (item.tab)}
|
|
63
|
+
{@const isSelected = editor.tab === item.tab}
|
|
64
|
+
<button
|
|
65
|
+
type="button"
|
|
66
|
+
role="tab"
|
|
67
|
+
id="{panelId}-tab-{item.tab}"
|
|
68
|
+
data-tab={item.tab}
|
|
69
|
+
aria-selected={isSelected}
|
|
70
|
+
aria-controls={panelId}
|
|
71
|
+
tabindex={isSelected ? 0 : -1}
|
|
72
|
+
class="-mb-px border-b-2 px-3 py-2 text-sm focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-green {isSelected
|
|
73
|
+
? 'border-primary-green font-medium text-ink-primary'
|
|
74
|
+
: 'border-transparent text-ink-muted hover:text-ink-primary'}"
|
|
75
|
+
onclick={() => open(item.tab)}
|
|
76
|
+
onkeydown={(event) => handleKeydown(event, index)}
|
|
77
|
+
>
|
|
78
|
+
{$t(item.labelKey)}
|
|
79
|
+
</button>
|
|
80
|
+
{/each}
|
|
81
|
+
</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** The id of the panel the tabs control; each tab's id is made from it. */
|
|
3
|
+
panelId: string;
|
|
4
|
+
}
|
|
5
|
+
declare const EditorTabs: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type EditorTabs = ReturnType<typeof EditorTabs>;
|
|
7
|
+
export default EditorTabs;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The top of an open workflow: the way back to the list, the workflow's name (changed here), where it stands (draft, live,
|
|
3
|
+
paused, archived) and whether what was typed is saved, and the things to do with the draft: try it with a test visitor,
|
|
4
|
+
look at older versions, get the code that puts it on a page, publish.
|
|
5
|
+
|
|
6
|
+
Publish is available whenever there is something to publish; when the draft has problems it does not publish and shows
|
|
7
|
+
them (the blocks are outlined and the panel lists them), so a person is told what is missing instead of facing a button
|
|
8
|
+
that is dead for no visible reason.
|
|
9
|
+
-->
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import { MAX_WORKFLOW_NAME_LENGTH } from '../../api/types.js';
|
|
12
|
+
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
13
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
14
|
+
import type { WorkflowsMessageKey } from '../../i18n/messages.js';
|
|
15
|
+
import ActionButton from '../ui/ActionButton.svelte';
|
|
16
|
+
import Icon from '../ui/Icon.svelte';
|
|
17
|
+
import StatusBadge from '../ui/StatusBadge.svelte';
|
|
18
|
+
import TextField from '../ui/TextField.svelte';
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
onback: () => void;
|
|
22
|
+
onpublish: () => void;
|
|
23
|
+
/** Opens the embed code of this workflow; absent when the page that hosts the screen has no such dialog. */
|
|
24
|
+
onshowembedcode?: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let { onback, onpublish, onshowembedcode }: Props = $props();
|
|
28
|
+
|
|
29
|
+
const editor = useEditorState();
|
|
30
|
+
const { t } = useWorkflowsLanguage();
|
|
31
|
+
|
|
32
|
+
/** What is in the name box while it is being typed; it follows the workflow's name again whenever that changes. */
|
|
33
|
+
let nameDraft = $derived(editor.name);
|
|
34
|
+
|
|
35
|
+
const SAVE_STATE_KEYS = {
|
|
36
|
+
saved: 'workflows.save.saved',
|
|
37
|
+
pending: 'workflows.save.pending',
|
|
38
|
+
saving: 'workflows.save.saving',
|
|
39
|
+
failed: 'workflows.save.failed',
|
|
40
|
+
conflict: 'workflows.save.conflict'
|
|
41
|
+
} as const satisfies Record<typeof editor.saveState, WorkflowsMessageKey>;
|
|
42
|
+
|
|
43
|
+
const publishLabelKey = $derived<WorkflowsMessageKey>(
|
|
44
|
+
editor.busy === 'publishing'
|
|
45
|
+
? 'workflows.top.publishing'
|
|
46
|
+
: editor.status === 'draft'
|
|
47
|
+
? 'workflows.top.publish'
|
|
48
|
+
: 'workflows.top.publishChanges'
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
function commitName(): void {
|
|
52
|
+
if (nameDraft.trim() === '') {
|
|
53
|
+
// An empty name is not a name: put the old one back.
|
|
54
|
+
nameDraft = editor.name;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
editor.setName(nameDraft);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function toggleTestRun(): void {
|
|
61
|
+
if (editor.panel === 'test') editor.closeTestRun();
|
|
62
|
+
else editor.openTestRun();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function toggleHistory(): void {
|
|
66
|
+
if (editor.panel === 'history') editor.closeHistory();
|
|
67
|
+
else editor.openHistory();
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<div class="flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-grey2 px-4 py-3">
|
|
72
|
+
<ActionButton variant="ghost" size="small" onclick={onback}>
|
|
73
|
+
<Icon name="back" />
|
|
74
|
+
{$t('workflows.top.back')}
|
|
75
|
+
</ActionButton>
|
|
76
|
+
|
|
77
|
+
<div class="min-w-48 max-w-96 flex-1">
|
|
78
|
+
<TextField
|
|
79
|
+
label={$t('workflows.top.nameLabel')}
|
|
80
|
+
hideLabel
|
|
81
|
+
maxlength={MAX_WORKFLOW_NAME_LENGTH}
|
|
82
|
+
disabled={editor.isReadOnly}
|
|
83
|
+
bind:value={nameDraft}
|
|
84
|
+
onchange={commitName}
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div class="flex flex-col">
|
|
89
|
+
<StatusBadge
|
|
90
|
+
status={editor.status}
|
|
91
|
+
hasUnpublishedChanges={editor.workflow?.unpublishedChanges ?? false}
|
|
92
|
+
/>
|
|
93
|
+
<span class="text-xs text-ink-muted" role="status" aria-live="polite"
|
|
94
|
+
>{$t(SAVE_STATE_KEYS[editor.saveState])}</span
|
|
95
|
+
>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div class="ms-auto flex flex-wrap items-center gap-2">
|
|
99
|
+
<ActionButton
|
|
100
|
+
size="small"
|
|
101
|
+
pressed={editor.panel === 'test'}
|
|
102
|
+
disabled={editor.isReadOnly || editor.tab !== 'editor'}
|
|
103
|
+
onclick={toggleTestRun}
|
|
104
|
+
>
|
|
105
|
+
<Icon name="play" />
|
|
106
|
+
{$t('workflows.top.testRun')}
|
|
107
|
+
</ActionButton>
|
|
108
|
+
<ActionButton
|
|
109
|
+
size="small"
|
|
110
|
+
pressed={editor.panel === 'history'}
|
|
111
|
+
disabled={editor.tab !== 'editor'}
|
|
112
|
+
onclick={toggleHistory}
|
|
113
|
+
>
|
|
114
|
+
<Icon name="history" />
|
|
115
|
+
{$t('workflows.top.history')}
|
|
116
|
+
</ActionButton>
|
|
117
|
+
{#if onshowembedcode && editor.workflow?.everPublished}
|
|
118
|
+
<ActionButton size="small" onclick={onshowembedcode}>
|
|
119
|
+
<Icon name="code" />
|
|
120
|
+
{$t('workflows.top.embedCode')}
|
|
121
|
+
</ActionButton>
|
|
122
|
+
{/if}
|
|
123
|
+
<ActionButton
|
|
124
|
+
variant="primary"
|
|
125
|
+
size="small"
|
|
126
|
+
disabled={!editor.canTryPublish}
|
|
127
|
+
onclick={onpublish}
|
|
128
|
+
>
|
|
129
|
+
{$t(publishLabelKey)}
|
|
130
|
+
</ActionButton>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
onback: () => void;
|
|
3
|
+
onpublish: () => void;
|
|
4
|
+
/** Opens the embed code of this workflow; absent when the page that hosts the screen has no such dialog. */
|
|
5
|
+
onshowembedcode?: () => void;
|
|
6
|
+
}
|
|
7
|
+
declare const EditorTopBar: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type EditorTopBar = ReturnType<typeof EditorTopBar>;
|
|
9
|
+
export default EditorTopBar;
|