@widgetic/workflows 0.2.10 → 0.2.12
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 +11 -13
- package/dist/api/workflowsApi.d.ts +9 -1
- package/dist/api/workflowsApi.js +2 -1
- package/dist/assistant/assistantEvents.d.ts +42 -0
- package/dist/assistant/assistantEvents.js +61 -0
- package/dist/assistant/assistantRemoteChange.d.ts +4 -0
- package/dist/assistant/assistantRemoteChange.js +8 -0
- package/dist/assistant/assistantSaveMode.d.ts +5 -0
- package/dist/assistant/assistantSaveMode.js +8 -0
- package/dist/assistant/assistantStream.d.ts +8 -0
- package/dist/assistant/assistantStream.js +140 -0
- package/dist/assistant/assistantTranscript.d.ts +11 -0
- package/dist/assistant/assistantTranscript.js +18 -0
- package/dist/assistant/types.d.ts +81 -0
- package/dist/assistant/types.js +1 -0
- package/dist/assistant/workflowPlanViewModel.d.ts +48 -0
- package/dist/assistant/workflowPlanViewModel.js +17 -0
- package/dist/components/Workflows.svelte +3 -1
- package/dist/components/WorkflowsEmptyState.svelte +15 -3
- package/dist/components/WorkflowsEmptyState.svelte.d.ts +2 -0
- package/dist/components/WorkflowsWorkspace.svelte +4 -0
- package/dist/components/WorkflowsWorkspace.svelte.d.ts +1 -0
- package/dist/components/assistant/WorkflowAssistantPanel.svelte +384 -0
- package/dist/components/assistant/WorkflowAssistantPanel.svelte.d.ts +8 -0
- package/dist/components/canvas/CompositionNodeView.svelte +5 -5
- package/dist/components/canvas/ConditionNodeView.svelte +4 -4
- package/dist/components/canvas/HandlePoint.svelte +1 -1
- package/dist/components/canvas/TriggerNodeView.svelte +5 -4
- package/dist/components/canvas/WorkflowCanvas.svelte +16 -6
- package/dist/components/canvas/WorkflowCanvas.svelte.d.ts +2 -2
- package/dist/components/editor/EditorCanvasArea.svelte +57 -2
- package/dist/components/editor/EditorCanvasArea.svelte.d.ts +8 -1
- package/dist/components/editor/EditorTabs.svelte +1 -2
- package/dist/components/editor/EditorTopBar.svelte +29 -21
- package/dist/components/editor/EditorTopBar.svelte.d.ts +3 -0
- package/dist/components/editor/RunsFlow.svelte +73 -23
- package/dist/components/editor/WorkflowEditor.svelte +31 -3
- package/dist/components/editor/WorkflowEditor.svelte.d.ts +5 -0
- package/dist/components/editor/WorkflowNameControl.svelte +136 -0
- package/dist/components/editor/WorkflowNameControl.svelte.d.ts +13 -0
- package/dist/components/list/WorkflowList.svelte +112 -60
- package/dist/components/list/WorkflowList.svelte.d.ts +2 -0
- package/dist/components/list/WorkflowRow.svelte +2 -0
- package/dist/components/panel/ConditionForm.svelte +7 -7
- package/dist/components/ui/Menu.svelte +31 -7
- package/dist/components/ui/Menu.svelte.d.ts +4 -0
- package/dist/components/ui/icons.d.ts +2 -0
- package/dist/components/ui/icons.js +3 -1
- package/dist/drafts/draftJournal.d.ts +59 -0
- package/dist/drafts/draftJournal.js +261 -0
- package/dist/drafts/workflowDraft.d.ts +72 -0
- package/dist/drafts/workflowDraft.js +151 -0
- package/dist/drafts/workflowListViewState.d.ts +30 -0
- package/dist/drafts/workflowListViewState.js +92 -0
- package/dist/editor/createBlankWorkflow.d.ts +30 -0
- package/dist/editor/createBlankWorkflow.js +37 -0
- package/dist/editor/editorState.svelte.d.ts +68 -2
- package/dist/editor/editorState.svelte.js +273 -0
- package/dist/editor/listState.svelte.d.ts +73 -36
- package/dist/editor/listState.svelte.js +260 -46
- package/dist/editor/presetChoice.d.ts +4 -4
- package/dist/editor/presetChoice.js +4 -4
- package/dist/editor/runsFlowBandLabel.d.ts +16 -0
- package/dist/editor/runsFlowBandLabel.js +34 -0
- package/dist/editor/runsFlowLayout.d.ts +24 -9
- package/dist/editor/runsFlowLayout.js +73 -28
- package/dist/editor/workflowNameCommit.d.ts +12 -0
- package/dist/editor/workflowNameCommit.js +11 -0
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/messages.d.ts +40 -26
- package/dist/i18n/messages.js +43 -30
- package/dist/types/index.d.ts +4 -0
- package/package.json +8 -1
- package/dist/components/list/CreateWorkflowDialog.svelte +0 -262
- package/dist/components/list/CreateWorkflowDialog.svelte.d.ts +0 -9
|
@@ -4,12 +4,15 @@ import { WORKFLOW_STATUSES } from '../api/types.js';
|
|
|
4
4
|
import { workflowsError, workflowsWarn } from '../utils/logger.js';
|
|
5
5
|
import { pickApiErrorMessage } from './apiErrorText.js';
|
|
6
6
|
import { EditingWatcher } from './editingWatcher.js';
|
|
7
|
+
import { BLANK_WORKFLOW_NAME, createBlankWorkflowAndOpen } from './createBlankWorkflow.js';
|
|
7
8
|
import { detectBrowserTimeZone } from './zonedTime.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
export
|
|
12
|
-
|
|
9
|
+
import { createDraftJournal } from '../drafts/draftJournal.js';
|
|
10
|
+
import { WORKFLOW_NEW_DIALOG_DRAFT_NAMESPACE, listViewStateStorageKey, parseListViewStateEntry, serializeListViewState, validateWorkflowListViewState } from '../drafts/workflowListViewState.js';
|
|
11
|
+
/** The tabs of the list, in the order the design draws them. */
|
|
12
|
+
export const LIST_TABS = ['all', ...WORKFLOW_STATUSES];
|
|
13
|
+
/** Whether what a control reported is one of the tabs (a select reports plain text). */
|
|
14
|
+
export function isListTab(value) {
|
|
15
|
+
return LIST_TABS.includes(value);
|
|
13
16
|
}
|
|
14
17
|
/** One page of the list is this many workflows; "Show more" reads the next. */
|
|
15
18
|
export const LIST_PAGE_SIZE = 25;
|
|
@@ -27,12 +30,8 @@ export class WorkflowListState {
|
|
|
27
30
|
loadingMore = $state(false);
|
|
28
31
|
failure = $state.raw(null);
|
|
29
32
|
search = $state('');
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* The tab that is open. It is kept here and not worked out from `statusFilter`: once one state is chosen in the Status menu
|
|
33
|
-
* the filter no longer says which tab it was chosen under, and the tab must not move by itself.
|
|
34
|
-
*/
|
|
35
|
-
scope = $state('active');
|
|
33
|
+
/** The status tab that is open (`all` = the API’s default list, not archived). */
|
|
34
|
+
tab = $state('all');
|
|
36
35
|
sortField = $state('createdAt');
|
|
37
36
|
sortDirection = $state('desc');
|
|
38
37
|
/** Workflows something is being done to (a duplicate on its way, a state change). */
|
|
@@ -50,9 +49,7 @@ export class WorkflowListState {
|
|
|
50
49
|
/** Whether there is more of the list than is shown. */
|
|
51
50
|
hasMore = $derived(this.items.length < this.total);
|
|
52
51
|
/** Whether the person asked for anything that narrows the list (so "nothing" means "nothing matches", not "nothing yet"). */
|
|
53
|
-
isNarrowed = $derived(this.search.trim() !== '' || this.
|
|
54
|
-
/** What the Status menu shows: the one state the list is narrowed to, or `any` when the tab alone decides. */
|
|
55
|
-
statusChoice = $derived(this.statusFilter === '' || this.statusFilter === 'all' ? 'any' : this.statusFilter);
|
|
52
|
+
isNarrowed = $derived(this.search.trim() !== '' || this.tab !== 'all');
|
|
56
53
|
/**
|
|
57
54
|
* The presets "New workflow" offers, as the API gave them the last time they were read (none until then, and none when
|
|
58
55
|
* the workspace is offered none: the dialog then has only the blank start, as it always had).
|
|
@@ -68,6 +65,19 @@ export class WorkflowListState {
|
|
|
68
65
|
* time it opens, so a start is blank until somebody chooses otherwise, and a key that is no longer on offer means blank too.
|
|
69
66
|
*/
|
|
70
67
|
chosenPresetKey = $state(null);
|
|
68
|
+
/** Whether the host's "New workflow" dialog is open (preset start and name). */
|
|
69
|
+
newWorkflowDialogOpen = $state(false);
|
|
70
|
+
/** Name typed into the new-workflow dialog before it is sent. */
|
|
71
|
+
newWorkflowDialogName = $state('');
|
|
72
|
+
/** Row whose menu was open when the person left; restored when that row is still in the list. */
|
|
73
|
+
openMenuWorkflowId = $state(null);
|
|
74
|
+
/** Scroll offset of the list body, restored after reload. */
|
|
75
|
+
listScrollTop = $state(0);
|
|
76
|
+
workspaceId;
|
|
77
|
+
viewStateStorage;
|
|
78
|
+
dialogJournal;
|
|
79
|
+
viewStateWriteTimer = null;
|
|
80
|
+
restoredViewState = false;
|
|
71
81
|
api;
|
|
72
82
|
reportError;
|
|
73
83
|
searchDelay;
|
|
@@ -86,6 +96,19 @@ export class WorkflowListState {
|
|
|
86
96
|
*/
|
|
87
97
|
unresolvedStart = null;
|
|
88
98
|
constructor(options) {
|
|
99
|
+
this.workspaceId = options.workspaceId;
|
|
100
|
+
this.viewStateStorage =
|
|
101
|
+
options.viewStateStorage !== undefined
|
|
102
|
+
? options.viewStateStorage
|
|
103
|
+
: typeof sessionStorage !== 'undefined'
|
|
104
|
+
? sessionStorage
|
|
105
|
+
: null;
|
|
106
|
+
if (options.dialogDraftJournal !== undefined) {
|
|
107
|
+
this.dialogJournal = options.dialogDraftJournal;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.dialogJournal = createDraftJournal(WORKFLOW_NEW_DIALOG_DRAFT_NAMESPACE, options.dialogDraftJournalOptions ?? {});
|
|
111
|
+
}
|
|
89
112
|
this.api = options.api;
|
|
90
113
|
this.reportError = options.reportError;
|
|
91
114
|
this.searchDelay = options.searchDelayMilliseconds ?? SEARCH_DELAY_MILLISECONDS;
|
|
@@ -123,12 +146,178 @@ export class WorkflowListState {
|
|
|
123
146
|
if (this.searchTimer !== null)
|
|
124
147
|
clearTimeout(this.searchTimer);
|
|
125
148
|
this.searchTimer = null;
|
|
149
|
+
if (this.viewStateWriteTimer !== null)
|
|
150
|
+
clearTimeout(this.viewStateWriteTimer);
|
|
151
|
+
this.viewStateWriteTimer = null;
|
|
152
|
+
this.persistListViewStateNow();
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Reads session view state and the new-workflow dialog journal once, before the first load.
|
|
156
|
+
* Safe to call only once per opening of the list.
|
|
157
|
+
*/
|
|
158
|
+
restorePersistedState() {
|
|
159
|
+
if (this.restoredViewState)
|
|
160
|
+
return;
|
|
161
|
+
this.restoredViewState = true;
|
|
162
|
+
this.restoreListViewState();
|
|
163
|
+
this.restoreNewWorkflowDialogDraft();
|
|
164
|
+
}
|
|
165
|
+
workflowIdSet() {
|
|
166
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
167
|
+
return new Set(this.items.map((item) => item.id));
|
|
168
|
+
}
|
|
169
|
+
presetKeySet() {
|
|
170
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
171
|
+
return new Set(this.presets.map((preset) => preset.key));
|
|
172
|
+
}
|
|
173
|
+
restoreListViewState() {
|
|
174
|
+
const storage = this.viewStateStorage;
|
|
175
|
+
if (!storage)
|
|
176
|
+
return;
|
|
177
|
+
let raw;
|
|
178
|
+
try {
|
|
179
|
+
raw = storage.getItem(listViewStateStorageKey(this.workspaceId));
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const parsed = parseListViewStateEntry(raw);
|
|
185
|
+
if (!parsed)
|
|
186
|
+
return;
|
|
187
|
+
// Menu id is checked again once rows are loaded (`reconcileOpenMenuWithItems`).
|
|
188
|
+
const validated = validateWorkflowListViewState({ ...parsed, openMenuWorkflowId: null }, new Set());
|
|
189
|
+
if (!validated)
|
|
190
|
+
return;
|
|
191
|
+
this.search = validated.search;
|
|
192
|
+
this.tab = validated.tab;
|
|
193
|
+
this.sortField = validated.sortField;
|
|
194
|
+
this.sortDirection = validated.sortDirection;
|
|
195
|
+
this.listScrollTop = validated.scrollTop;
|
|
196
|
+
if (typeof parsed.openMenuWorkflowId === 'string') {
|
|
197
|
+
this.openMenuWorkflowId = parsed.openMenuWorkflowId;
|
|
198
|
+
}
|
|
199
|
+
else if (parsed.openMenuWorkflowId === null) {
|
|
200
|
+
this.openMenuWorkflowId = null;
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
console.debug('[workflowList] Restored list view state', { workspaceId: this.workspaceId });
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
// ignore
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
restoreNewWorkflowDialogDraft() {
|
|
210
|
+
if (!this.dialogJournal)
|
|
211
|
+
return;
|
|
212
|
+
const entry = this.dialogJournal.read(this.workspaceId);
|
|
213
|
+
if (!entry)
|
|
214
|
+
return;
|
|
215
|
+
const candidate = entry.payload;
|
|
216
|
+
if (!candidate || typeof candidate !== 'object' || typeof candidate.isOpen !== 'boolean')
|
|
217
|
+
return;
|
|
218
|
+
this.newWorkflowDialogOpen = candidate.isOpen;
|
|
219
|
+
this.newWorkflowDialogName = typeof candidate.name === 'string' ? candidate.name : '';
|
|
220
|
+
if (typeof candidate.chosenPresetKey === 'string' || candidate.chosenPresetKey === null) {
|
|
221
|
+
this.chosenPresetKey = candidate.chosenPresetKey;
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
console.debug('[workflowList] Restored new-workflow dialog draft', { workspaceId: this.workspaceId });
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
// ignore
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
readNewDialogPayload() {
|
|
231
|
+
return {
|
|
232
|
+
isOpen: this.newWorkflowDialogOpen,
|
|
233
|
+
chosenPresetKey: this.chosenPresetKey,
|
|
234
|
+
name: this.newWorkflowDialogName
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
journalNewDialogFromState() {
|
|
238
|
+
if (!this.dialogJournal)
|
|
239
|
+
return;
|
|
240
|
+
const payload = this.readNewDialogPayload();
|
|
241
|
+
if (!payload.isOpen && payload.name.trim() === '' && payload.chosenPresetKey === null) {
|
|
242
|
+
this.dialogJournal.clear(this.workspaceId);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
this.dialogJournal.write(this.workspaceId, payload, null);
|
|
246
|
+
}
|
|
247
|
+
schedulePersistListViewState() {
|
|
248
|
+
if (!this.viewStateStorage)
|
|
249
|
+
return;
|
|
250
|
+
if (this.viewStateWriteTimer !== null)
|
|
251
|
+
clearTimeout(this.viewStateWriteTimer);
|
|
252
|
+
this.viewStateWriteTimer = setTimeout(() => {
|
|
253
|
+
this.viewStateWriteTimer = null;
|
|
254
|
+
this.persistListViewStateNow();
|
|
255
|
+
}, 250);
|
|
256
|
+
}
|
|
257
|
+
persistListViewState() {
|
|
258
|
+
this.schedulePersistListViewState();
|
|
259
|
+
}
|
|
260
|
+
persistListViewStateNow() {
|
|
261
|
+
const storage = this.viewStateStorage;
|
|
262
|
+
if (!storage)
|
|
263
|
+
return;
|
|
264
|
+
const state = {
|
|
265
|
+
v: 1,
|
|
266
|
+
search: this.search,
|
|
267
|
+
tab: this.tab,
|
|
268
|
+
sortField: this.sortField,
|
|
269
|
+
sortDirection: this.sortDirection,
|
|
270
|
+
scrollTop: this.listScrollTop,
|
|
271
|
+
openMenuWorkflowId: this.openMenuWorkflowId
|
|
272
|
+
};
|
|
273
|
+
try {
|
|
274
|
+
storage.setItem(listViewStateStorageKey(this.workspaceId), serializeListViewState(state));
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
// ignore quota errors for view state
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
followListScroll(scrollTop) {
|
|
281
|
+
if (!Number.isFinite(scrollTop) || scrollTop < 0)
|
|
282
|
+
return;
|
|
283
|
+
this.listScrollTop = scrollTop;
|
|
284
|
+
this.schedulePersistListViewState();
|
|
285
|
+
}
|
|
286
|
+
followRowMenuOpen(workflowId) {
|
|
287
|
+
this.openMenuWorkflowId = workflowId;
|
|
288
|
+
this.schedulePersistListViewState();
|
|
289
|
+
}
|
|
290
|
+
/** Host or dialog UI: keep the new-workflow dialog open state and inputs for a refresh. */
|
|
291
|
+
updateNewWorkflowDialog(patch) {
|
|
292
|
+
if (patch.isOpen !== undefined)
|
|
293
|
+
this.newWorkflowDialogOpen = patch.isOpen;
|
|
294
|
+
if (patch.name !== undefined)
|
|
295
|
+
this.newWorkflowDialogName = patch.name;
|
|
296
|
+
if (patch.chosenPresetKey !== undefined)
|
|
297
|
+
this.chosenPresetKey = patch.chosenPresetKey;
|
|
298
|
+
this.journalNewDialogFromState();
|
|
299
|
+
}
|
|
300
|
+
reconcileOpenMenuWithItems() {
|
|
301
|
+
if (this.openMenuWorkflowId === null)
|
|
302
|
+
return;
|
|
303
|
+
if (!this.items.some((item) => item.id === this.openMenuWorkflowId)) {
|
|
304
|
+
this.openMenuWorkflowId = null;
|
|
305
|
+
this.schedulePersistListViewState();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
reconcileDialogPresetWithPresets() {
|
|
309
|
+
if (this.chosenPresetKey === null)
|
|
310
|
+
return;
|
|
311
|
+
if (!this.presetKeySet().has(this.chosenPresetKey)) {
|
|
312
|
+
this.chosenPresetKey = null;
|
|
313
|
+
this.journalNewDialogFromState();
|
|
314
|
+
}
|
|
126
315
|
}
|
|
127
316
|
buildQuery(offset) {
|
|
128
317
|
const search = this.search.trim();
|
|
129
318
|
return {
|
|
130
319
|
...(search === '' ? {} : { search }),
|
|
131
|
-
...(this.
|
|
320
|
+
...(this.tab === 'all' ? {} : { status: this.tab }),
|
|
132
321
|
sort: { field: this.sortField, direction: this.sortDirection },
|
|
133
322
|
limit: this.pageSize,
|
|
134
323
|
offset
|
|
@@ -148,6 +337,7 @@ export class WorkflowListState {
|
|
|
148
337
|
this.items = page.items;
|
|
149
338
|
this.total = page.total;
|
|
150
339
|
this.loadState = 'ready';
|
|
340
|
+
this.reconcileOpenMenuWithItems();
|
|
151
341
|
this.editingWatcher?.lookSoon();
|
|
152
342
|
}
|
|
153
343
|
catch (error) {
|
|
@@ -192,6 +382,7 @@ export class WorkflowListState {
|
|
|
192
382
|
/** The person typed in the search: ask again once they stop. */
|
|
193
383
|
setSearch(text) {
|
|
194
384
|
this.search = text;
|
|
385
|
+
this.schedulePersistListViewState();
|
|
195
386
|
if (this.searchTimer !== null)
|
|
196
387
|
clearTimeout(this.searchTimer);
|
|
197
388
|
this.searchTimer = setTimeout(() => {
|
|
@@ -200,44 +391,28 @@ export class WorkflowListState {
|
|
|
200
391
|
}, this.searchDelay);
|
|
201
392
|
}
|
|
202
393
|
/**
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*/
|
|
206
|
-
setStatusFilter(filter) {
|
|
207
|
-
if (filter === 'all' || filter === 'archived')
|
|
208
|
-
this.scope = 'all';
|
|
209
|
-
else if (filter === '')
|
|
210
|
-
this.scope = 'active';
|
|
211
|
-
if (filter === this.statusFilter)
|
|
212
|
-
return;
|
|
213
|
-
this.statusFilter = filter;
|
|
214
|
-
void this.load();
|
|
215
|
-
}
|
|
216
|
-
/** A tab was chosen: the list covers what the tab says, and the Status menu goes back to Any. */
|
|
217
|
-
chooseScope(scope) {
|
|
218
|
-
this.setStatusFilter(scope === 'all' ? 'all' : '');
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* A line of the Status menu was chosen. A state narrows the list to it (Archived also opens the second tab, where the
|
|
222
|
-
* archived workflows are), and Any gives the list back to the tab that is open. What a select reports is plain text, so
|
|
223
|
-
* a line the menu does not have is said once and changes nothing.
|
|
394
|
+
* A tab was chosen. `all` asks for the API’s default (not archived); each state asks for that state only. What a control
|
|
395
|
+
* reports is plain text, so a value the list does not offer is said once and changes nothing.
|
|
224
396
|
*/
|
|
225
|
-
|
|
226
|
-
if (!
|
|
227
|
-
workflowsWarn(`The
|
|
397
|
+
chooseTab(choice) {
|
|
398
|
+
if (!isListTab(choice)) {
|
|
399
|
+
workflowsWarn(`The list filter reported "${choice}", which it does not offer; the list is left as it is.`);
|
|
228
400
|
return;
|
|
229
401
|
}
|
|
230
|
-
if (choice ===
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
402
|
+
if (choice === this.tab)
|
|
403
|
+
return;
|
|
404
|
+
this.tab = choice;
|
|
405
|
+
this.schedulePersistListViewState();
|
|
406
|
+
void this.load();
|
|
234
407
|
}
|
|
235
408
|
setSort(field) {
|
|
236
409
|
this.sortField = field;
|
|
410
|
+
this.schedulePersistListViewState();
|
|
237
411
|
void this.load();
|
|
238
412
|
}
|
|
239
413
|
toggleSortDirection() {
|
|
240
414
|
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
415
|
+
this.schedulePersistListViewState();
|
|
241
416
|
void this.load();
|
|
242
417
|
}
|
|
243
418
|
// ---- things done to a workflow -------------------------------------------------------------------------------
|
|
@@ -269,8 +444,10 @@ export class WorkflowListState {
|
|
|
269
444
|
this.setBusy(workflowId, false);
|
|
270
445
|
}
|
|
271
446
|
}
|
|
272
|
-
/**
|
|
447
|
+
/** The last refusal to make a workflow (shown on the list when "New workflow" fails). */
|
|
273
448
|
createFailure = $state.raw(null);
|
|
449
|
+
/** While a blank workflow is being made from the list (double-clicks are ignored). */
|
|
450
|
+
isCreatingNew = $state(false);
|
|
274
451
|
async create(input) {
|
|
275
452
|
this.createFailure = null;
|
|
276
453
|
try {
|
|
@@ -279,6 +456,10 @@ export class WorkflowListState {
|
|
|
279
456
|
compositionId: input.composition?.id ?? null,
|
|
280
457
|
timezone: detectBrowserTimeZone()
|
|
281
458
|
});
|
|
459
|
+
this.newWorkflowDialogOpen = false;
|
|
460
|
+
this.newWorkflowDialogName = '';
|
|
461
|
+
this.chosenPresetKey = null;
|
|
462
|
+
this.dialogJournal?.clear(this.workspaceId);
|
|
282
463
|
return created;
|
|
283
464
|
}
|
|
284
465
|
catch (error) {
|
|
@@ -290,7 +471,34 @@ export class WorkflowListState {
|
|
|
290
471
|
}
|
|
291
472
|
}
|
|
292
473
|
/**
|
|
293
|
-
*
|
|
474
|
+
* Makes a blank workflow named {@link BLANK_WORKFLOW_NAME} and returns it. Refusals are in {@link createFailure}; while the
|
|
475
|
+
* request runs {@link isCreatingNew} is true.
|
|
476
|
+
*/
|
|
477
|
+
async createBlank() {
|
|
478
|
+
if (this.isCreatingNew)
|
|
479
|
+
return undefined;
|
|
480
|
+
this.isCreatingNew = true;
|
|
481
|
+
try {
|
|
482
|
+
return await this.create({ name: BLANK_WORKFLOW_NAME, composition: null });
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
this.isCreatingNew = false;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
/** Makes a blank workflow and opens it (`onOpen` is called only after a workflow was made). */
|
|
489
|
+
async createBlankAndOpen(onOpen) {
|
|
490
|
+
await createBlankWorkflowAndOpen({
|
|
491
|
+
isCreating: () => this.isCreatingNew,
|
|
492
|
+
setCreating: (busy) => {
|
|
493
|
+
this.isCreatingNew = busy;
|
|
494
|
+
},
|
|
495
|
+
create: (input) => this.create(input),
|
|
496
|
+
open: onOpen,
|
|
497
|
+
existingNames: this.items.map((item) => item.name)
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Reads the presets a partner or admin flow can start from. A preset is a convenience: when they
|
|
294
502
|
* cannot be read the dialog says so and the blank start keeps working, so this is logged, and never reported to the page as
|
|
295
503
|
* a failure of the screen.
|
|
296
504
|
*/
|
|
@@ -306,6 +514,7 @@ export class WorkflowListState {
|
|
|
306
514
|
return;
|
|
307
515
|
this.presets = presets;
|
|
308
516
|
this.presetsState = 'ready';
|
|
517
|
+
this.reconcileDialogPresetWithPresets();
|
|
309
518
|
}
|
|
310
519
|
catch (error) {
|
|
311
520
|
if (isCancelled(error) || this.disposed)
|
|
@@ -328,7 +537,12 @@ export class WorkflowListState {
|
|
|
328
537
|
: makeIdempotencyKey();
|
|
329
538
|
this.unresolvedStart = null;
|
|
330
539
|
try {
|
|
331
|
-
|
|
540
|
+
const created = await this.api.startFromPreset({ key: input.key, name }, { idempotencyKey });
|
|
541
|
+
this.newWorkflowDialogOpen = false;
|
|
542
|
+
this.newWorkflowDialogName = '';
|
|
543
|
+
this.chosenPresetKey = null;
|
|
544
|
+
this.dialogJournal?.clear(this.workspaceId);
|
|
545
|
+
return created;
|
|
332
546
|
}
|
|
333
547
|
catch (error) {
|
|
334
548
|
if (isCancelled(error))
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { WorkflowPreset, WorkflowPresetWidget } from '../api/types.js';
|
|
2
2
|
/**
|
|
3
|
-
* What
|
|
3
|
+
* What a preset start decides, kept in one place so partner and admin flows can read and test it on its
|
|
4
4
|
* own: which preset is chosen, which pictures its card draws, and whether the person can go on.
|
|
5
5
|
*/
|
|
6
6
|
/** How many pictures a card of a preset draws; the widgets after them are counted ("+2"). */
|
|
7
7
|
export declare const PRESET_PICTURES_SHOWN = 3;
|
|
8
8
|
/**
|
|
9
9
|
* The preset the person chose, from the ones on offer now. `null` is a blank start: nothing was chosen, or the preset that was
|
|
10
|
-
* chosen is not on offer any more (the list was read again and it is gone)
|
|
10
|
+
* chosen is not on offer any more (the list was read again and it is gone).
|
|
11
11
|
*/
|
|
12
12
|
export declare function chosenPresetOf(presets: readonly WorkflowPreset[], chosenKey: string | null): WorkflowPreset | null;
|
|
13
13
|
/** The pictures a card draws (the first widgets, in the order the preset shows them) and how many widgets did not fit. */
|
|
@@ -16,8 +16,8 @@ export declare function picturesOf(preset: Pick<WorkflowPreset, 'widgets'>, show
|
|
|
16
16
|
hiddenCount: number;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Whether
|
|
20
|
-
*
|
|
19
|
+
* Whether a preset start can go on now. A blank start needs the name; a preset names itself after its title when the name is
|
|
20
|
+
* left empty.
|
|
21
21
|
*/
|
|
22
22
|
export declare function canStartNow(input: {
|
|
23
23
|
preset: WorkflowPreset | null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What
|
|
2
|
+
* What a preset start decides, kept in one place so partner and admin flows can read and test it on its
|
|
3
3
|
* own: which preset is chosen, which pictures its card draws, and whether the person can go on.
|
|
4
4
|
*/
|
|
5
5
|
/** How many pictures a card of a preset draws; the widgets after them are counted ("+2"). */
|
|
6
6
|
export const PRESET_PICTURES_SHOWN = 3;
|
|
7
7
|
/**
|
|
8
8
|
* The preset the person chose, from the ones on offer now. `null` is a blank start: nothing was chosen, or the preset that was
|
|
9
|
-
* chosen is not on offer any more (the list was read again and it is gone)
|
|
9
|
+
* chosen is not on offer any more (the list was read again and it is gone).
|
|
10
10
|
*/
|
|
11
11
|
export function chosenPresetOf(presets, chosenKey) {
|
|
12
12
|
if (chosenKey === null)
|
|
@@ -22,8 +22,8 @@ export function picturesOf(preset, shown = PRESET_PICTURES_SHOWN) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Whether
|
|
26
|
-
*
|
|
25
|
+
* Whether a preset start can go on now. A blank start needs the name; a preset names itself after its title when the name is
|
|
26
|
+
* left empty.
|
|
27
27
|
*/
|
|
28
28
|
export function canStartNow(input) {
|
|
29
29
|
if (input.isBusy)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Bands thinner than this do not show an on-band count · percent label. */
|
|
2
|
+
export declare const MIN_BAND_LABEL_THICKNESS = 14;
|
|
3
|
+
/**
|
|
4
|
+
* The share of visitors who started, as a whole-number percent for the on-band label. A band that is positive but rounds to
|
|
5
|
+
* nothing reads `<1%` (worked out from the number, since the zero of each language is written in its own way).
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatBandLabelPercent(value: number, visitorsStarted: number, locale: string): string;
|
|
8
|
+
/** The middle of the last stretch of a band curve (the S-curve into the target column). */
|
|
9
|
+
export declare function bandLabelCenterOfLastStretch(stations: ReadonlyArray<{
|
|
10
|
+
xIn: number;
|
|
11
|
+
xOut: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}>): {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
} | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Bands thinner than this do not show an on-band count · percent label. */
|
|
2
|
+
export const MIN_BAND_LABEL_THICKNESS = 14;
|
|
3
|
+
/**
|
|
4
|
+
* A fraction as a whole-number percent, written the way the person's language writes it. A language tag the platform does not
|
|
5
|
+
* know is not worth a broken chart: the percent is then written in the plain way.
|
|
6
|
+
*/
|
|
7
|
+
function formatWholePercent(fraction, locale) {
|
|
8
|
+
try {
|
|
9
|
+
return new Intl.NumberFormat(locale, { style: 'percent', maximumFractionDigits: 0 }).format(fraction);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return `${Math.round(fraction * 100)}%`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The share of visitors who started, as a whole-number percent for the on-band label. A band that is positive but rounds to
|
|
17
|
+
* nothing reads `<1%` (worked out from the number, since the zero of each language is written in its own way).
|
|
18
|
+
*/
|
|
19
|
+
export function formatBandLabelPercent(value, visitorsStarted, locale) {
|
|
20
|
+
if (!(visitorsStarted > 0) || !(value > 0))
|
|
21
|
+
return formatWholePercent(0, locale);
|
|
22
|
+
const share = value / visitorsStarted;
|
|
23
|
+
if (Math.round(share * 100) === 0)
|
|
24
|
+
return `<${formatWholePercent(0.01, locale)}`;
|
|
25
|
+
return formatWholePercent(share, locale);
|
|
26
|
+
}
|
|
27
|
+
/** The middle of the last stretch of a band curve (the S-curve into the target column). */
|
|
28
|
+
export function bandLabelCenterOfLastStretch(stations) {
|
|
29
|
+
if (stations.length < 2)
|
|
30
|
+
return null;
|
|
31
|
+
const from = stations[stations.length - 2];
|
|
32
|
+
const to = stations[stations.length - 1];
|
|
33
|
+
return { x: (from.xOut + to.xIn) / 2, y: (from.y + to.y) / 2 };
|
|
34
|
+
}
|
|
@@ -30,9 +30,12 @@ export declare const RUNS_FLOW_METRICS: {
|
|
|
30
30
|
readonly stepGap: 20;
|
|
31
31
|
/** The space between a lane and what is above it (a lane has no label to make room for). */
|
|
32
32
|
readonly laneGap: 8;
|
|
33
|
-
/**
|
|
34
|
-
readonly nameLineHeight:
|
|
35
|
-
|
|
33
|
+
/** Caption line for a composition's name above or beside a bar. */
|
|
34
|
+
readonly nameLineHeight: 16;
|
|
35
|
+
/** Bold line for the visitor count on the chart. */
|
|
36
|
+
readonly countLineHeight: 20;
|
|
37
|
+
/** Space between a bar and on-chart stayed/failed words to its right. */
|
|
38
|
+
readonly barSideLabelGap: 6;
|
|
36
39
|
/** The space between the label and its bar. */
|
|
37
40
|
readonly labelMargin: 6;
|
|
38
41
|
/** A bar and a band are never thinner than this (a few visitors among thousands stay visible). */
|
|
@@ -55,17 +58,23 @@ export declare const RUNS_FLOW_METRICS: {
|
|
|
55
58
|
/** The space kept between a label and the next column's bars. */
|
|
56
59
|
readonly labelGutter: 16;
|
|
57
60
|
};
|
|
61
|
+
/** Where the on-chart label of a bar sits (numbers only on the chart; details stay in tooltips and the screen-reader list). */
|
|
62
|
+
export type StepChartLabelPlacement = 'entryCount' | 'above' | 'beside';
|
|
58
63
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
64
|
+
* Picks the placement from the column: entry count only, name+count above, or name+count beside the last column. The one bar
|
|
65
|
+
* a visitor starts in has no name on the chart (the workflow's name is in the header), also when nothing follows it, so that
|
|
66
|
+
* is looked at before the last column.
|
|
62
67
|
*/
|
|
63
|
-
export declare function
|
|
68
|
+
export declare function chartLabelPlacement(columnNumber: number, columnCount: number, barsInColumn: number): StepChartLabelPlacement;
|
|
69
|
+
/** How many lines of on-chart label sit above the bar (0 when the label is beside it). */
|
|
70
|
+
export declare function countLabelLines(placement: StepChartLabelPlacement): number;
|
|
64
71
|
/** A bar, with the place of its label. */
|
|
65
72
|
export interface PlacedStep extends RunsFlowStep {
|
|
66
|
-
/** The left edge of the bar
|
|
73
|
+
/** The left edge of the bar. */
|
|
67
74
|
x: number;
|
|
68
|
-
|
|
75
|
+
labelPlacement: StepChartLabelPlacement;
|
|
76
|
+
/** The top-left of the on-chart label (above or beside the bar). */
|
|
77
|
+
labelX: number;
|
|
69
78
|
labelY: number;
|
|
70
79
|
barY: number;
|
|
71
80
|
barHeight: number;
|
|
@@ -90,6 +99,12 @@ export interface PlacedLink extends RunsFlowLink {
|
|
|
90
99
|
thickness: number;
|
|
91
100
|
/** The columns the band skips, left to right, and where it runs through each one. Empty for a band to the next column. */
|
|
92
101
|
lanes: PlacedLane[];
|
|
102
|
+
/** The centre of the on-band count · percent label, when the band is thick enough. */
|
|
103
|
+
labelCenter: {
|
|
104
|
+
x: number;
|
|
105
|
+
y: number;
|
|
106
|
+
} | null;
|
|
107
|
+
showBandLabel: boolean;
|
|
93
108
|
}
|
|
94
109
|
export interface PlacedRunsFlow {
|
|
95
110
|
width: number;
|