@widgetic/workflows 0.2.6 → 0.2.8
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 +51 -44
- package/dist/api/types.d.ts +17 -0
- package/dist/api/types.js +7 -0
- package/dist/api/workflowsApi.js +23 -2
- package/dist/components/Workflows.svelte +13 -15
- package/dist/components/WorkflowsEmptyState.svelte +14 -12
- package/dist/components/WorkflowsHeader.svelte +9 -5
- package/dist/components/WorkflowsHeader.svelte.d.ts +4 -16
- package/dist/components/WorkflowsWorkspace.svelte +3 -2
- package/dist/components/canvas/AddBlockMenu.svelte +11 -2
- package/dist/components/canvas/CanvasToolbar.svelte +42 -31
- package/dist/components/canvas/CanvasToolbar.svelte.d.ts +2 -0
- package/dist/components/canvas/CompositionNodeView.svelte +58 -36
- package/dist/components/canvas/ConditionNodeView.svelte +31 -18
- package/dist/components/canvas/HandlePoint.svelte +10 -3
- package/dist/components/canvas/HandlePoint.svelte.d.ts +1 -1
- package/dist/components/canvas/TriggerNodeView.svelte +39 -13
- package/dist/components/canvas/WorkflowCanvas.svelte +22 -7
- package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +2 -0
- package/dist/components/canvas/WorkflowEdgeView.svelte +5 -6
- package/dist/components/editor/ConflictBanner.svelte +1 -1
- package/dist/components/editor/EditorBanners.svelte +11 -4
- package/dist/components/editor/EditorCanvasArea.svelte +17 -10
- package/dist/components/editor/EditorTabs.svelte +10 -44
- package/dist/components/editor/EditorTopBar.svelte +166 -54
- package/dist/components/editor/PresenceBanner.svelte +106 -85
- package/dist/components/editor/RunsFlow.svelte +136 -42
- package/dist/components/editor/RunsTab.svelte +52 -46
- package/dist/components/editor/SettingsRow.svelte +35 -0
- package/dist/components/editor/SettingsRow.svelte.d.ts +14 -0
- package/dist/components/editor/SettingsTab.svelte +66 -50
- package/dist/components/editor/WorkflowEditor.svelte +4 -5
- package/dist/components/list/CreateWorkflowDialog.svelte +123 -73
- package/dist/components/list/WorkflowList.svelte +227 -100
- package/dist/components/list/WorkflowRow.svelte +84 -42
- package/dist/components/panel/BlockProblems.svelte +9 -8
- package/dist/components/panel/CompositionForm.svelte +52 -34
- package/dist/components/panel/CompositionPicker.svelte +43 -21
- package/dist/components/panel/CompositionPicker.svelte.d.ts +5 -0
- package/dist/components/panel/CompositionSelect.svelte +105 -0
- package/dist/components/panel/CompositionSelect.svelte.d.ts +23 -0
- package/dist/components/panel/ConditionForm.svelte +50 -17
- package/dist/components/panel/EventValueRow.svelte +5 -4
- package/dist/components/panel/ProblemsList.svelte +17 -19
- package/dist/components/panel/RuleCard.svelte +127 -89
- package/dist/components/panel/RuleCard.svelte.d.ts +2 -0
- package/dist/components/panel/SidePanel.svelte +101 -50
- package/dist/components/panel/TestResultLine.svelte +35 -0
- package/dist/components/panel/TestResultLine.svelte.d.ts +9 -0
- package/dist/components/panel/TestRow.svelte +21 -18
- package/dist/components/panel/TestRunPanel.svelte +61 -39
- package/dist/components/panel/TestTriggerCard.svelte +66 -6
- package/dist/components/panel/TestTriggerCard.svelte.d.ts +10 -0
- package/dist/components/panel/TriggerForm.svelte +24 -25
- package/dist/components/panel/VersionHistory.svelte +31 -43
- package/dist/components/ui/ActionButton.svelte +44 -12
- package/dist/components/ui/ActionButton.svelte.d.ts +2 -1
- package/dist/components/ui/Badge.svelte +39 -0
- package/dist/components/ui/Badge.svelte.d.ts +12 -0
- package/dist/components/ui/ConfirmDialog.svelte +4 -3
- package/dist/components/ui/Menu.svelte +28 -14
- package/dist/components/ui/Menu.svelte.d.ts +3 -1
- package/dist/components/ui/Modal.svelte +15 -8
- package/dist/components/ui/Notice.svelte +35 -11
- package/dist/components/ui/Notice.svelte.d.ts +4 -1
- package/dist/components/ui/SelectField.svelte +48 -20
- package/dist/components/ui/SelectField.svelte.d.ts +2 -0
- package/dist/components/ui/StatusBadge.svelte +13 -24
- package/dist/components/ui/StatusBadge.svelte.d.ts +0 -2
- package/dist/components/ui/Tabs.svelte +79 -0
- package/dist/components/ui/Tabs.svelte.d.ts +21 -0
- package/dist/components/ui/TextField.svelte +47 -27
- package/dist/components/ui/TextField.svelte.d.ts +5 -0
- package/dist/components/ui/icons.d.ts +43 -29
- package/dist/components/ui/icons.js +101 -40
- package/dist/editor/editorState.svelte.d.ts +23 -2
- package/dist/editor/editorState.svelte.js +36 -0
- package/dist/editor/listState.svelte.d.ts +32 -2
- package/dist/editor/listState.svelte.js +41 -0
- package/dist/editor/runsFlow.d.ts +28 -3
- package/dist/editor/runsFlow.js +27 -2
- package/dist/editor/runsFlowLayout.d.ts +6 -2
- package/dist/editor/runsFlowLayout.js +7 -2
- package/dist/editor/statsRange.d.ts +7 -1
- package/dist/editor/statsRange.js +14 -0
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +32 -13
- package/dist/i18n/messages.js +33 -14
- package/dist/i18n/statusWords.d.ts +12 -0
- package/dist/i18n/statusWords.js +12 -0
- package/package.json +3 -3
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
is sent and no visit is counted; any change to the draft ends the test, because the path it showed is no longer the draft's.
|
|
7
7
|
-->
|
|
8
8
|
<script lang="ts">
|
|
9
|
+
import type { TestRunResult } from '../../editor/testRun.js';
|
|
9
10
|
import { describeBlocksUniquely } from '../../editor/blockLabels.js';
|
|
11
|
+
import { findCompositionOfTrigger } from '../../editor/canvasWords.js';
|
|
10
12
|
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
11
13
|
import { listTriggersOfCurrent } from '../../editor/testRun.js';
|
|
12
14
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
13
15
|
import ActionButton from '../ui/ActionButton.svelte';
|
|
14
16
|
import Icon from '../ui/Icon.svelte';
|
|
17
|
+
import TestResultLine from './TestResultLine.svelte';
|
|
15
18
|
import TestTriggerCard from './TestTriggerCard.svelte';
|
|
16
19
|
|
|
17
20
|
const editor = useEditorState();
|
|
@@ -22,64 +25,83 @@
|
|
|
22
25
|
const triggers = $derived(run ? listTriggersOfCurrent(editor.graph, run) : []);
|
|
23
26
|
const currentName = $derived(run?.currentNodeId ? (labels.get(run.currentNodeId) ?? '') : '');
|
|
24
27
|
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
/** The trigger a card started to fire last (each card says so before its result arrives). */
|
|
29
|
+
let firedTriggerId = $state<string | null>(null);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Which trigger was fired last, so the result line shows on that card only. The mark counts only while the test has a
|
|
33
|
+
* result to show: starting over, or a change to the draft, ends the result and the mark goes with it.
|
|
34
|
+
*/
|
|
35
|
+
const lastFiredTriggerId = $derived(run?.lastResult ? firedTriggerId : null);
|
|
36
|
+
|
|
37
|
+
function rememberFiredTrigger(triggerId: string): void {
|
|
38
|
+
firedTriggerId = triggerId;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Result text for the trigger that was fired last (shown on that card). */
|
|
42
|
+
const cardResult = $derived.by((): { text: string; outcome: TestRunResult['outcome'] } | null => {
|
|
43
|
+
const state = run;
|
|
44
|
+
const result = state?.lastResult;
|
|
45
|
+
if (!result || !lastFiredTriggerId) return null;
|
|
46
|
+
if (result.outcome === 'moved') {
|
|
47
|
+
const toId = result.toNodeId;
|
|
48
|
+
return {
|
|
49
|
+
outcome: 'moved',
|
|
50
|
+
text: $t('workflows.test.resultMoved', { name: labels.get(toId) ?? '' })
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (result.outcome === 'stayed')
|
|
54
|
+
return { outcome: 'stayed', text: $t('workflows.test.resultStayed') };
|
|
55
|
+
return { outcome: 'ignored', text: $t('workflows.test.resultIgnored') };
|
|
34
56
|
});
|
|
35
57
|
</script>
|
|
36
58
|
|
|
37
59
|
<div class="flex flex-col gap-4">
|
|
38
|
-
<
|
|
39
|
-
<div>
|
|
40
|
-
<h3 class="text-sm font-semibold">{$t('workflows.test.heading')}</h3>
|
|
41
|
-
<p class="text-xs text-ink-muted">{$t('workflows.test.help')}</p>
|
|
42
|
-
</div>
|
|
43
|
-
<ActionButton
|
|
44
|
-
variant="ghost"
|
|
45
|
-
iconOnly
|
|
46
|
-
ariaLabel={$t('workflows.test.close')}
|
|
47
|
-
title={$t('workflows.test.close')}
|
|
48
|
-
onclick={() => editor.closeTestRun()}
|
|
49
|
-
>
|
|
50
|
-
<Icon name="close" />
|
|
51
|
-
</ActionButton>
|
|
52
|
-
</div>
|
|
60
|
+
<p class="text-body text-muted-foreground">{$t('workflows.test.help')}</p>
|
|
53
61
|
|
|
54
62
|
{#if run === null}
|
|
55
|
-
<p class="text-
|
|
63
|
+
<p class="text-caption text-muted-foreground">{$t('workflows.test.ended')}</p>
|
|
56
64
|
<ActionButton size="small" class="self-start" onclick={() => editor.openTestRun()}>
|
|
57
65
|
<Icon name="play" />
|
|
58
66
|
{$t('workflows.test.start')}
|
|
59
67
|
</ActionButton>
|
|
60
68
|
{:else if run.currentNodeId === null}
|
|
61
|
-
<p class="text-
|
|
69
|
+
<p class="text-caption text-muted-foreground">{$t('workflows.test.noStart')}</p>
|
|
62
70
|
{:else}
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<
|
|
71
|
+
<div class="flex items-center justify-between gap-2">
|
|
72
|
+
<p class="min-w-0 text-body-medium text-foreground" aria-live="polite">
|
|
73
|
+
{$t('workflows.test.visitorIsOn', { name: currentName })}
|
|
74
|
+
</p>
|
|
75
|
+
<ActionButton
|
|
76
|
+
variant="secondary"
|
|
77
|
+
size="small"
|
|
78
|
+
class="shrink-0"
|
|
79
|
+
onclick={() => editor.restartTestRun()}
|
|
80
|
+
>
|
|
81
|
+
<Icon name="refresh" />
|
|
82
|
+
{$t('workflows.test.restart')}
|
|
83
|
+
</ActionButton>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<!-- The card that was fired says what happened. When the visitor moved on it is gone from the panel, so the panel says it. -->
|
|
87
|
+
{#if cardResult && !triggers.some((trigger) => trigger.id === lastFiredTriggerId)}
|
|
88
|
+
<TestResultLine text={cardResult.text} outcome={cardResult.outcome} />
|
|
68
89
|
{/if}
|
|
69
90
|
|
|
70
91
|
{#if triggers.length === 0}
|
|
71
|
-
<p class="text-
|
|
92
|
+
<p class="text-caption text-muted-foreground">{$t('workflows.test.noTriggers')}</p>
|
|
72
93
|
{:else}
|
|
73
|
-
<div class="flex flex-col gap-
|
|
94
|
+
<div class="flex w-full flex-col gap-2.5">
|
|
74
95
|
{#each triggers as trigger (trigger.id + ':' + run.visitedNodeIds.length)}
|
|
75
|
-
<TestTriggerCard
|
|
96
|
+
<TestTriggerCard
|
|
97
|
+
{trigger}
|
|
98
|
+
isCurrentComposition={findCompositionOfTrigger(editor.graph, trigger.id) ===
|
|
99
|
+
run.currentNodeId}
|
|
100
|
+
result={lastFiredTriggerId === trigger.id ? cardResult : null}
|
|
101
|
+
onFireStart={rememberFiredTrigger}
|
|
102
|
+
/>
|
|
76
103
|
{/each}
|
|
77
104
|
</div>
|
|
78
105
|
{/if}
|
|
79
|
-
|
|
80
|
-
<ActionButton size="small" class="self-start" onclick={() => editor.restartTestRun()}>
|
|
81
|
-
<Icon name="undo" />
|
|
82
|
-
{$t('workflows.test.restart')}
|
|
83
|
-
</ActionButton>
|
|
84
106
|
{/if}
|
|
85
107
|
</div>
|
|
@@ -7,26 +7,53 @@
|
|
|
7
7
|
-->
|
|
8
8
|
<script lang="ts">
|
|
9
9
|
import type { FieldType, FieldValue, TriggerNode } from '@widgetic/workflows-engine';
|
|
10
|
-
import {
|
|
10
|
+
import type { TestRunResult } from '../../editor/testRun.js';
|
|
11
|
+
import {
|
|
12
|
+
FIELD_TYPE_MESSAGE_KEYS,
|
|
13
|
+
TRIGGER_KIND_MESSAGE_KEYS,
|
|
14
|
+
summarizeTrigger
|
|
15
|
+
} from '../../editor/blockLabels.js';
|
|
11
16
|
import { findCompositionOfTrigger } from '../../editor/canvasWords.js';
|
|
12
17
|
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
13
18
|
import { readTypedValue } from '../../editor/graphModel.js';
|
|
14
19
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
20
|
+
import type { IconName } from '../ui/icons.js';
|
|
15
21
|
import ActionButton from '../ui/ActionButton.svelte';
|
|
16
22
|
import Icon from '../ui/Icon.svelte';
|
|
17
23
|
import SelectField from '../ui/SelectField.svelte';
|
|
18
24
|
import TextField from '../ui/TextField.svelte';
|
|
19
25
|
import type { SelectChoice } from '../ui/types.js';
|
|
26
|
+
import TestResultLine from './TestResultLine.svelte';
|
|
20
27
|
|
|
21
28
|
interface Props {
|
|
22
29
|
trigger: TriggerNode;
|
|
30
|
+
/** The visitor is still on the composition this trigger hangs from. */
|
|
31
|
+
isCurrentComposition?: boolean;
|
|
32
|
+
/** Outcome of the last fire of this trigger, if it was the one fired. */
|
|
33
|
+
result?: { text: string; outcome: TestRunResult['outcome'] } | null;
|
|
34
|
+
/** Called before `fireTrigger` so the panel can attach the result to this card. */
|
|
35
|
+
onFireStart?: (triggerId: string) => void;
|
|
23
36
|
}
|
|
24
37
|
|
|
25
|
-
let { trigger }: Props = $props();
|
|
38
|
+
let { trigger, isCurrentComposition = false, result = null, onFireStart }: Props = $props();
|
|
26
39
|
|
|
27
40
|
const editor = useEditorState();
|
|
28
41
|
const { t, locale } = useWorkflowsLanguage();
|
|
29
42
|
|
|
43
|
+
/** Icon for the trigger kind — matches the canvas block tile language. */
|
|
44
|
+
const kindIcon = $derived.by((): IconName => {
|
|
45
|
+
switch (trigger.trigger.kind) {
|
|
46
|
+
case 'input':
|
|
47
|
+
return 'forms';
|
|
48
|
+
case 'action':
|
|
49
|
+
return 'click';
|
|
50
|
+
case 'pageEvent':
|
|
51
|
+
return 'bolt';
|
|
52
|
+
case 'scheduled':
|
|
53
|
+
return 'clock';
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
30
57
|
interface TestValueField {
|
|
31
58
|
name: string;
|
|
32
59
|
label: string;
|
|
@@ -81,6 +108,7 @@
|
|
|
81
108
|
|
|
82
109
|
/** Fires the trigger with the values typed; a text box left empty carries no value, as an empty value would not. */
|
|
83
110
|
function fire(): void {
|
|
111
|
+
onFireStart?.(trigger.id);
|
|
84
112
|
const values: Record<string, FieldValue> = {};
|
|
85
113
|
for (const field of fields) {
|
|
86
114
|
const text = readTyped(field);
|
|
@@ -92,8 +120,25 @@
|
|
|
92
120
|
}
|
|
93
121
|
</script>
|
|
94
122
|
|
|
95
|
-
<div
|
|
96
|
-
|
|
123
|
+
<div
|
|
124
|
+
class="flex w-full max-w-full flex-col gap-2.5 rounded-xl border bg-background p-3 transition-colors duration-fast {isCurrentComposition
|
|
125
|
+
? 'border-primary ring-2 ring-primary'
|
|
126
|
+
: 'border-border'}"
|
|
127
|
+
>
|
|
128
|
+
<div class="flex items-center gap-2">
|
|
129
|
+
<span
|
|
130
|
+
class="flex size-6 shrink-0 items-center justify-center rounded-full bg-brand-subtle"
|
|
131
|
+
aria-hidden="true"
|
|
132
|
+
>
|
|
133
|
+
<Icon name={kindIcon} class="size-4 text-brand-foreground" />
|
|
134
|
+
</span>
|
|
135
|
+
<p class="min-w-0 flex-1 truncate text-caption-medium text-muted-foreground">
|
|
136
|
+
{$t(TRIGGER_KIND_MESSAGE_KEYS[trigger.trigger.kind])}
|
|
137
|
+
</p>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<p class="text-body-medium text-foreground break-words" dir="auto">{summary}</p>
|
|
141
|
+
|
|
97
142
|
{#each fields as field (field.name)}
|
|
98
143
|
{#if field.type === 'boolean'}
|
|
99
144
|
<SelectField
|
|
@@ -101,6 +146,7 @@
|
|
|
101
146
|
value={readTyped(field)}
|
|
102
147
|
choices={yesNoChoices}
|
|
103
148
|
help={$t(FIELD_TYPE_MESSAGE_KEYS[field.type])}
|
|
149
|
+
disabled={editor.isReadOnly}
|
|
104
150
|
onchange={(text) => (typed[field.name] = text)}
|
|
105
151
|
/>
|
|
106
152
|
{:else}
|
|
@@ -110,12 +156,26 @@
|
|
|
110
156
|
inputmode={field.type === 'number' ? 'decimal' : 'text'}
|
|
111
157
|
maxlength={200}
|
|
112
158
|
help={$t(FIELD_TYPE_MESSAGE_KEYS[field.type])}
|
|
159
|
+
disabled={editor.isReadOnly}
|
|
113
160
|
bind:value={() => readTyped(field), (text) => (typed[field.name] = text)}
|
|
114
161
|
/>
|
|
115
162
|
{/if}
|
|
116
163
|
{/each}
|
|
117
|
-
|
|
118
|
-
|
|
164
|
+
|
|
165
|
+
<ActionButton
|
|
166
|
+
variant="outline"
|
|
167
|
+
size="small"
|
|
168
|
+
class="self-start"
|
|
169
|
+
disabled={editor.isReadOnly}
|
|
170
|
+
onclick={fire}
|
|
171
|
+
>
|
|
172
|
+
<Icon name="bolt" />
|
|
119
173
|
{$t('workflows.test.fire')}
|
|
120
174
|
</ActionButton>
|
|
175
|
+
|
|
176
|
+
{#if result}
|
|
177
|
+
<div class="border-t border-border pt-2.5">
|
|
178
|
+
<TestResultLine text={result.text} outcome={result.outcome} />
|
|
179
|
+
</div>
|
|
180
|
+
{/if}
|
|
121
181
|
</div>
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { TriggerNode } from '@widgetic/workflows-engine';
|
|
2
|
+
import type { TestRunResult } from '../../editor/testRun.js';
|
|
2
3
|
interface Props {
|
|
3
4
|
trigger: TriggerNode;
|
|
5
|
+
/** The visitor is still on the composition this trigger hangs from. */
|
|
6
|
+
isCurrentComposition?: boolean;
|
|
7
|
+
/** Outcome of the last fire of this trigger, if it was the one fired. */
|
|
8
|
+
result?: {
|
|
9
|
+
text: string;
|
|
10
|
+
outcome: TestRunResult['outcome'];
|
|
11
|
+
} | null;
|
|
12
|
+
/** Called before `fireTrigger` so the panel can attach the result to this card. */
|
|
13
|
+
onFireStart?: (triggerId: string) => void;
|
|
4
14
|
}
|
|
5
15
|
declare const TestTriggerCard: import("svelte").Component<Props, {}, "">;
|
|
6
16
|
type TestTriggerCard = ReturnType<typeof TestTriggerCard>;
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
40
40
|
import ActionButton from '../ui/ActionButton.svelte';
|
|
41
41
|
import Icon from '../ui/Icon.svelte';
|
|
42
|
+
import Notice from '../ui/Notice.svelte';
|
|
42
43
|
import SelectField from '../ui/SelectField.svelte';
|
|
43
44
|
import TextField from '../ui/TextField.svelte';
|
|
44
45
|
import type { SelectChoice } from '../ui/types.js';
|
|
@@ -236,10 +237,8 @@
|
|
|
236
237
|
</script>
|
|
237
238
|
|
|
238
239
|
<div class="flex flex-col gap-4">
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
<p class="text-xs text-ink-muted">{$t('workflows.trigger.help')}</p>
|
|
242
|
-
</div>
|
|
240
|
+
<!-- The panel's head names the block ("Trigger"); the form starts with what the block is for. -->
|
|
241
|
+
<p class="text-body text-muted-foreground">{$t('workflows.trigger.help')}</p>
|
|
243
242
|
|
|
244
243
|
<BlockProblems nodeId={node.id} />
|
|
245
244
|
|
|
@@ -251,11 +250,13 @@
|
|
|
251
250
|
onchange={chooseKind}
|
|
252
251
|
/>
|
|
253
252
|
{#if unavailableNotes.length > 0}
|
|
254
|
-
<
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
253
|
+
<Notice tone="info" class="rounded-xl">
|
|
254
|
+
<ul class="flex flex-col gap-1">
|
|
255
|
+
{#each unavailableNotes as note (note)}
|
|
256
|
+
<li class="text-caption text-muted-foreground">{note}</li>
|
|
257
|
+
{/each}
|
|
258
|
+
</ul>
|
|
259
|
+
</Notice>
|
|
259
260
|
{/if}
|
|
260
261
|
|
|
261
262
|
{#if trigger.kind === 'input'}
|
|
@@ -268,7 +269,7 @@
|
|
|
268
269
|
onchange={(table) => editor.replaceBlock({ ...node, trigger: { kind: 'input', table } })}
|
|
269
270
|
/>
|
|
270
271
|
{#if trigger.table !== ''}
|
|
271
|
-
<p class="text-
|
|
272
|
+
<p class="text-caption text-muted-foreground">
|
|
272
273
|
{readableColumns.length > 0
|
|
273
274
|
? $t('workflows.trigger.readableValues', { values: readableColumns.join(', ') })
|
|
274
275
|
: $t('workflows.trigger.noReadableValues')}
|
|
@@ -295,9 +296,11 @@
|
|
|
295
296
|
bind:value={eventNameDraft}
|
|
296
297
|
onchange={commitEventName}
|
|
297
298
|
/>
|
|
298
|
-
<div class="flex flex-col gap-
|
|
299
|
-
<
|
|
300
|
-
|
|
299
|
+
<div class="flex flex-col gap-4">
|
|
300
|
+
<div class="flex flex-col gap-1.5">
|
|
301
|
+
<h4 class="text-body-medium text-foreground">{$t('workflows.event.valuesHeading')}</h4>
|
|
302
|
+
<p class="text-caption text-muted-foreground">{$t('workflows.event.valuesHelp')}</p>
|
|
303
|
+
</div>
|
|
301
304
|
{#each trigger.values as value, index (index)}
|
|
302
305
|
<EventValueRow
|
|
303
306
|
{value}
|
|
@@ -309,6 +312,7 @@
|
|
|
309
312
|
{/each}
|
|
310
313
|
{#if !editor.isReadOnly}
|
|
311
314
|
<ActionButton
|
|
315
|
+
variant="ghost"
|
|
312
316
|
size="small"
|
|
313
317
|
class="self-start"
|
|
314
318
|
disabled={trigger.values.length >= MAX_EVENT_VALUES}
|
|
@@ -319,7 +323,7 @@
|
|
|
319
323
|
</ActionButton>
|
|
320
324
|
{/if}
|
|
321
325
|
</div>
|
|
322
|
-
<p class="text-
|
|
326
|
+
<p class="text-caption text-muted-foreground">{$t('workflows.event.howToSend')}</p>
|
|
323
327
|
{:else if schedule}
|
|
324
328
|
<SelectField
|
|
325
329
|
label={$t('workflows.schedule.modeLabel')}
|
|
@@ -329,9 +333,9 @@
|
|
|
329
333
|
onchange={chooseScheduleMode}
|
|
330
334
|
/>
|
|
331
335
|
{#if schedule.mode === 'after'}
|
|
332
|
-
<div class="flex items-
|
|
336
|
+
<div class="flex flex-wrap items-end gap-2">
|
|
333
337
|
<TextField
|
|
334
|
-
class="w-24"
|
|
338
|
+
class="w-24 min-w-24"
|
|
335
339
|
type="number"
|
|
336
340
|
min={1}
|
|
337
341
|
inputmode="numeric"
|
|
@@ -341,7 +345,7 @@
|
|
|
341
345
|
onchange={commitWaitAmount}
|
|
342
346
|
/>
|
|
343
347
|
<SelectField
|
|
344
|
-
class="flex-1"
|
|
348
|
+
class="min-w-0 flex-1"
|
|
345
349
|
label={$t('workflows.schedule.unitLabel')}
|
|
346
350
|
value={schedule.unit}
|
|
347
351
|
choices={unitChoices}
|
|
@@ -349,7 +353,7 @@
|
|
|
349
353
|
onchange={chooseUnit}
|
|
350
354
|
/>
|
|
351
355
|
</div>
|
|
352
|
-
<p class="text-
|
|
356
|
+
<p class="text-caption text-muted-foreground">{$t('workflows.schedule.afterHelp')}</p>
|
|
353
357
|
{:else}
|
|
354
358
|
<TextField
|
|
355
359
|
type="datetime-local"
|
|
@@ -372,13 +376,8 @@
|
|
|
372
376
|
/>
|
|
373
377
|
|
|
374
378
|
{#if !editor.isReadOnly}
|
|
375
|
-
<ActionButton
|
|
376
|
-
|
|
377
|
-
size="small"
|
|
378
|
-
class="self-start"
|
|
379
|
-
onclick={() => editor.removeBlock(node.id)}
|
|
380
|
-
>
|
|
381
|
-
<Icon name="trash" />
|
|
379
|
+
<ActionButton variant="secondary" class="w-full" onclick={() => editor.removeBlock(node.id)}>
|
|
380
|
+
<Icon name="trash" class="size-4" />
|
|
382
381
|
{$t('workflows.panel.removeBlock')}
|
|
383
382
|
</ActionButton>
|
|
384
383
|
{/if}
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
import { useEditorState } from '../../editor/editorState.svelte.js';
|
|
12
12
|
import { useWorkflowsLanguage } from '../../i18n/language.js';
|
|
13
13
|
import ActionButton from '../ui/ActionButton.svelte';
|
|
14
|
+
import Badge from '../ui/Badge.svelte';
|
|
14
15
|
import ConfirmDialog from '../ui/ConfirmDialog.svelte';
|
|
15
|
-
import Icon from '../ui/Icon.svelte';
|
|
16
16
|
|
|
17
17
|
const editor = useEditorState();
|
|
18
18
|
const { t, locale } = useWorkflowsLanguage();
|
|
@@ -28,21 +28,7 @@
|
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
30
|
<div class="flex flex-col gap-4">
|
|
31
|
-
<
|
|
32
|
-
<div>
|
|
33
|
-
<h3 class="text-sm font-semibold">{$t('workflows.history.heading')}</h3>
|
|
34
|
-
<p class="text-xs text-ink-muted">{$t('workflows.history.help')}</p>
|
|
35
|
-
</div>
|
|
36
|
-
<ActionButton
|
|
37
|
-
variant="ghost"
|
|
38
|
-
iconOnly
|
|
39
|
-
ariaLabel={$t('workflows.history.close')}
|
|
40
|
-
title={$t('workflows.history.close')}
|
|
41
|
-
onclick={() => editor.closeHistory()}
|
|
42
|
-
>
|
|
43
|
-
<Icon name="close" />
|
|
44
|
-
</ActionButton>
|
|
45
|
-
</div>
|
|
31
|
+
<p class="text-body text-muted-foreground">{$t('workflows.history.help')}</p>
|
|
46
32
|
|
|
47
33
|
<!-- The banner above the canvas says which version is shown and has the way back to the draft; here is what can be done with it. -->
|
|
48
34
|
{#if viewing}
|
|
@@ -59,51 +45,52 @@
|
|
|
59
45
|
{/if}
|
|
60
46
|
|
|
61
47
|
{#if editor.versionsState === 'loading' && editor.versions === null}
|
|
62
|
-
<p class="text-
|
|
48
|
+
<p class="text-caption text-muted-foreground" role="status">{$t('workflows.common.loading')}</p>
|
|
63
49
|
{:else if editor.versionsState === 'failed'}
|
|
64
50
|
<div class="flex flex-col items-start gap-2">
|
|
65
|
-
<p class="text-
|
|
66
|
-
<ActionButton size="small" onclick={() => void editor.loadVersions()}
|
|
67
|
-
|
|
68
|
-
>
|
|
51
|
+
<p class="text-caption text-destructive" role="alert">{$t('workflows.history.failed')}</p>
|
|
52
|
+
<ActionButton variant="outline" size="small" onclick={() => void editor.loadVersions()}>
|
|
53
|
+
{$t('workflows.error.retry')}
|
|
54
|
+
</ActionButton>
|
|
69
55
|
</div>
|
|
70
56
|
{:else if editor.versions !== null && editor.versions.length === 0}
|
|
71
|
-
<p class="text-
|
|
57
|
+
<p class="text-caption text-muted-foreground">{$t('workflows.history.none')}</p>
|
|
72
58
|
{:else if editor.versions !== null}
|
|
73
|
-
<ul class="flex flex-col gap-
|
|
59
|
+
<ul class="flex flex-col gap-1">
|
|
74
60
|
{#each editor.versions as version (version.id)}
|
|
75
61
|
{@const isShown = viewing?.id === version.id}
|
|
76
62
|
<li
|
|
77
|
-
class="flex
|
|
78
|
-
? '
|
|
79
|
-
: '
|
|
63
|
+
class="flex w-full min-w-0 items-center gap-3 rounded-lg px-3 py-2.5 transition-colors duration-fast hover:bg-accent {isShown
|
|
64
|
+
? 'bg-accent'
|
|
65
|
+
: ''}"
|
|
80
66
|
>
|
|
81
|
-
<div class="flex min-w-0 flex-col gap-0.5">
|
|
82
|
-
<
|
|
83
|
-
|
|
67
|
+
<div class="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
68
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
69
|
+
<span class="text-body-medium text-foreground">
|
|
70
|
+
{$t('workflows.history.version', { number: version.versionNumber })}
|
|
71
|
+
</span>
|
|
84
72
|
{#if version.isLive}
|
|
85
|
-
<
|
|
86
|
-
class="rounded-pill border border-primary-green px-2 text-xs font-normal text-primary-green"
|
|
87
|
-
>{$t('workflows.history.live')}</span
|
|
88
|
-
>
|
|
73
|
+
<Badge tone="brand" showDot>{$t('workflows.history.live')}</Badge>
|
|
89
74
|
{/if}
|
|
75
|
+
</div>
|
|
76
|
+
<span class="text-caption text-muted-foreground" dir="auto">
|
|
77
|
+
{version.publishedBy?.name
|
|
78
|
+
? $t('workflows.history.byOn', {
|
|
79
|
+
name: version.publishedBy.name,
|
|
80
|
+
date: formatMomentInZone(version.publishedAt, $locale, editor.timezone)
|
|
81
|
+
})
|
|
82
|
+
: formatMomentInZone(version.publishedAt, $locale, editor.timezone)}
|
|
90
83
|
</span>
|
|
91
|
-
<span class="text-xs text-ink-muted"
|
|
92
|
-
>{formatMomentInZone(version.publishedAt, $locale, editor.timezone)}</span
|
|
93
|
-
>
|
|
94
|
-
{#if version.publishedBy?.name}
|
|
95
|
-
<span class="truncate text-xs text-ink-muted" dir="auto"
|
|
96
|
-
>{$t('workflows.history.by', { name: version.publishedBy.name })}</span
|
|
97
|
-
>
|
|
98
|
-
{/if}
|
|
99
84
|
</div>
|
|
100
85
|
<ActionButton
|
|
86
|
+
variant="ghost"
|
|
101
87
|
size="small"
|
|
88
|
+
class="shrink-0"
|
|
102
89
|
pressed={isShown}
|
|
103
90
|
disabled={editor.busy !== null}
|
|
104
91
|
onclick={() => void editor.viewVersion(version.id)}
|
|
105
92
|
>
|
|
106
|
-
{$t('workflows.history.view')}
|
|
93
|
+
{isShown ? $t('workflows.history.viewingShort') : $t('workflows.history.view')}
|
|
107
94
|
</ActionButton>
|
|
108
95
|
</li>
|
|
109
96
|
{/each}
|
|
@@ -115,7 +102,8 @@
|
|
|
115
102
|
<ConfirmDialog
|
|
116
103
|
title={$t('workflows.history.restoreTitle', { number: viewing.versionNumber })}
|
|
117
104
|
message={$t('workflows.history.restoreMessage', { number: viewing.versionNumber })}
|
|
118
|
-
confirmLabel={$t('workflows.history.
|
|
105
|
+
confirmLabel={$t('workflows.history.restoreConfirm')}
|
|
106
|
+
tone="normal"
|
|
119
107
|
busy={editor.busy === 'restoring'}
|
|
120
108
|
onconfirm={() => void restore()}
|
|
121
109
|
oncancel={() => (isAskingToRestore = false)}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
A button of the screen. One place decides how a button looks (the
|
|
2
|
+
A button of the screen. One place decides how a button looks (the colours, the corners, the focus ring), so every button
|
|
3
3
|
of the screen answers a theme the same way. The words on it are given by the caller, already in the page's language.
|
|
4
4
|
|
|
5
|
+
The looks are the design system's button (Figma "Button" and "Button Small", "Icon Button"): `primary` is the one thing
|
|
6
|
+
to do on a screen, `outline` is the usual button, `secondary` is the same without the line, `ghost` is the quietest,
|
|
7
|
+
`accent` is the sage one of the canvas, `danger` takes something away.
|
|
8
|
+
|
|
5
9
|
`iconOnly` makes it a square with a picture and no words: the caller must then give `ariaLabel`, because a picture says
|
|
6
10
|
nothing to a screen reader.
|
|
7
11
|
-->
|
|
@@ -10,7 +14,8 @@
|
|
|
10
14
|
|
|
11
15
|
interface Props {
|
|
12
16
|
/** How loud the button is: `primary` is the one thing to do on a screen; `danger` takes something away. */
|
|
13
|
-
variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
17
|
+
variant?: 'primary' | 'outline' | 'secondary' | 'ghost' | 'accent' | 'danger';
|
|
18
|
+
/** `medium` is 36 high (32 square when `iconOnly`), `small` is 32 high (28 square). */
|
|
14
19
|
size?: 'small' | 'medium';
|
|
15
20
|
type?: 'button' | 'submit';
|
|
16
21
|
disabled?: boolean;
|
|
@@ -33,7 +38,7 @@
|
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
let {
|
|
36
|
-
variant = '
|
|
41
|
+
variant = 'outline',
|
|
37
42
|
size = 'medium',
|
|
38
43
|
type = 'button',
|
|
39
44
|
disabled = false,
|
|
@@ -50,20 +55,47 @@
|
|
|
50
55
|
}: Props = $props();
|
|
51
56
|
|
|
52
57
|
const variantClasses = {
|
|
53
|
-
primary: 'bg-primary
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
primary: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
59
|
+
outline:
|
|
60
|
+
'border border-input bg-background text-foreground hover:bg-accent hover:text-foreground aria-pressed:bg-accent',
|
|
61
|
+
secondary:
|
|
62
|
+
'bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground aria-pressed:bg-accent',
|
|
63
|
+
ghost: 'text-foreground hover:bg-accent hover:text-foreground aria-pressed:bg-accent',
|
|
64
|
+
accent: 'bg-brand text-brand-foreground hover:bg-brand/90',
|
|
65
|
+
danger: 'bg-destructive text-destructive-foreground hover:bg-destructive/90'
|
|
57
66
|
};
|
|
58
67
|
|
|
68
|
+
// A round button of a picture is the loud one (the plus of the list on a narrow screen); the quiet ones keep the corner.
|
|
69
|
+
const shapeClasses = $derived(
|
|
70
|
+
iconOnly && (variant === 'primary' || variant === 'accent') ? 'rounded-full' : 'rounded-lg'
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The sides of a button, as Figma draws them (Button and Button Small): the button pads 12 (small 8) and the words sit in a
|
|
75
|
+
* box with 4 more on each side, so a button with only words is the words + 32 wide (small + 24), one with a picture first is
|
|
76
|
+
* the words + 48 (small + 40) and one with a picture at each end is the words + 64 (small + 48). CSS cannot tell a picture
|
|
77
|
+
* before the words from one after them (words are no element), so the first picture is taken as the one before; the width
|
|
78
|
+
* is the same either way. The 1px line of the outline button sits inside the padding in Figma and takes no room, but a CSS
|
|
79
|
+
* border sits outside it, so that button gives 1px of every side to it. The same numbers as the design system's Button.
|
|
80
|
+
*/
|
|
81
|
+
const sideClasses = $derived.by(() => {
|
|
82
|
+
const hasLine = variant === 'outline';
|
|
83
|
+
if (size === 'small') {
|
|
84
|
+
return hasLine
|
|
85
|
+
? 'px-[11px] has-[>svg]:ps-[7px] has-[>svg:nth-of-type(2)]:pe-[7px]'
|
|
86
|
+
: 'px-3 has-[>svg]:ps-2 has-[>svg:nth-of-type(2)]:pe-2';
|
|
87
|
+
}
|
|
88
|
+
return hasLine
|
|
89
|
+
? 'px-[15px] has-[>svg]:ps-[11px] has-[>svg:nth-of-type(2)]:pe-[11px]'
|
|
90
|
+
: 'px-4 has-[>svg]:ps-3 has-[>svg:nth-of-type(2)]:pe-3';
|
|
91
|
+
});
|
|
92
|
+
|
|
59
93
|
const sizeClasses = $derived(
|
|
60
94
|
iconOnly
|
|
61
95
|
? size === 'small'
|
|
62
96
|
? 'size-7'
|
|
63
|
-
: 'size-
|
|
64
|
-
: size === 'small'
|
|
65
|
-
? 'px-2.5 py-1 text-xs'
|
|
66
|
-
: 'px-4 py-2 text-sm'
|
|
97
|
+
: 'size-8'
|
|
98
|
+
: `${size === 'small' ? 'h-8' : 'h-9'} ${sideClasses}`
|
|
67
99
|
);
|
|
68
100
|
</script>
|
|
69
101
|
|
|
@@ -71,7 +103,7 @@
|
|
|
71
103
|
{type}
|
|
72
104
|
{disabled}
|
|
73
105
|
{title}
|
|
74
|
-
class="inline-flex shrink-0 items-center justify-center gap-
|
|
106
|
+
class="press-feedback inline-flex shrink-0 items-center justify-center gap-1 text-label whitespace-nowrap transition-colors duration-fast focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 {shapeClasses} {variantClasses[
|
|
75
107
|
variant
|
|
76
108
|
]} {sizeClasses} {className}"
|
|
77
109
|
aria-label={ariaLabel}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
interface Props {
|
|
3
3
|
/** How loud the button is: `primary` is the one thing to do on a screen; `danger` takes something away. */
|
|
4
|
-
variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
4
|
+
variant?: 'primary' | 'outline' | 'secondary' | 'ghost' | 'accent' | 'danger';
|
|
5
|
+
/** `medium` is 36 high (32 square when `iconOnly`), `small` is 32 high (28 square). */
|
|
5
6
|
size?: 'small' | 'medium';
|
|
6
7
|
type?: 'button' | 'submit';
|
|
7
8
|
disabled?: boolean;
|