@widgetic/workflows 0.1.1 → 0.2.1
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/README.md +118 -46
- package/dist/api/apiContext.d.ts +4 -0
- package/dist/api/apiContext.js +17 -0
- package/dist/api/types.d.ts +201 -0
- package/dist/api/types.js +3 -0
- package/dist/api/workflowsApi.d.ts +133 -0
- package/dist/api/workflowsApi.js +763 -0
- package/dist/components/Workflows.svelte +43 -17
- package/dist/components/WorkflowsEmptyState.svelte +16 -5
- package/dist/components/WorkflowsEmptyState.svelte.d.ts +5 -16
- package/dist/components/WorkflowsHeader.svelte +2 -2
- package/dist/components/WorkflowsWorkspace.svelte +90 -0
- package/dist/components/WorkflowsWorkspace.svelte.d.ts +15 -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/ConflictBanner.svelte +78 -0
- package/dist/components/editor/ConflictBanner.svelte.d.ts +3 -0
- package/dist/components/editor/EditorBanners.svelte +141 -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/PresenceBanner.svelte +126 -0
- package/dist/components/editor/PresenceBanner.svelte.d.ts +3 -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 +198 -0
- package/dist/components/editor/WorkflowEditor.svelte.d.ts +17 -0
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.js +0 -2
- 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/editLeaseController.d.ts +162 -0
- package/dist/editor/editLeaseController.js +459 -0
- package/dist/editor/editorState.svelte.d.ts +277 -0
- package/dist/editor/editorState.svelte.js +862 -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/keepCopy.d.ts +41 -0
- package/dist/editor/keepCopy.js +52 -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/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +429 -4
- package/dist/i18n/messages.js +456 -8
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +41 -3
- package/package.json +5 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
What a person is told when a teammate is editing the workflow they opened, and what they can do about it.
|
|
3
|
+
|
|
4
|
+
- `blocked`: a choice is waiting. Take the editing over (the teammate's editing pauses, and what they saved stays), or
|
|
5
|
+
only look. It says who, in the person's own words: a named teammate, "you" in another window, or "someone". A person
|
|
6
|
+
whose own editing was taken is told so, which is not what a person who arrived to find it held is told.
|
|
7
|
+
- `readOnly`: the person chose to look. One line, with the way back: take over, or start editing once nobody is.
|
|
8
|
+
- anything else: nothing at all.
|
|
9
|
+
|
|
10
|
+
It shows what `editor.presence` says and reports the person's choices to the editor, which decides what they do (the
|
|
11
|
+
claim on editing, what is still allowed while it is held by another). Every word is in the catalog (`presence.*`).
|
|
12
|
+
-->
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
15
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
16
|
+
import ActionButton from '../ui/ActionButton.svelte';
|
|
17
|
+
|
|
18
|
+
const editor = useEditorState();
|
|
19
|
+
const { t } = useWorkflowsLanguage();
|
|
20
|
+
|
|
21
|
+
const presence = $derived(editor.presence);
|
|
22
|
+
|
|
23
|
+
// Who holds the editing, as the person is to read it: their own other window ("you"), a named teammate, or nobody named.
|
|
24
|
+
const holderIsYou = $derived(presence.holder?.isYou === true);
|
|
25
|
+
const holderName = $derived(presence.holder?.name ?? null);
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
{#if presence.phase === 'blocked'}
|
|
29
|
+
<!-- A choice is waiting: the screen only looks until the person makes it. -->
|
|
30
|
+
<div
|
|
31
|
+
role="alert"
|
|
32
|
+
data-workflows-presence="blocked"
|
|
33
|
+
class="flex flex-wrap items-start justify-between gap-x-4 gap-y-3 rounded-medium border border-grey2 bg-white px-3 py-2 text-start text-sm text-ink-primary"
|
|
34
|
+
>
|
|
35
|
+
<div class="flex min-w-0 flex-1 basis-60 flex-col gap-1">
|
|
36
|
+
<p class="font-medium break-words">
|
|
37
|
+
<!-- The heading: a claim that was this tab's and was taken says so; a tab that arrived to find it held does not. -->
|
|
38
|
+
{#if presence.lostIt}
|
|
39
|
+
{#if holderIsYou}
|
|
40
|
+
{$t('workflows.presence.lostTitleYou')}
|
|
41
|
+
{:else if holderName}
|
|
42
|
+
{$t('workflows.presence.lostTitleNamed', { name: holderName })}
|
|
43
|
+
{:else}
|
|
44
|
+
{$t('workflows.presence.lostTitle')}
|
|
45
|
+
{/if}
|
|
46
|
+
{:else if holderIsYou}
|
|
47
|
+
{$t('workflows.presence.blockedTitleYou')}
|
|
48
|
+
{:else if holderName}
|
|
49
|
+
{$t('workflows.presence.blockedTitleNamed', { name: holderName })}
|
|
50
|
+
{:else}
|
|
51
|
+
{$t('workflows.presence.blockedTitle')}
|
|
52
|
+
{/if}
|
|
53
|
+
</p>
|
|
54
|
+
<p class="text-xs text-ink-muted">
|
|
55
|
+
{presence.lostIt ? $t('workflows.presence.lostBody') : $t('workflows.presence.blockedBody')}
|
|
56
|
+
</p>
|
|
57
|
+
{#if presence.actionFailed}
|
|
58
|
+
<p class="text-xs text-error">{$t('workflows.presence.actionFailed')}</p>
|
|
59
|
+
{/if}
|
|
60
|
+
{#if presence.working}
|
|
61
|
+
<p class="text-xs text-ink-muted" role="status">{$t('workflows.presence.working')}</p>
|
|
62
|
+
{/if}
|
|
63
|
+
</div>
|
|
64
|
+
<div class="flex flex-wrap items-start gap-3">
|
|
65
|
+
<div class="flex max-w-48 flex-col items-start gap-1">
|
|
66
|
+
<ActionButton
|
|
67
|
+
variant="primary"
|
|
68
|
+
size="small"
|
|
69
|
+
disabled={presence.working}
|
|
70
|
+
onclick={() => editor.takeOverEditing()}
|
|
71
|
+
>
|
|
72
|
+
{$t('workflows.presence.takeOver')}
|
|
73
|
+
</ActionButton>
|
|
74
|
+
<span class="text-xs text-ink-muted">{$t('workflows.presence.takeOverHint')}</span>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="flex max-w-48 flex-col items-start gap-1">
|
|
77
|
+
<ActionButton size="small" disabled={presence.working} onclick={() => editor.lookOnly()}>
|
|
78
|
+
{$t('workflows.presence.lookOnly')}
|
|
79
|
+
</ActionButton>
|
|
80
|
+
<span class="text-xs text-ink-muted">{$t('workflows.presence.lookOnlyHint')}</span>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
{:else if presence.phase === 'readOnly'}
|
|
85
|
+
<div
|
|
86
|
+
role="status"
|
|
87
|
+
data-workflows-presence="readOnly"
|
|
88
|
+
class="flex flex-wrap items-center gap-x-3 gap-y-2 rounded-medium border border-grey2 bg-white px-3 py-2 text-start text-sm text-ink-primary"
|
|
89
|
+
>
|
|
90
|
+
<span class="min-w-0 flex-1 basis-60 break-words">
|
|
91
|
+
{#if presence.nobodyIsEditing}
|
|
92
|
+
{$t('workflows.presence.readOnlyFree')}
|
|
93
|
+
{:else if holderIsYou}
|
|
94
|
+
{$t('workflows.presence.readOnlyYou')}
|
|
95
|
+
{:else if holderName}
|
|
96
|
+
{$t('workflows.presence.readOnlyNamed', { name: holderName })}
|
|
97
|
+
{:else}
|
|
98
|
+
{$t('workflows.presence.readOnly')}
|
|
99
|
+
{/if}
|
|
100
|
+
</span>
|
|
101
|
+
{#if presence.actionFailed}
|
|
102
|
+
<span class="text-xs text-error">{$t('workflows.presence.actionFailed')}</span>
|
|
103
|
+
{/if}
|
|
104
|
+
{#if presence.working}
|
|
105
|
+
<span class="text-xs text-ink-muted">{$t('workflows.presence.working')}</span>
|
|
106
|
+
{/if}
|
|
107
|
+
{#if presence.nobodyIsEditing}
|
|
108
|
+
<ActionButton
|
|
109
|
+
variant="primary"
|
|
110
|
+
size="small"
|
|
111
|
+
disabled={presence.working}
|
|
112
|
+
onclick={() => editor.startEditing()}
|
|
113
|
+
>
|
|
114
|
+
{$t('workflows.presence.startEditing')}
|
|
115
|
+
</ActionButton>
|
|
116
|
+
{:else}
|
|
117
|
+
<ActionButton
|
|
118
|
+
size="small"
|
|
119
|
+
disabled={presence.working}
|
|
120
|
+
onclick={() => editor.takeOverEditing()}
|
|
121
|
+
>
|
|
122
|
+
{$t('workflows.presence.takeOver')}
|
|
123
|
+
</ActionButton>
|
|
124
|
+
{/if}
|
|
125
|
+
</div>
|
|
126
|
+
{/if}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Runs: the workflow as a read-only canvas, with the number of visitors on every composition, trigger and line, for a range of
|
|
3
|
+
days and one version (the live one to begin with). It answers "where do visitors go?" without ever showing a visitor: the
|
|
4
|
+
counts are numbers only (how many entered, how many followed a line, how many times a composition could not be shown), never
|
|
5
|
+
values and never people.
|
|
6
|
+
|
|
7
|
+
Counts are by UTC day, as the API keeps them, and say so.
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { onMount, untrack } from 'svelte';
|
|
11
|
+
import type { WorkflowGraph } from '@widgetic/workflows-engine';
|
|
12
|
+
import { useWorkflowsApi } from '../../api/apiContext.js';
|
|
13
|
+
import { isCancelled } from '../../api/workflowsApi.js';
|
|
14
|
+
import { pickApiErrorMessage } from '../../editor/apiErrorText.js';
|
|
15
|
+
import type { CanvasContext, CanvasMarks } from '../../editor/canvasContext.js';
|
|
16
|
+
import { makeCanvasWords } from '../../editor/canvasWords.js';
|
|
17
|
+
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
18
|
+
import type { CanvasHandle } from '../../editor/editorState.svelte.js';
|
|
19
|
+
import { RANGE_CHOICES_IN_DAYS, makeStatsRange, readRunCounts } from '../../editor/statsRange.js';
|
|
20
|
+
import type { RunCounts } from '../../editor/statsRange.js';
|
|
21
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
22
|
+
import type { WorkflowsMessageKey } from '../../i18n/messages.js';
|
|
23
|
+
import { workflowsError } from '../../utils/logger.js';
|
|
24
|
+
import WorkflowCanvas from '../canvas/WorkflowCanvas.svelte';
|
|
25
|
+
import ActionButton from '../ui/ActionButton.svelte';
|
|
26
|
+
import Icon from '../ui/Icon.svelte';
|
|
27
|
+
import Notice from '../ui/Notice.svelte';
|
|
28
|
+
import SelectField from '../ui/SelectField.svelte';
|
|
29
|
+
import type { SelectChoice } from '../ui/types.js';
|
|
30
|
+
|
|
31
|
+
const editor = useEditorState();
|
|
32
|
+
const api = useWorkflowsApi();
|
|
33
|
+
const { t, locale } = useWorkflowsLanguage();
|
|
34
|
+
|
|
35
|
+
/** What the canvas shows now: the version's blocks and the counts over them. */
|
|
36
|
+
interface Shown {
|
|
37
|
+
key: string;
|
|
38
|
+
graph: WorkflowGraph;
|
|
39
|
+
counts: RunCounts;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let rangeDays = $state('30');
|
|
43
|
+
/** The version the counts are for; empty is every version, drawn on the live one. */
|
|
44
|
+
let versionId = $state(editor.workflow?.liveVersion?.id ?? '');
|
|
45
|
+
let loadState = $state<'loading' | 'ready' | 'failed'>('loading');
|
|
46
|
+
let failureKey = $state.raw<WorkflowsMessageKey | null>(null);
|
|
47
|
+
let shown = $state.raw<Shown | null>(null);
|
|
48
|
+
let canvasHandle = $state.raw<CanvasHandle | null>(null);
|
|
49
|
+
|
|
50
|
+
let controller: AbortController | null = null;
|
|
51
|
+
|
|
52
|
+
const hasBeenPublished = $derived(
|
|
53
|
+
(editor.workflow?.liveVersion ?? null) !== null || (editor.versions?.length ?? 0) > 0
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const rangeChoices = $derived<SelectChoice[]>(
|
|
57
|
+
RANGE_CHOICES_IN_DAYS.map((days) => ({
|
|
58
|
+
value: String(days),
|
|
59
|
+
label: $t('workflows.runs.lastDays', { count: days })
|
|
60
|
+
}))
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const versionChoices = $derived<SelectChoice[]>([
|
|
64
|
+
...(editor.versions ?? []).map((version) => ({
|
|
65
|
+
value: version.id,
|
|
66
|
+
label: version.isLive
|
|
67
|
+
? $t('workflows.runs.versionLive', { number: version.versionNumber })
|
|
68
|
+
: $t('workflows.history.version', { number: version.versionNumber })
|
|
69
|
+
})),
|
|
70
|
+
{ value: '', label: $t('workflows.runs.allVersions') }
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
const startedText = $derived.by(() => {
|
|
74
|
+
const started = shown?.counts.started;
|
|
75
|
+
return started === null || started === undefined
|
|
76
|
+
? ''
|
|
77
|
+
: $t('workflows.runs.started', { count: started });
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const words = $derived(
|
|
81
|
+
shown
|
|
82
|
+
? makeCanvasWords({
|
|
83
|
+
graph: shown.graph,
|
|
84
|
+
options: editor.options,
|
|
85
|
+
timeZone: editor.timezone,
|
|
86
|
+
locale: $locale,
|
|
87
|
+
t: $t
|
|
88
|
+
})
|
|
89
|
+
: null
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const marks: CanvasMarks = {
|
|
93
|
+
get startNodeId() {
|
|
94
|
+
return (
|
|
95
|
+
shown?.graph.nodes.find((node) => node.type === 'composition' && node.startsHere === true)
|
|
96
|
+
?.id ?? null
|
|
97
|
+
);
|
|
98
|
+
},
|
|
99
|
+
problemCountOf: () => 0,
|
|
100
|
+
hasEdgeProblem: () => false,
|
|
101
|
+
isEdgeTaken: () => false,
|
|
102
|
+
entryCountOf: (nodeId) => (shown ? (shown.counts.entered.get(nodeId) ?? 0) : null),
|
|
103
|
+
followCountOf: (edgeId) => (shown ? (shown.counts.followed.get(edgeId) ?? 0) : null),
|
|
104
|
+
failureCountOf: (nodeId) => shown?.counts.failed.get(nodeId) ?? 0
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const context = $derived<CanvasContext | null>(words ? { marks, words, readOnly: true } : null);
|
|
108
|
+
|
|
109
|
+
/** Reads the counts and the blocks they are about, for a range of days and a version. */
|
|
110
|
+
async function load(days: number, selectedVersionId: string): Promise<void> {
|
|
111
|
+
controller?.abort();
|
|
112
|
+
const current = new AbortController();
|
|
113
|
+
controller = current;
|
|
114
|
+
loadState = 'loading';
|
|
115
|
+
failureKey = null;
|
|
116
|
+
try {
|
|
117
|
+
const range = makeStatsRange(days);
|
|
118
|
+
// "Every version" is drawn on the live one: the counts are by block id, and the live blocks are the ones that matter most.
|
|
119
|
+
const versionToDraw = selectedVersionId || editor.workflow?.liveVersion?.id || '';
|
|
120
|
+
const [stats, version] = await Promise.all([
|
|
121
|
+
api.getStats(
|
|
122
|
+
editor.workflowId,
|
|
123
|
+
{ ...range, ...(selectedVersionId ? { versionId: selectedVersionId } : {}) },
|
|
124
|
+
{ signal: current.signal }
|
|
125
|
+
),
|
|
126
|
+
versionToDraw
|
|
127
|
+
? api.getVersion(editor.workflowId, versionToDraw, { signal: current.signal })
|
|
128
|
+
: Promise.resolve(null)
|
|
129
|
+
]);
|
|
130
|
+
if (current.signal.aborted) return;
|
|
131
|
+
const graph = version?.graph ?? editor.graph;
|
|
132
|
+
await editor.ensureOptionsFor(graph);
|
|
133
|
+
if (current.signal.aborted) return;
|
|
134
|
+
shown = { key: `${version?.id ?? 'draft'}`, graph, counts: readRunCounts(stats) };
|
|
135
|
+
loadState = 'ready';
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (isCancelled(error)) return;
|
|
138
|
+
workflowsError('Reading the counts failed.', error);
|
|
139
|
+
failureKey = pickApiErrorMessage(error) ?? 'workflows.error.generic';
|
|
140
|
+
loadState = 'failed';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Reads the counts for what the two choices say, or says there is nothing to count while the workflow was never published. */
|
|
145
|
+
function reload(days: number, selectedVersionId: string): void {
|
|
146
|
+
if (!hasBeenPublished) {
|
|
147
|
+
loadState = 'ready';
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
void load(days, selectedVersionId);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
onMount(() => {
|
|
154
|
+
if (editor.versions === null) void editor.loadVersions();
|
|
155
|
+
// The first reading; every later one is asked for by a change of the range or the version (below).
|
|
156
|
+
reload(
|
|
157
|
+
Number(untrack(() => rangeDays)),
|
|
158
|
+
untrack(() => versionId)
|
|
159
|
+
);
|
|
160
|
+
return () => controller?.abort();
|
|
161
|
+
});
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<div class="flex min-h-0 flex-1 flex-col gap-3 p-4">
|
|
165
|
+
{#if !hasBeenPublished}
|
|
166
|
+
<p class="py-10 text-center text-sm text-ink-muted">{$t('workflows.runs.neverPublished')}</p>
|
|
167
|
+
{:else}
|
|
168
|
+
<div class="flex flex-wrap items-end gap-3">
|
|
169
|
+
<SelectField
|
|
170
|
+
class="w-48"
|
|
171
|
+
label={$t('workflows.runs.rangeLabel')}
|
|
172
|
+
bind:value={rangeDays}
|
|
173
|
+
choices={rangeChoices}
|
|
174
|
+
onchange={(chosenDays) => reload(Number(chosenDays), versionId)}
|
|
175
|
+
/>
|
|
176
|
+
<SelectField
|
|
177
|
+
class="w-56"
|
|
178
|
+
label={$t('workflows.runs.versionLabel')}
|
|
179
|
+
bind:value={versionId}
|
|
180
|
+
choices={versionChoices}
|
|
181
|
+
onchange={(chosenVersionId) => reload(Number(rangeDays), chosenVersionId)}
|
|
182
|
+
/>
|
|
183
|
+
{#if startedText}
|
|
184
|
+
<p class="pb-2 text-sm" aria-live="polite">{startedText}</p>
|
|
185
|
+
{/if}
|
|
186
|
+
</div>
|
|
187
|
+
<p class="text-xs text-ink-muted">{$t('workflows.runs.help')}</p>
|
|
188
|
+
{#if shown && shown.counts.busiest === 0 && loadState === 'ready'}
|
|
189
|
+
<p class="text-xs text-ink-muted" role="status">{$t('workflows.runs.none')}</p>
|
|
190
|
+
{/if}
|
|
191
|
+
|
|
192
|
+
{#if loadState === 'failed'}
|
|
193
|
+
<Notice tone="problem">
|
|
194
|
+
{failureKey ? $t(failureKey) : ''}
|
|
195
|
+
{#snippet action()}
|
|
196
|
+
<ActionButton size="small" onclick={() => void load(Number(rangeDays), versionId)}
|
|
197
|
+
>{$t('workflows.error.retry')}</ActionButton
|
|
198
|
+
>
|
|
199
|
+
{/snippet}
|
|
200
|
+
</Notice>
|
|
201
|
+
{/if}
|
|
202
|
+
|
|
203
|
+
<div class="relative min-h-80 flex-1" aria-busy={loadState === 'loading'}>
|
|
204
|
+
{#if shown && context}
|
|
205
|
+
{#key shown.key}
|
|
206
|
+
<WorkflowCanvas
|
|
207
|
+
initialGraph={shown.graph}
|
|
208
|
+
readContext={() => context}
|
|
209
|
+
readOnly={true}
|
|
210
|
+
onReady={(handle) => (canvasHandle = handle)}
|
|
211
|
+
/>
|
|
212
|
+
{/key}
|
|
213
|
+
<div
|
|
214
|
+
class="absolute start-3 top-3 z-20 flex items-center gap-1 rounded-large border border-grey2 bg-white p-1 shadow-sm"
|
|
215
|
+
role="toolbar"
|
|
216
|
+
aria-label={$t('workflows.toolbar.label')}
|
|
217
|
+
>
|
|
218
|
+
<ActionButton
|
|
219
|
+
variant="ghost"
|
|
220
|
+
size="small"
|
|
221
|
+
iconOnly
|
|
222
|
+
ariaLabel={$t('workflows.toolbar.zoomOut')}
|
|
223
|
+
title={$t('workflows.toolbar.zoomOut')}
|
|
224
|
+
onclick={() => canvasHandle?.zoomOut()}
|
|
225
|
+
>
|
|
226
|
+
<Icon name="zoomOut" />
|
|
227
|
+
</ActionButton>
|
|
228
|
+
<ActionButton
|
|
229
|
+
variant="ghost"
|
|
230
|
+
size="small"
|
|
231
|
+
iconOnly
|
|
232
|
+
ariaLabel={$t('workflows.toolbar.zoomIn')}
|
|
233
|
+
title={$t('workflows.toolbar.zoomIn')}
|
|
234
|
+
onclick={() => canvasHandle?.zoomIn()}
|
|
235
|
+
>
|
|
236
|
+
<Icon name="zoomIn" />
|
|
237
|
+
</ActionButton>
|
|
238
|
+
<ActionButton
|
|
239
|
+
variant="ghost"
|
|
240
|
+
size="small"
|
|
241
|
+
iconOnly
|
|
242
|
+
ariaLabel={$t('workflows.toolbar.fit')}
|
|
243
|
+
title={$t('workflows.toolbar.fit')}
|
|
244
|
+
onclick={() => canvasHandle?.fitView()}
|
|
245
|
+
>
|
|
246
|
+
<Icon name="fit" />
|
|
247
|
+
</ActionButton>
|
|
248
|
+
</div>
|
|
249
|
+
{:else if loadState === 'loading'}
|
|
250
|
+
<p class="py-10 text-center text-sm text-ink-muted" role="status">
|
|
251
|
+
{$t('workflows.common.loading')}
|
|
252
|
+
</p>
|
|
253
|
+
{/if}
|
|
254
|
+
</div>
|
|
255
|
+
{/if}
|
|
256
|
+
</div>
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Settings: the time zone the workflow's scheduled moments are told in, the code that puts the workflow on a page, and what
|
|
3
|
+
can be done with the workflow as a whole: pause it, archive it, copy it, delete it.
|
|
4
|
+
|
|
5
|
+
Pausing is for a while: an embed of a paused workflow shows only its first composition, as a plain embed would. Archiving is
|
|
6
|
+
for good, but not lost (it can be brought back). A workflow that was ever published cannot be deleted, because pages out there
|
|
7
|
+
may still carry its id; it can be archived instead, and the page says so.
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
11
|
+
import { listTimeZones } from '../../editor/zonedTime.js';
|
|
12
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
13
|
+
import ActionButton from '../ui/ActionButton.svelte';
|
|
14
|
+
import ConfirmDialog from '../ui/ConfirmDialog.svelte';
|
|
15
|
+
import Icon from '../ui/Icon.svelte';
|
|
16
|
+
import SelectField from '../ui/SelectField.svelte';
|
|
17
|
+
import type { SelectChoice } from '../ui/types.js';
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
/** Opens the embed code of this workflow; absent when the page that hosts the screen has no such dialog. */
|
|
21
|
+
onshowembedcode?: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let { onshowembedcode }: Props = $props();
|
|
25
|
+
|
|
26
|
+
const editor = useEditorState();
|
|
27
|
+
const { t } = useWorkflowsLanguage();
|
|
28
|
+
const sectionId = $props.id();
|
|
29
|
+
|
|
30
|
+
let asking = $state<'archive' | 'delete' | null>(null);
|
|
31
|
+
|
|
32
|
+
const zoneChoices = $derived.by<SelectChoice[]>(() => {
|
|
33
|
+
const zones = listTimeZones();
|
|
34
|
+
// A zone saved with the workflow that this browser does not list is still shown, so the select never lies about it.
|
|
35
|
+
if (!zones.includes(editor.timezone)) zones.unshift(editor.timezone);
|
|
36
|
+
return zones.map((zone) => ({ value: zone, label: zone }));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const isLiveOrPaused = $derived(editor.status === 'live' || editor.status === 'paused');
|
|
40
|
+
const canDelete = $derived(!(editor.workflow?.everPublished ?? false));
|
|
41
|
+
|
|
42
|
+
async function confirmArchive(): Promise<void> {
|
|
43
|
+
await editor.changeState('archive');
|
|
44
|
+
asking = null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function confirmDelete(): Promise<void> {
|
|
48
|
+
await editor.deleteWorkflow();
|
|
49
|
+
asking = null;
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<div class="mx-auto flex w-full max-w-2xl flex-col gap-8 overflow-auto p-4 pb-10">
|
|
54
|
+
<section class="flex flex-col gap-2" aria-labelledby="{sectionId}-zone">
|
|
55
|
+
<h3 id="{sectionId}-zone" class="text-sm font-semibold">
|
|
56
|
+
{$t('workflows.settings.zoneHeading')}
|
|
57
|
+
</h3>
|
|
58
|
+
<SelectField
|
|
59
|
+
label={$t('workflows.settings.zoneLabel')}
|
|
60
|
+
value={editor.timezone}
|
|
61
|
+
choices={zoneChoices}
|
|
62
|
+
disabled={editor.isReadOnly}
|
|
63
|
+
help={$t('workflows.settings.zoneHelp')}
|
|
64
|
+
onchange={(zone) => editor.setTimezone(zone)}
|
|
65
|
+
/>
|
|
66
|
+
</section>
|
|
67
|
+
|
|
68
|
+
{#if onshowembedcode && editor.workflow?.everPublished}
|
|
69
|
+
<section class="flex flex-col gap-2" aria-labelledby="{sectionId}-embed">
|
|
70
|
+
<h3 id="{sectionId}-embed" class="text-sm font-semibold">
|
|
71
|
+
{$t('workflows.settings.embedHeading')}
|
|
72
|
+
</h3>
|
|
73
|
+
<p class="text-xs text-ink-muted">{$t('workflows.settings.embedHelp')}</p>
|
|
74
|
+
<ActionButton size="small" class="self-start" onclick={onshowembedcode}>
|
|
75
|
+
<Icon name="code" />
|
|
76
|
+
{$t('workflows.top.embedCode')}
|
|
77
|
+
</ActionButton>
|
|
78
|
+
</section>
|
|
79
|
+
{/if}
|
|
80
|
+
|
|
81
|
+
<section class="flex flex-col gap-3" aria-labelledby="{sectionId}-state">
|
|
82
|
+
<h3 id="{sectionId}-state" class="text-sm font-semibold">
|
|
83
|
+
{$t('workflows.settings.stateHeading')}
|
|
84
|
+
</h3>
|
|
85
|
+
|
|
86
|
+
{#if isLiveOrPaused}
|
|
87
|
+
<div class="flex flex-col gap-1">
|
|
88
|
+
<ActionButton
|
|
89
|
+
size="small"
|
|
90
|
+
class="self-start"
|
|
91
|
+
disabled={!editor.canChangeWorkflow}
|
|
92
|
+
onclick={() => void editor.changeState(editor.status === 'paused' ? 'resume' : 'pause')}
|
|
93
|
+
>
|
|
94
|
+
{editor.status === 'paused'
|
|
95
|
+
? $t('workflows.settings.resume')
|
|
96
|
+
: $t('workflows.settings.pause')}
|
|
97
|
+
</ActionButton>
|
|
98
|
+
<p class="text-xs text-ink-muted">
|
|
99
|
+
{editor.status === 'paused'
|
|
100
|
+
? $t('workflows.settings.resumeHelp')
|
|
101
|
+
: $t('workflows.settings.pauseHelp')}
|
|
102
|
+
</p>
|
|
103
|
+
</div>
|
|
104
|
+
{/if}
|
|
105
|
+
|
|
106
|
+
<div class="flex flex-col gap-1">
|
|
107
|
+
{#if editor.status === 'archived'}
|
|
108
|
+
<ActionButton
|
|
109
|
+
size="small"
|
|
110
|
+
class="self-start"
|
|
111
|
+
disabled={!editor.canChangeWorkflow}
|
|
112
|
+
onclick={() => void editor.changeState('unarchive')}
|
|
113
|
+
>
|
|
114
|
+
{$t('workflows.settings.unarchive')}
|
|
115
|
+
</ActionButton>
|
|
116
|
+
<p class="text-xs text-ink-muted">{$t('workflows.settings.unarchiveHelp')}</p>
|
|
117
|
+
{:else if editor.workflow?.everPublished}
|
|
118
|
+
<ActionButton
|
|
119
|
+
size="small"
|
|
120
|
+
class="self-start"
|
|
121
|
+
disabled={!editor.canChangeWorkflow}
|
|
122
|
+
onclick={() => (asking = 'archive')}
|
|
123
|
+
>
|
|
124
|
+
{$t('workflows.settings.archive')}
|
|
125
|
+
</ActionButton>
|
|
126
|
+
<p class="text-xs text-ink-muted">{$t('workflows.settings.archiveHelp')}</p>
|
|
127
|
+
{/if}
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div class="flex flex-col gap-1">
|
|
131
|
+
<ActionButton
|
|
132
|
+
size="small"
|
|
133
|
+
class="self-start"
|
|
134
|
+
disabled={editor.busy !== null}
|
|
135
|
+
onclick={() => void editor.duplicate()}
|
|
136
|
+
>
|
|
137
|
+
<Icon name="copy" />
|
|
138
|
+
{$t('workflows.settings.duplicate')}
|
|
139
|
+
</ActionButton>
|
|
140
|
+
<p class="text-xs text-ink-muted">{$t('workflows.settings.duplicateHelp')}</p>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<div class="flex flex-col gap-1">
|
|
144
|
+
<ActionButton
|
|
145
|
+
variant="danger"
|
|
146
|
+
size="small"
|
|
147
|
+
class="self-start"
|
|
148
|
+
disabled={!editor.canChangeWorkflow || !canDelete}
|
|
149
|
+
onclick={() => (asking = 'delete')}
|
|
150
|
+
>
|
|
151
|
+
<Icon name="trash" />
|
|
152
|
+
{$t('workflows.settings.delete')}
|
|
153
|
+
</ActionButton>
|
|
154
|
+
<p class="text-xs text-ink-muted">
|
|
155
|
+
{canDelete ? $t('workflows.settings.deleteHelp') : $t('workflows.settings.deleteBlocked')}
|
|
156
|
+
</p>
|
|
157
|
+
</div>
|
|
158
|
+
</section>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
{#if asking === 'archive'}
|
|
162
|
+
<ConfirmDialog
|
|
163
|
+
title={$t('workflows.settings.archiveTitle')}
|
|
164
|
+
message={$t('workflows.settings.archiveMessage')}
|
|
165
|
+
confirmLabel={$t('workflows.settings.archive')}
|
|
166
|
+
busy={editor.busy === 'changingState'}
|
|
167
|
+
onconfirm={() => void confirmArchive()}
|
|
168
|
+
oncancel={() => (asking = null)}
|
|
169
|
+
/>
|
|
170
|
+
{:else if asking === 'delete'}
|
|
171
|
+
<ConfirmDialog
|
|
172
|
+
title={$t('workflows.settings.deleteTitle')}
|
|
173
|
+
message={$t('workflows.settings.deleteMessage', { name: editor.name })}
|
|
174
|
+
confirmLabel={$t('workflows.settings.delete')}
|
|
175
|
+
tone="danger"
|
|
176
|
+
busy={editor.busy === 'deleting'}
|
|
177
|
+
onconfirm={() => void confirmDelete()}
|
|
178
|
+
oncancel={() => (asking = null)}
|
|
179
|
+
/>
|
|
180
|
+
{/if}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** Opens the embed code of this workflow; absent when the page that hosts the screen has no such dialog. */
|
|
3
|
+
onshowembedcode?: () => void;
|
|
4
|
+
}
|
|
5
|
+
declare const SettingsTab: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type SettingsTab = ReturnType<typeof SettingsTab>;
|
|
7
|
+
export default SettingsTab;
|