@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,89 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
"New workflow": a name, and the composition visitors see first (optional: it can be chosen in the editor). Making it opens
|
|
3
|
+
the editor straight away, with the composition already on the canvas as the start.
|
|
4
|
+
|
|
5
|
+
The name is the only thing required, so the dialog never asks for what it could do without.
|
|
6
|
+
-->
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { MAX_WORKFLOW_NAME_LENGTH } from '../../api/types.js';
|
|
9
|
+
import type { CompositionOption, WorkflowDetail } from '../../api/types.js';
|
|
10
|
+
import { useListState } from '../../editor/listState.svelte.js';
|
|
11
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
12
|
+
import CompositionPicker from '../panel/CompositionPicker.svelte';
|
|
13
|
+
import ActionButton from '../ui/ActionButton.svelte';
|
|
14
|
+
import Modal from '../ui/Modal.svelte';
|
|
15
|
+
import Notice from '../ui/Notice.svelte';
|
|
16
|
+
import TextField from '../ui/TextField.svelte';
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
oncancel: () => void;
|
|
20
|
+
/** The workflow was made; the screen opens it. */
|
|
21
|
+
oncreated: (created: WorkflowDetail) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let { oncancel, oncreated }: Props = $props();
|
|
25
|
+
|
|
26
|
+
const list = useListState();
|
|
27
|
+
const { t } = useWorkflowsLanguage();
|
|
28
|
+
|
|
29
|
+
let name = $state('');
|
|
30
|
+
let chosen = $state.raw<CompositionOption | null>(null);
|
|
31
|
+
let isCreating = $state(false);
|
|
32
|
+
|
|
33
|
+
const canCreate = $derived(name.trim() !== '' && !isCreating);
|
|
34
|
+
|
|
35
|
+
async function create(): Promise<void> {
|
|
36
|
+
if (!canCreate) return;
|
|
37
|
+
isCreating = true;
|
|
38
|
+
try {
|
|
39
|
+
const created = await list.create({ name: name.trim(), composition: chosen });
|
|
40
|
+
if (created) oncreated(created);
|
|
41
|
+
} finally {
|
|
42
|
+
isCreating = false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Enter in the name box makes the workflow, as the button does. */
|
|
47
|
+
function handleKeydown(event: KeyboardEvent): void {
|
|
48
|
+
if (
|
|
49
|
+
event.key === 'Enter' &&
|
|
50
|
+
event.target instanceof HTMLInputElement &&
|
|
51
|
+
event.target.type === 'text'
|
|
52
|
+
) {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
void create();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<Modal title={$t('workflows.create.title')} size="medium" busy={isCreating} onclose={oncancel}>
|
|
60
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
61
|
+
<div class="flex flex-col gap-4" onkeydown={handleKeydown}>
|
|
62
|
+
<TextField
|
|
63
|
+
label={$t('workflows.create.nameLabel')}
|
|
64
|
+
placeholder={$t('workflows.create.namePlaceholder')}
|
|
65
|
+
maxlength={MAX_WORKFLOW_NAME_LENGTH}
|
|
66
|
+
autofocus
|
|
67
|
+
bind:value={name}
|
|
68
|
+
/>
|
|
69
|
+
<div class="flex flex-col gap-2">
|
|
70
|
+
<p class="text-xs font-medium">{$t('workflows.create.compositionLabel')}</p>
|
|
71
|
+
<p class="text-xs text-ink-muted">{$t('workflows.create.compositionHelp')}</p>
|
|
72
|
+
<CompositionPicker
|
|
73
|
+
selectedId={chosen?.id ?? null}
|
|
74
|
+
onpick={(option) => (chosen = chosen?.id === option.id ? null : option)}
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
{#if list.createFailure}
|
|
78
|
+
<Notice tone="problem">{$t(list.createFailure)}</Notice>
|
|
79
|
+
{/if}
|
|
80
|
+
</div>
|
|
81
|
+
{#snippet footer()}
|
|
82
|
+
<ActionButton disabled={isCreating} onclick={oncancel}
|
|
83
|
+
>{$t('workflows.common.cancel')}</ActionButton
|
|
84
|
+
>
|
|
85
|
+
<ActionButton variant="primary" disabled={!canCreate} onclick={() => void create()}>
|
|
86
|
+
{isCreating ? $t('workflows.create.creating') : $t('workflows.create.create')}
|
|
87
|
+
</ActionButton>
|
|
88
|
+
{/snippet}
|
|
89
|
+
</Modal>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WorkflowDetail } from '../../api/types.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
oncancel: () => void;
|
|
4
|
+
/** The workflow was made; the screen opens it. */
|
|
5
|
+
oncreated: (created: WorkflowDetail) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const CreateWorkflowDialog: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type CreateWorkflowDialog = ReturnType<typeof CreateWorkflowDialog>;
|
|
9
|
+
export default CreateWorkflowDialog;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The list of a workspace's workflows: search, a filter by state, an order (name, when it was made, when it was last
|
|
3
|
+
published, how many visitors started it) and a row for each, with "New workflow" at the top.
|
|
4
|
+
|
|
5
|
+
The list can be longer than a page, so every change of the search, the filter or the order asks the API again; "Show more"
|
|
6
|
+
adds the next page. A page of nothing says why: nothing made yet (and offers to make one), or nothing matches what was asked.
|
|
7
|
+
-->
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { onDestroy, onMount } from 'svelte';
|
|
10
|
+
import type { WorkflowDetail } from '../../api/types.js';
|
|
11
|
+
import { WORKFLOW_STATUSES } from '../../api/types.js';
|
|
12
|
+
import type { WorkflowSortField } from '../../api/types.js';
|
|
13
|
+
import { useWorkflowsApi } from '../../api/apiContext.js';
|
|
14
|
+
import { WorkflowListState, provideListState } from '../../editor/listState.svelte.js';
|
|
15
|
+
import type { ListStatusFilter } from '../../editor/listState.svelte.js';
|
|
16
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
17
|
+
import type { WorkflowsMessageKey } from '../../i18n/messages.js';
|
|
18
|
+
import type { WorkflowsError } from '../../types/index.js';
|
|
19
|
+
import WorkflowsEmptyState from '../WorkflowsEmptyState.svelte';
|
|
20
|
+
import WorkflowsHeader from '../WorkflowsHeader.svelte';
|
|
21
|
+
import ActionButton from '../ui/ActionButton.svelte';
|
|
22
|
+
import Icon from '../ui/Icon.svelte';
|
|
23
|
+
import Notice from '../ui/Notice.svelte';
|
|
24
|
+
import SelectField from '../ui/SelectField.svelte';
|
|
25
|
+
import TextField from '../ui/TextField.svelte';
|
|
26
|
+
import type { SelectChoice } from '../ui/types.js';
|
|
27
|
+
import CreateWorkflowDialog from './CreateWorkflowDialog.svelte';
|
|
28
|
+
import WorkflowRow from './WorkflowRow.svelte';
|
|
29
|
+
|
|
30
|
+
interface Props {
|
|
31
|
+
/** A workflow was chosen (or just made): open it. */
|
|
32
|
+
onopen: (workflowId: string) => void;
|
|
33
|
+
/** A failure the page should hear about. */
|
|
34
|
+
onerror: (error: WorkflowsError) => void;
|
|
35
|
+
/** Shows the embed code of a workflow; the page that hosts the screen decides what that looks like. */
|
|
36
|
+
onshowembedcode?: (workflowId: string) => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let { onopen, onerror, onshowembedcode }: Props = $props();
|
|
40
|
+
|
|
41
|
+
const api = useWorkflowsApi();
|
|
42
|
+
const { t } = useWorkflowsLanguage();
|
|
43
|
+
|
|
44
|
+
const list = new WorkflowListState({ api, reportError: (error) => onerror(error) });
|
|
45
|
+
provideListState(list);
|
|
46
|
+
|
|
47
|
+
let isCreating = $state(false);
|
|
48
|
+
|
|
49
|
+
const STATUS_FILTER_KEYS = {
|
|
50
|
+
'': 'workflows.list.filterActive',
|
|
51
|
+
all: 'workflows.list.filterAll',
|
|
52
|
+
draft: 'workflows.status.draft',
|
|
53
|
+
live: 'workflows.status.live',
|
|
54
|
+
paused: 'workflows.status.paused',
|
|
55
|
+
archived: 'workflows.status.archived'
|
|
56
|
+
} as const satisfies Record<ListStatusFilter, WorkflowsMessageKey>;
|
|
57
|
+
|
|
58
|
+
const SORT_KEYS = {
|
|
59
|
+
createdAt: 'workflows.list.sortCreated',
|
|
60
|
+
lastPublishedAt: 'workflows.list.sortPublished',
|
|
61
|
+
runsCount: 'workflows.list.sortRuns',
|
|
62
|
+
name: 'workflows.list.sortName'
|
|
63
|
+
} as const satisfies Record<WorkflowSortField, WorkflowsMessageKey>;
|
|
64
|
+
|
|
65
|
+
const statusChoices = $derived<SelectChoice[]>(
|
|
66
|
+
(['', 'all', ...WORKFLOW_STATUSES] as ListStatusFilter[]).map((filter) => ({
|
|
67
|
+
value: filter,
|
|
68
|
+
label: $t(STATUS_FILTER_KEYS[filter])
|
|
69
|
+
}))
|
|
70
|
+
);
|
|
71
|
+
const sortChoices = $derived<SelectChoice[]>(
|
|
72
|
+
(Object.keys(SORT_KEYS) as WorkflowSortField[]).map((field) => ({
|
|
73
|
+
value: field,
|
|
74
|
+
label: $t(SORT_KEYS[field])
|
|
75
|
+
}))
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
let searchDraft = $state('');
|
|
79
|
+
|
|
80
|
+
function handleCreated(created: WorkflowDetail): void {
|
|
81
|
+
isCreating = false;
|
|
82
|
+
onopen(created.id);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
onMount(() => {
|
|
86
|
+
void list.load();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
onDestroy(() => list.dispose());
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<div class="@container flex flex-1 flex-col gap-5">
|
|
93
|
+
<div class="flex flex-wrap items-start justify-between gap-3">
|
|
94
|
+
<WorkflowsHeader />
|
|
95
|
+
<ActionButton variant="primary" onclick={() => (isCreating = true)}>
|
|
96
|
+
<Icon name="plus" />
|
|
97
|
+
{$t('workflows.list.newWorkflow')}
|
|
98
|
+
</ActionButton>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
{#if list.notice}
|
|
102
|
+
{@const notice = list.notice}
|
|
103
|
+
<Notice tone={notice.tone}>
|
|
104
|
+
{$t(notice.messageKey, notice.values)}
|
|
105
|
+
{#snippet action()}
|
|
106
|
+
<ActionButton variant="ghost" size="small" onclick={() => list.dismissNotice()}
|
|
107
|
+
>{$t('workflows.common.dismiss')}</ActionButton
|
|
108
|
+
>
|
|
109
|
+
{/snippet}
|
|
110
|
+
</Notice>
|
|
111
|
+
{/if}
|
|
112
|
+
|
|
113
|
+
<div class="flex flex-wrap items-end gap-3">
|
|
114
|
+
<TextField
|
|
115
|
+
class="min-w-56 flex-1"
|
|
116
|
+
type="search"
|
|
117
|
+
label={$t('workflows.list.searchLabel')}
|
|
118
|
+
placeholder={$t('workflows.list.searchPlaceholder')}
|
|
119
|
+
hideLabel
|
|
120
|
+
bind:value={searchDraft}
|
|
121
|
+
oninput={() => list.setSearch(searchDraft)}
|
|
122
|
+
/>
|
|
123
|
+
<SelectField
|
|
124
|
+
class="w-44"
|
|
125
|
+
label={$t('workflows.list.filterLabel')}
|
|
126
|
+
value={list.statusFilter}
|
|
127
|
+
choices={statusChoices}
|
|
128
|
+
onchange={(filter) => list.setStatusFilter(filter as ListStatusFilter)}
|
|
129
|
+
/>
|
|
130
|
+
<SelectField
|
|
131
|
+
class="w-44"
|
|
132
|
+
label={$t('workflows.list.sortLabel')}
|
|
133
|
+
value={list.sortField}
|
|
134
|
+
choices={sortChoices}
|
|
135
|
+
onchange={(field) => list.setSort(field as WorkflowSortField)}
|
|
136
|
+
/>
|
|
137
|
+
<ActionButton
|
|
138
|
+
iconOnly
|
|
139
|
+
ariaLabel={list.sortDirection === 'asc'
|
|
140
|
+
? $t('workflows.list.sortAscending')
|
|
141
|
+
: $t('workflows.list.sortDescending')}
|
|
142
|
+
title={list.sortDirection === 'asc'
|
|
143
|
+
? $t('workflows.list.sortAscending')
|
|
144
|
+
: $t('workflows.list.sortDescending')}
|
|
145
|
+
onclick={() => list.toggleSortDirection()}
|
|
146
|
+
>
|
|
147
|
+
<Icon name={list.sortDirection === 'asc' ? 'up' : 'down'} />
|
|
148
|
+
</ActionButton>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
{#if list.loadState === 'loading'}
|
|
152
|
+
<p class="py-10 text-center text-sm text-ink-muted" role="status">
|
|
153
|
+
{$t('workflows.common.loading')}
|
|
154
|
+
</p>
|
|
155
|
+
{:else if list.loadState === 'failed'}
|
|
156
|
+
<Notice tone="problem">
|
|
157
|
+
{$t(list.failure ?? 'workflows.error.generic')}
|
|
158
|
+
{#snippet action()}
|
|
159
|
+
<ActionButton size="small" onclick={() => void list.load()}
|
|
160
|
+
>{$t('workflows.error.retry')}</ActionButton
|
|
161
|
+
>
|
|
162
|
+
{/snippet}
|
|
163
|
+
</Notice>
|
|
164
|
+
{:else if list.items.length === 0}
|
|
165
|
+
{#if list.isNarrowed}
|
|
166
|
+
<p class="py-10 text-center text-sm text-ink-muted">{$t('workflows.list.noMatches')}</p>
|
|
167
|
+
{:else}
|
|
168
|
+
<WorkflowsEmptyState oncreate={() => (isCreating = true)} />
|
|
169
|
+
{/if}
|
|
170
|
+
{:else}
|
|
171
|
+
<div class="flex flex-col gap-2">
|
|
172
|
+
<!-- The column headings are only drawn where the rows have columns. -->
|
|
173
|
+
<div
|
|
174
|
+
class="hidden grid-cols-[minmax(0,2fr)_7rem_6rem_8rem_8rem_auto] gap-x-4 px-4 text-xs text-ink-muted @2xl:grid"
|
|
175
|
+
aria-hidden="true"
|
|
176
|
+
>
|
|
177
|
+
<span>{$t('workflows.list.columnName')}</span>
|
|
178
|
+
<span>{$t('workflows.list.columnStatus')}</span>
|
|
179
|
+
<span>{$t('workflows.list.columnRuns')}</span>
|
|
180
|
+
<span>{$t('workflows.list.columnPublished')}</span>
|
|
181
|
+
<span>{$t('workflows.list.columnCreated')}</span>
|
|
182
|
+
<span class="w-8"></span>
|
|
183
|
+
</div>
|
|
184
|
+
<ul class="flex flex-col gap-2" aria-label={$t('workflows.list.label')}>
|
|
185
|
+
{#each list.items as item (item.id)}
|
|
186
|
+
<WorkflowRow {item} {onopen} {onshowembedcode} />
|
|
187
|
+
{/each}
|
|
188
|
+
</ul>
|
|
189
|
+
{#if list.hasMore}
|
|
190
|
+
<ActionButton
|
|
191
|
+
class="self-center"
|
|
192
|
+
disabled={list.loadingMore}
|
|
193
|
+
onclick={() => void list.loadMore()}
|
|
194
|
+
>
|
|
195
|
+
{list.loadingMore ? $t('workflows.common.loading') : $t('workflows.list.showMore')}
|
|
196
|
+
</ActionButton>
|
|
197
|
+
{/if}
|
|
198
|
+
</div>
|
|
199
|
+
{/if}
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
{#if isCreating}
|
|
203
|
+
<CreateWorkflowDialog oncancel={() => (isCreating = false)} oncreated={handleCreated} />
|
|
204
|
+
{/if}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WorkflowsError } from '../../types/index.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** A workflow was chosen (or just made): open it. */
|
|
4
|
+
onopen: (workflowId: string) => void;
|
|
5
|
+
/** A failure the page should hear about. */
|
|
6
|
+
onerror: (error: WorkflowsError) => void;
|
|
7
|
+
/** Shows the embed code of a workflow; the page that hosts the screen decides what that looks like. */
|
|
8
|
+
onshowembedcode?: (workflowId: string) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const WorkflowList: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type WorkflowList = ReturnType<typeof WorkflowList>;
|
|
12
|
+
export default WorkflowList;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
One workflow in the list: its name (which opens it), where it stands, how many compositions it uses, how many visitors
|
|
3
|
+
started it, when it was last published and made, and a menu of what can be done to it from here.
|
|
4
|
+
|
|
5
|
+
What the menu offers follows the workflow: a live one can be paused, a published one can be archived (never deleted: pages
|
|
6
|
+
out there may carry its id), an archived one can be brought back, and any can be copied. The two that cannot be taken back
|
|
7
|
+
ask first.
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import type { WorkflowListItem } from '../../api/types.js';
|
|
11
|
+
import { formatDay } from '../../editor/blockLabels.js';
|
|
12
|
+
import { formatCount } from '../../editor/formatCount.js';
|
|
13
|
+
import { useListState } from '../../editor/listState.svelte.js';
|
|
14
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
15
|
+
import ConfirmDialog from '../ui/ConfirmDialog.svelte';
|
|
16
|
+
import Menu from '../ui/Menu.svelte';
|
|
17
|
+
import StatusBadge from '../ui/StatusBadge.svelte';
|
|
18
|
+
import type { MenuGroup } from '../ui/types.js';
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
item: WorkflowListItem;
|
|
22
|
+
onopen: (workflowId: string) => void;
|
|
23
|
+
/** Shows the embed code of a workflow; absent when the page that hosts the screen has no such dialog. */
|
|
24
|
+
onshowembedcode?: (workflowId: string) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let { item, onopen, onshowembedcode }: Props = $props();
|
|
28
|
+
|
|
29
|
+
const list = useListState();
|
|
30
|
+
const { t, locale } = useWorkflowsLanguage();
|
|
31
|
+
|
|
32
|
+
let asking = $state<'archive' | 'delete' | null>(null);
|
|
33
|
+
|
|
34
|
+
const isBusy = $derived(list.busyIds.has(item.id));
|
|
35
|
+
const wasPublished = $derived(item.firstPublishedAt !== null);
|
|
36
|
+
|
|
37
|
+
const groups = $derived.by<MenuGroup[]>(() => {
|
|
38
|
+
const states: MenuGroup['items'][number][] = [];
|
|
39
|
+
if (item.status === 'live') {
|
|
40
|
+
states.push({
|
|
41
|
+
key: 'pause',
|
|
42
|
+
label: $t('workflows.settings.pause'),
|
|
43
|
+
icon: 'pause',
|
|
44
|
+
onSelect: () => void list.changeState(item.id, 'pause')
|
|
45
|
+
});
|
|
46
|
+
} else if (item.status === 'paused') {
|
|
47
|
+
states.push({
|
|
48
|
+
key: 'resume',
|
|
49
|
+
label: $t('workflows.settings.resume'),
|
|
50
|
+
icon: 'play',
|
|
51
|
+
onSelect: () => void list.changeState(item.id, 'resume')
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (item.status === 'archived') {
|
|
55
|
+
states.push({
|
|
56
|
+
key: 'unarchive',
|
|
57
|
+
label: $t('workflows.settings.unarchive'),
|
|
58
|
+
icon: 'undo',
|
|
59
|
+
onSelect: () => void list.changeState(item.id, 'unarchive')
|
|
60
|
+
});
|
|
61
|
+
} else if (wasPublished) {
|
|
62
|
+
states.push({
|
|
63
|
+
key: 'archive',
|
|
64
|
+
label: $t('workflows.settings.archive'),
|
|
65
|
+
icon: 'archive',
|
|
66
|
+
onSelect: () => (asking = 'archive')
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
key: 'open',
|
|
72
|
+
items: [
|
|
73
|
+
{
|
|
74
|
+
key: 'open',
|
|
75
|
+
label: $t('workflows.list.open'),
|
|
76
|
+
icon: 'open',
|
|
77
|
+
onSelect: () => onopen(item.id)
|
|
78
|
+
},
|
|
79
|
+
...(onshowembedcode && wasPublished
|
|
80
|
+
? [
|
|
81
|
+
{
|
|
82
|
+
key: 'embed',
|
|
83
|
+
label: $t('workflows.top.embedCode'),
|
|
84
|
+
icon: 'code' as const,
|
|
85
|
+
onSelect: () => onshowembedcode(item.id)
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
: []),
|
|
89
|
+
{
|
|
90
|
+
key: 'duplicate',
|
|
91
|
+
label: $t('workflows.settings.duplicate'),
|
|
92
|
+
icon: 'copy',
|
|
93
|
+
onSelect: () => void list.duplicate(item.id)
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
...(states.length > 0 ? [{ key: 'states', items: states }] : []),
|
|
98
|
+
{
|
|
99
|
+
key: 'danger',
|
|
100
|
+
items: [
|
|
101
|
+
{
|
|
102
|
+
key: 'delete',
|
|
103
|
+
label: $t('workflows.settings.delete'),
|
|
104
|
+
description: wasPublished ? $t('workflows.settings.deleteBlocked') : undefined,
|
|
105
|
+
icon: 'trash',
|
|
106
|
+
tone: 'danger',
|
|
107
|
+
disabled: wasPublished,
|
|
108
|
+
onSelect: () => (asking = 'delete')
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
async function confirmArchive(): Promise<void> {
|
|
116
|
+
await list.changeState(item.id, 'archive');
|
|
117
|
+
asking = null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function confirmDelete(): Promise<void> {
|
|
121
|
+
await list.remove(item.id);
|
|
122
|
+
asking = null;
|
|
123
|
+
}
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<li
|
|
127
|
+
class="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 rounded-large border border-grey2 px-4 py-3 aria-busy:opacity-60 @2xl:grid-cols-[minmax(0,2fr)_7rem_6rem_8rem_8rem_auto]"
|
|
128
|
+
aria-busy={isBusy}
|
|
129
|
+
>
|
|
130
|
+
<div class="flex min-w-0 flex-col">
|
|
131
|
+
<button
|
|
132
|
+
type="button"
|
|
133
|
+
class="truncate text-start text-sm font-medium hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-green"
|
|
134
|
+
dir="auto"
|
|
135
|
+
onclick={() => onopen(item.id)}
|
|
136
|
+
>
|
|
137
|
+
{item.name}
|
|
138
|
+
</button>
|
|
139
|
+
<span class="text-xs text-ink-muted"
|
|
140
|
+
>{$t('workflows.list.compositionsCount', { count: item.compositionIds.length })}</span
|
|
141
|
+
>
|
|
142
|
+
</div>
|
|
143
|
+
<div class="@2xl:order-none">
|
|
144
|
+
<StatusBadge status={item.status} hasUnpublishedChanges={item.unpublishedChanges} />
|
|
145
|
+
</div>
|
|
146
|
+
<span class="hidden text-sm @2xl:block">{formatCount(item.runsCount, $locale)}</span>
|
|
147
|
+
<span class="hidden text-sm text-ink-muted @2xl:block">
|
|
148
|
+
{item.lastPublishedAt ? formatDay(item.lastPublishedAt, $locale) : $t('workflows.list.never')}
|
|
149
|
+
</span>
|
|
150
|
+
<span class="hidden text-sm text-ink-muted @2xl:block">{formatDay(item.createdAt, $locale)}</span>
|
|
151
|
+
<!-- On a narrow screen the figures that have no column of their own are one line under the name. -->
|
|
152
|
+
<p class="col-span-2 text-xs text-ink-muted @2xl:hidden">
|
|
153
|
+
{$t('workflows.list.runsCount', { count: item.runsCount })} ·
|
|
154
|
+
{item.lastPublishedAt
|
|
155
|
+
? $t('workflows.list.publishedOn', { date: formatDay(item.lastPublishedAt, $locale) })
|
|
156
|
+
: $t('workflows.list.neverPublished')}
|
|
157
|
+
</p>
|
|
158
|
+
<div class="col-start-2 row-start-1 @2xl:col-start-auto @2xl:row-start-auto">
|
|
159
|
+
<Menu
|
|
160
|
+
{groups}
|
|
161
|
+
label={$t('workflows.list.rowMenu', { name: item.name })}
|
|
162
|
+
icon="more"
|
|
163
|
+
iconOnly
|
|
164
|
+
variant="ghost"
|
|
165
|
+
size="small"
|
|
166
|
+
align="end"
|
|
167
|
+
disabled={isBusy}
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
170
|
+
</li>
|
|
171
|
+
|
|
172
|
+
{#if asking === 'archive'}
|
|
173
|
+
<ConfirmDialog
|
|
174
|
+
title={$t('workflows.settings.archiveTitle')}
|
|
175
|
+
message={$t('workflows.settings.archiveMessage')}
|
|
176
|
+
confirmLabel={$t('workflows.settings.archive')}
|
|
177
|
+
busy={isBusy}
|
|
178
|
+
onconfirm={() => void confirmArchive()}
|
|
179
|
+
oncancel={() => (asking = null)}
|
|
180
|
+
/>
|
|
181
|
+
{:else if asking === 'delete'}
|
|
182
|
+
<ConfirmDialog
|
|
183
|
+
title={$t('workflows.settings.deleteTitle')}
|
|
184
|
+
message={$t('workflows.settings.deleteMessage', { name: item.name })}
|
|
185
|
+
confirmLabel={$t('workflows.settings.delete')}
|
|
186
|
+
tone="danger"
|
|
187
|
+
busy={isBusy}
|
|
188
|
+
onconfirm={() => void confirmDelete()}
|
|
189
|
+
oncancel={() => (asking = null)}
|
|
190
|
+
/>
|
|
191
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WorkflowListItem } from '../../api/types.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
item: WorkflowListItem;
|
|
4
|
+
onopen: (workflowId: string) => void;
|
|
5
|
+
/** Shows the embed code of a workflow; absent when the page that hosts the screen has no such dialog. */
|
|
6
|
+
onshowembedcode?: (workflowId: string) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const WorkflowRow: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type WorkflowRow = ReturnType<typeof WorkflowRow>;
|
|
10
|
+
export default WorkflowRow;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
What the check finds wrong with one block, in sentences, under the form of that block. The draft is checked all the time
|
|
3
|
+
with the engine's own rules (the same ones the publish applies), so a person sees what stops a publish while they build
|
|
4
|
+
instead of after they press the button. Warnings are advice and are not red.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { describeBlocksUniquely } from '../../editor/blockLabels.js';
|
|
8
|
+
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
9
|
+
import { describeIssue } from '../../editor/issueText.js';
|
|
10
|
+
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
11
|
+
import Icon from '../ui/Icon.svelte';
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
nodeId: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let { nodeId }: Props = $props();
|
|
18
|
+
|
|
19
|
+
const editor = useEditorState();
|
|
20
|
+
const { t } = useWorkflowsLanguage();
|
|
21
|
+
|
|
22
|
+
const sentences = $derived.by(() => {
|
|
23
|
+
const issues = editor.issuesOnCanvas.byNode.get(nodeId) ?? [];
|
|
24
|
+
if (issues.length === 0) return [];
|
|
25
|
+
const labels = describeBlocksUniquely(editor.graph, editor.options, $t);
|
|
26
|
+
const context = { t: $t, describeBlock: (blockId: string) => labels.get(blockId) ?? '' };
|
|
27
|
+
return issues.map((issue) => ({
|
|
28
|
+
severity: issue.severity,
|
|
29
|
+
text: describeIssue(issue, context)
|
|
30
|
+
}));
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
{#if sentences.length > 0}
|
|
35
|
+
<ul class="flex flex-col gap-1.5" aria-label={$t('workflows.panel.problemsLabel')}>
|
|
36
|
+
{#each sentences as sentence, index (index)}
|
|
37
|
+
<li
|
|
38
|
+
class="flex items-start gap-2 text-xs {sentence.severity === 'error'
|
|
39
|
+
? 'text-error'
|
|
40
|
+
: 'text-ink-muted'}"
|
|
41
|
+
>
|
|
42
|
+
<Icon name="warning" class="mt-0.5 size-3.5" />
|
|
43
|
+
<span>{sentence.text}</span>
|
|
44
|
+
</li>
|
|
45
|
+
{/each}
|
|
46
|
+
</ul>
|
|
47
|
+
{/if}
|