@shipfox/client-workflows 12.0.1 → 13.0.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/.storybook/preview.tsx +3 -3
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +65 -0
- package/dist/components/job-graph/job-duration-format.d.ts +2 -2
- package/dist/components/job-graph/job-duration-format.d.ts.map +1 -1
- package/dist/components/job-graph/job-duration-format.js +4 -2
- package/dist/components/job-graph/job-duration-format.js.map +1 -1
- package/dist/components/job-graph/job-node.d.ts +1 -1
- package/dist/components/job-graph/job-node.d.ts.map +1 -1
- package/dist/components/job-graph/job-node.js +5 -4
- package/dist/components/job-graph/job-node.js.map +1 -1
- package/dist/components/step-list/step-list.d.ts +2 -2
- package/dist/components/step-list/step-list.d.ts.map +1 -1
- package/dist/components/step-list/step-list.js.map +1 -1
- package/dist/components/workflow-run-list/job-status-strip.d.ts +21 -0
- package/dist/components/workflow-run-list/job-status-strip.d.ts.map +1 -0
- package/dist/components/workflow-run-list/job-status-strip.js +185 -0
- package/dist/components/workflow-run-list/job-status-strip.js.map +1 -0
- package/dist/components/workflow-run-list/run-display.d.ts +27 -3
- package/dist/components/workflow-run-list/run-display.d.ts.map +1 -1
- package/dist/components/workflow-run-list/run-display.js +78 -7
- package/dist/components/workflow-run-list/run-display.js.map +1 -1
- package/dist/components/workflow-run-list/types.d.ts +23 -24
- package/dist/components/workflow-run-list/types.d.ts.map +1 -1
- package/dist/components/workflow-run-list/types.js.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-filter-menu.d.ts +22 -0
- package/dist/components/workflow-run-list/workflow-run-filter-menu.d.ts.map +1 -0
- package/dist/components/workflow-run-list/workflow-run-filter-menu.js +68 -0
- package/dist/components/workflow-run-list/workflow-run-filter-menu.js.map +1 -0
- package/dist/components/workflow-run-list/workflow-run-filters.d.ts +18 -0
- package/dist/components/workflow-run-list/workflow-run-filters.d.ts.map +1 -0
- package/dist/components/workflow-run-list/workflow-run-filters.js +236 -0
- package/dist/components/workflow-run-list/workflow-run-filters.js.map +1 -0
- package/dist/components/workflow-run-list/workflow-run-list-content.d.ts +8 -4
- package/dist/components/workflow-run-list/workflow-run-list-content.d.ts.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-content.js +40 -12
- package/dist/components/workflow-run-list/workflow-run-list-content.js.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-states.d.ts +29 -2
- package/dist/components/workflow-run-list/workflow-run-list-states.d.ts.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-states.js +103 -44
- package/dist/components/workflow-run-list/workflow-run-list-states.js.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-view.d.ts +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-view.d.ts.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-view.js +60 -43
- package/dist/components/workflow-run-list/workflow-run-list-view.js.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list.d.ts +1 -1
- package/dist/components/workflow-run-list/workflow-run-list.d.ts.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-list.js +20 -8
- package/dist/components/workflow-run-list/workflow-run-list.js.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-row.d.ts +19 -9
- package/dist/components/workflow-run-list/workflow-run-row.d.ts.map +1 -1
- package/dist/components/workflow-run-list/workflow-run-row.js +179 -112
- package/dist/components/workflow-run-list/workflow-run-row.js.map +1 -1
- package/dist/components/workflow-run-number-label.d.ts +15 -0
- package/dist/components/workflow-run-number-label.d.ts.map +1 -0
- package/dist/components/workflow-run-number-label.js +41 -0
- package/dist/components/workflow-run-number-label.js.map +1 -0
- package/dist/components/workflow-run-summary/workflow-run-attempt-switcher.d.ts +3 -3
- package/dist/components/workflow-run-summary/workflow-run-attempt-switcher.d.ts.map +1 -1
- package/dist/components/workflow-run-summary/workflow-run-attempt-switcher.js +8 -7
- package/dist/components/workflow-run-summary/workflow-run-attempt-switcher.js.map +1 -1
- package/dist/components/workflow-run-summary/workflow-run-summary.d.ts +3 -3
- package/dist/components/workflow-run-summary/workflow-run-summary.d.ts.map +1 -1
- package/dist/components/workflow-run-summary/workflow-run-summary.js +16 -7
- package/dist/components/workflow-run-summary/workflow-run-summary.js.map +1 -1
- package/dist/components/workflow-run-view/agent-config-failure-callout.d.ts +2 -2
- package/dist/components/workflow-run-view/agent-config-failure-callout.d.ts.map +1 -1
- package/dist/components/workflow-run-view/agent-config-failure-callout.js +4 -4
- package/dist/components/workflow-run-view/agent-config-failure-callout.js.map +1 -1
- package/dist/components/workflow-run-view/job-card.d.ts +2 -2
- package/dist/components/workflow-run-view/job-card.d.ts.map +1 -1
- package/dist/components/workflow-run-view/job-card.js +51 -32
- package/dist/components/workflow-run-view/job-card.js.map +1 -1
- package/dist/components/workflow-run-view/job-execution-switcher.d.ts +1 -1
- package/dist/components/workflow-run-view/job-execution-switcher.d.ts.map +1 -1
- package/dist/components/workflow-run-view/job-execution-switcher.js +20 -8
- package/dist/components/workflow-run-view/job-execution-switcher.js.map +1 -1
- package/dist/components/workflow-run-view/workflow-run-view.d.ts +3 -2
- package/dist/components/workflow-run-view/workflow-run-view.d.ts.map +1 -1
- package/dist/components/workflow-run-view/workflow-run-view.js +15 -11
- package/dist/components/workflow-run-view/workflow-run-view.js.map +1 -1
- package/dist/components/workflow-status/status-visuals.d.ts +4 -4
- package/dist/components/workflow-status/status-visuals.d.ts.map +1 -1
- package/dist/components/workflow-status/status-visuals.js +7 -0
- package/dist/components/workflow-status/status-visuals.js.map +1 -1
- package/dist/components/workflow-status/workflow-status-icon.d.ts +3 -4
- package/dist/components/workflow-status/workflow-status-icon.d.ts.map +1 -1
- package/dist/components/workflow-status/workflow-status-icon.js +6 -4
- package/dist/components/workflow-status/workflow-status-icon.js.map +1 -1
- package/dist/core/entities/job-execution.d.ts +10 -0
- package/dist/core/entities/job-execution.d.ts.map +1 -1
- package/dist/core/entities/job-execution.js +11 -0
- package/dist/core/entities/job-execution.js.map +1 -1
- package/dist/core/entities/job.d.ts +4 -2
- package/dist/core/entities/job.d.ts.map +1 -1
- package/dist/core/entities/job.js +8 -1
- package/dist/core/entities/job.js.map +1 -1
- package/dist/core/entities/workflow-run.d.ts +52 -4
- package/dist/core/entities/workflow-run.d.ts.map +1 -1
- package/dist/core/entities/workflow-run.js +22 -3
- package/dist/core/entities/workflow-run.js.map +1 -1
- package/dist/core/workflow-run.d.ts +6 -6
- package/dist/core/workflow-run.d.ts.map +1 -1
- package/dist/core/workflow-run.js +3 -3
- package/dist/core/workflow-run.js.map +1 -1
- package/dist/feature.d.ts +7 -7
- package/dist/feature.js +5 -5
- package/dist/feature.js.map +1 -1
- package/dist/hooks/api/workflow-run-mapper.d.ts +4 -3
- package/dist/hooks/api/workflow-run-mapper.d.ts.map +1 -1
- package/dist/hooks/api/workflow-run-mapper.js +31 -3
- package/dist/hooks/api/workflow-run-mapper.js.map +1 -1
- package/dist/hooks/api/workflow-runs.d.ts +4 -4
- package/dist/hooks/api/workflow-runs.d.ts.map +1 -1
- package/dist/hooks/api/workflow-runs.js +12 -4
- package/dist/hooks/api/workflow-runs.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/pages/project-workflows-page.js +46 -1
- package/dist/pages/project-workflows-page.js.map +1 -1
- package/dist/pages/workflow-run-detail-page.d.ts +11 -0
- package/dist/pages/workflow-run-detail-page.d.ts.map +1 -0
- package/dist/pages/workflow-run-detail-page.js +30 -0
- package/dist/pages/workflow-run-detail-page.js.map +1 -0
- package/dist/pages/workflow-run-list-page.d.ts +10 -0
- package/dist/pages/workflow-run-list-page.d.ts.map +1 -0
- package/dist/pages/workflow-run-list-page.js +43 -0
- package/dist/pages/workflow-run-list-page.js.map +1 -0
- package/dist/routes/inputs.d.ts +61 -5
- package/dist/routes/inputs.d.ts.map +1 -1
- package/dist/routes/inputs.js +150 -13
- package/dist/routes/inputs.js.map +1 -1
- package/dist/routes/project-route.d.ts +6 -0
- package/dist/routes/project-route.d.ts.map +1 -0
- package/dist/routes/project-route.js +25 -0
- package/dist/routes/project-route.js.map +1 -0
- package/dist/routes/run-detail.d.ts.map +1 -1
- package/dist/routes/run-detail.js +12 -7
- package/dist/routes/run-detail.js.map +1 -1
- package/dist/routes/runs.d.ts.map +1 -1
- package/dist/routes/runs.js +11 -6
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/workflows.js +6 -5
- package/dist/routes/workflows.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/components/job-graph/job-duration-format.ts +11 -2
- package/src/components/job-graph/job-graph-view.test.tsx +19 -8
- package/src/components/job-graph/job-graph.stories.tsx +23 -19
- package/src/components/job-graph/job-node.stories.tsx +10 -5
- package/src/components/job-graph/job-node.test.tsx +55 -10
- package/src/components/job-graph/job-node.tsx +16 -9
- package/src/components/step-list/step-list.stories.tsx +2 -3
- package/src/components/step-list/step-list.tsx +3 -2
- package/src/components/workflow-run-list/job-status-strip.tsx +189 -0
- package/src/components/workflow-run-list/run-display.test.ts +169 -30
- package/src/components/workflow-run-list/run-display.ts +116 -9
- package/src/components/workflow-run-list/types.ts +21 -17
- package/src/components/workflow-run-list/workflow-run-filter-menu.tsx +100 -0
- package/src/components/workflow-run-list/workflow-run-filters.tsx +243 -0
- package/src/components/workflow-run-list/workflow-run-list-content.tsx +44 -16
- package/src/components/workflow-run-list/workflow-run-list-states.tsx +128 -27
- package/src/components/workflow-run-list/workflow-run-list-view.test.tsx +441 -104
- package/src/components/workflow-run-list/workflow-run-list-view.tsx +73 -43
- package/src/components/workflow-run-list/workflow-run-list.stories.tsx +140 -20
- package/src/components/workflow-run-list/workflow-run-list.tsx +20 -10
- package/src/components/workflow-run-list/workflow-run-row.tsx +173 -106
- package/src/components/workflow-run-number-label.test.tsx +45 -0
- package/src/components/workflow-run-number-label.tsx +47 -0
- package/src/components/workflow-run-summary/workflow-run-attempt-switcher.test.tsx +7 -8
- package/src/components/workflow-run-summary/workflow-run-attempt-switcher.tsx +13 -12
- package/src/components/workflow-run-summary/workflow-run-summary.stories.tsx +6 -8
- package/src/components/workflow-run-summary/workflow-run-summary.test.tsx +27 -2
- package/src/components/workflow-run-summary/workflow-run-summary.tsx +19 -9
- package/src/components/workflow-run-view/agent-config-failure-callout.stories.tsx +2 -3
- package/src/components/workflow-run-view/agent-config-failure-callout.tsx +4 -4
- package/src/components/workflow-run-view/job-card.stories.tsx +11 -10
- package/src/components/workflow-run-view/job-card.test.tsx +115 -0
- package/src/components/workflow-run-view/job-card.tsx +74 -35
- package/src/components/workflow-run-view/job-execution-switcher.tsx +31 -9
- package/src/components/workflow-run-view/workflow-run-view.test.tsx +88 -30
- package/src/components/workflow-run-view/workflow-run-view.tsx +24 -14
- package/src/components/workflow-status/status-visuals.test.ts +9 -0
- package/src/components/workflow-status/status-visuals.ts +6 -4
- package/src/components/workflow-status/workflow-status-icon.stories.tsx +10 -2
- package/src/components/workflow-status/workflow-status-icon.test.tsx +18 -0
- package/src/components/workflow-status/workflow-status-icon.tsx +17 -24
- package/src/core/entities/job-execution.ts +22 -0
- package/src/core/entities/job-status.test.ts +104 -0
- package/src/core/entities/job.ts +18 -3
- package/src/core/entities/workflow-run.ts +76 -7
- package/src/core/workflow-run.test.ts +24 -9
- package/src/core/workflow-run.ts +17 -2
- package/src/feature.ts +5 -5
- package/src/hooks/api/workflow-run-mapper.ts +30 -3
- package/src/hooks/api/workflow-runs.test.tsx +2 -0
- package/src/hooks/api/workflow-runs.ts +12 -7
- package/src/index.ts +7 -2
- package/src/page-harness-budget.test.ts +1 -1
- package/src/pages/project-workflows-page.test.tsx +59 -5
- package/src/pages/project-workflows-page.tsx +34 -1
- package/src/pages/workflow-run-detail-page.tsx +45 -0
- package/src/pages/workflow-run-list-page.tsx +65 -0
- package/src/pages/{workflow-run-page.test.tsx → workflow-run-pages.test.tsx} +211 -47
- package/src/routes/inputs.test.ts +193 -12
- package/src/routes/inputs.ts +170 -11
- package/src/routes/project-route.tsx +25 -0
- package/src/routes/run-detail.tsx +15 -8
- package/src/routes/runs.tsx +14 -7
- package/src/routes/workflows.tsx +5 -4
- package/test/fixtures/workflow-run.ts +76 -7
- package/test/pages.tsx +18 -8
- package/test/render.tsx +8 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/components/workflow-run-list/workflow-run-list-header.d.ts +0 -10
- package/dist/components/workflow-run-list/workflow-run-list-header.d.ts.map +0 -1
- package/dist/components/workflow-run-list/workflow-run-list-header.js +0 -55
- package/dist/components/workflow-run-list/workflow-run-list-header.js.map +0 -1
- package/dist/pages/workflow-run-first-time-use.d.ts +0 -6
- package/dist/pages/workflow-run-first-time-use.d.ts.map +0 -1
- package/dist/pages/workflow-run-first-time-use.js +0 -17
- package/dist/pages/workflow-run-first-time-use.js.map +0 -1
- package/dist/pages/workflow-run-page.d.ts +0 -10
- package/dist/pages/workflow-run-page.d.ts.map +0 -1
- package/dist/pages/workflow-run-page.js +0 -90
- package/dist/pages/workflow-run-page.js.map +0 -1
- package/src/components/workflow-run-list/workflow-run-list-header.tsx +0 -53
- package/src/pages/workflow-run-first-time-use.tsx +0 -17
- package/src/pages/workflow-run-page.tsx +0 -94
|
@@ -1,22 +1,203 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {parseAppSearch, stringifyAppSearch} from '@shipfox/client-shell/runtime';
|
|
2
|
+
import {
|
|
3
|
+
applyWorkflowRunFilterPatch,
|
|
4
|
+
clearWorkflowRunFilters,
|
|
5
|
+
hasWorkflowRunFilters,
|
|
6
|
+
validateWorkflowRunsSearch,
|
|
7
|
+
type WorkflowRunsSearch,
|
|
8
|
+
workflowRouteParams,
|
|
9
|
+
workflowRunSearchParams,
|
|
10
|
+
} from './inputs.js';
|
|
2
11
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
/** Everything a filter change writes, then reads back, exactly as the router would. */
|
|
13
|
+
function roundTrip(search: WorkflowRunsSearch): WorkflowRunsSearch {
|
|
14
|
+
const query = stringifyAppSearch(workflowRunSearchParams(search, {}));
|
|
15
|
+
return validateWorkflowRunsSearch(parseAppSearch(query));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('validateWorkflowRunsSearch', () => {
|
|
19
|
+
test('drops malformed values instead of rejecting the URL', () => {
|
|
20
|
+
expect(
|
|
21
|
+
validateWorkflowRunsSearch({
|
|
22
|
+
search: ['unexpected'],
|
|
23
|
+
status: 'unknown',
|
|
24
|
+
after: 'yesterday',
|
|
25
|
+
before: '2026-13-01',
|
|
26
|
+
}),
|
|
27
|
+
).toEqual({});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('ignores parameters it does not recognize', () => {
|
|
31
|
+
expect(validateWorkflowRunsSearch({search: 'deploy', page: '3', sort: 'name'})).toEqual({
|
|
32
|
+
search: 'deploy',
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('reads a single repeated key as a one-element list', () => {
|
|
37
|
+
expect(validateWorkflowRunsSearch({status: 'failed'})).toEqual({status: ['failed']});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('keeps only the statuses it knows out of a mixed list', () => {
|
|
41
|
+
expect(validateWorkflowRunsSearch({status: ['failed', 'nonsense', 'running']})).toEqual({
|
|
42
|
+
status: ['failed', 'running'],
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('coerces a numeric-looking branch back to a string', () => {
|
|
47
|
+
expect(validateWorkflowRunsSearch({branch: 2024})).toEqual({branch: ['2024']});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('deduplicates a repeated value', () => {
|
|
51
|
+
expect(validateWorkflowRunsSearch({branch: ['main', 'main', 'next']})).toEqual({
|
|
52
|
+
branch: ['main', 'next'],
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('rejects a well-shaped but impossible date', () => {
|
|
57
|
+
expect(validateWorkflowRunsSearch({after: '2026-02-31'})).toEqual({});
|
|
58
|
+
expect(validateWorkflowRunsSearch({after: '2026-02-28'})).toEqual({after: '2026-02-28'});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('keeps the run selection parameters the detail route owns', () => {
|
|
62
|
+
expect(validateWorkflowRunsSearch({status: 'failed', runAttempt: '2', job: 'job-1'})).toEqual({
|
|
63
|
+
status: ['failed'],
|
|
64
|
+
runAttempt: 2,
|
|
65
|
+
jobId: 'job-1',
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('the run list URL contract', () => {
|
|
71
|
+
test.each([
|
|
72
|
+
['search', {search: 'deploy-web'}],
|
|
73
|
+
['status', {status: ['failed' as const, 'running' as const]}],
|
|
74
|
+
['branch', {branch: ['main', 'release/v2']}],
|
|
75
|
+
['actor', {actor: ['octocat', 'hubot']}],
|
|
76
|
+
['event', {event: ['push', 'pull_request']}],
|
|
77
|
+
['after and before', {after: '2026-05-01', before: '2026-05-31'}],
|
|
78
|
+
])('round-trips %s through the URL', (_param, search) => {
|
|
79
|
+
expect(roundTrip(search)).toEqual(search);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('round-trips every parameter at once', () => {
|
|
83
|
+
const search: WorkflowRunsSearch = {
|
|
84
|
+
search: 'deploy',
|
|
85
|
+
status: ['failed', 'cancelled'],
|
|
86
|
+
branch: ['main'],
|
|
87
|
+
actor: ['octocat'],
|
|
88
|
+
event: ['push'],
|
|
89
|
+
after: '2026-05-01',
|
|
90
|
+
before: '2026-05-31',
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
expect(roundTrip(search)).toEqual(search);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('repeats the key rather than comma-joining a multi-select', () => {
|
|
97
|
+
const query = stringifyAppSearch(workflowRunSearchParams({status: ['failed', 'running']}, {}));
|
|
98
|
+
|
|
99
|
+
expect(query).toBe('?status=failed&status=running');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('survives a branch name containing a comma', () => {
|
|
103
|
+
expect(roundTrip({branch: ['release,v2', 'main']})).toEqual({branch: ['release,v2', 'main']});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// A branch named for a year, a release train called `false`: names that happen to be valid
|
|
107
|
+
// JSON have to come back as themselves, or the filter matches nothing and the shared link
|
|
108
|
+
// is broken for good.
|
|
109
|
+
test.each([
|
|
110
|
+
['a numeric branch beside a plain one', {branch: ['2024', 'main']}],
|
|
111
|
+
['two numeric branches', {branch: ['2024', '2025']}],
|
|
112
|
+
['a boolean-looking branch', {branch: ['false', 'main']}],
|
|
113
|
+
['numeric actors', {actor: ['123', '456']}],
|
|
114
|
+
])('survives %s', (_case, search) => {
|
|
115
|
+
expect(roundTrip(search)).toEqual(search);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('writes nothing for an unfiltered list', () => {
|
|
119
|
+
expect(stringifyAppSearch(workflowRunSearchParams({}, {}))).toBe('');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('has no page or cursor parameter to carry', () => {
|
|
123
|
+
const query = stringifyAppSearch(workflowRunSearchParams({search: 'deploy'}, {}));
|
|
124
|
+
|
|
125
|
+
expect(query).not.toContain('page');
|
|
126
|
+
expect(query).not.toContain('cursor');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
describe('applyWorkflowRunFilterPatch', () => {
|
|
131
|
+
test('replaces only the dimensions the patch names', () => {
|
|
132
|
+
const next = applyWorkflowRunFilterPatch(
|
|
133
|
+
{search: 'deploy', status: ['failed']},
|
|
134
|
+
{
|
|
135
|
+
branch: ['main'],
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
expect(next).toEqual({search: 'deploy', status: ['failed'], branch: ['main']});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('deletes a dimension set to undefined, an empty string, or an empty list', () => {
|
|
143
|
+
const search: WorkflowRunsSearch = {search: 'deploy', status: ['failed'], after: '2026-05-01'};
|
|
144
|
+
|
|
145
|
+
expect(applyWorkflowRunFilterPatch(search, {search: '', status: [], after: undefined})).toEqual(
|
|
146
|
+
{},
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('leaves the run selection parameters alone', () => {
|
|
151
|
+
const next = applyWorkflowRunFilterPatch({runAttempt: 2, jobId: 'job-1'}, {search: 'deploy'});
|
|
152
|
+
|
|
153
|
+
expect(next).toEqual({runAttempt: 2, jobId: 'job-1', search: 'deploy'});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('clearWorkflowRunFilters', () => {
|
|
158
|
+
test('drops every filter and keeps the selection parameters', () => {
|
|
159
|
+
const cleared = clearWorkflowRunFilters({
|
|
160
|
+
search: 'deploy',
|
|
161
|
+
status: ['failed'],
|
|
162
|
+
branch: ['main'],
|
|
163
|
+
actor: ['octocat'],
|
|
164
|
+
event: ['push'],
|
|
165
|
+
after: '2026-05-01',
|
|
166
|
+
before: '2026-05-31',
|
|
8
167
|
runAttempt: 2,
|
|
9
168
|
});
|
|
169
|
+
|
|
170
|
+
expect(cleared).toEqual({runAttempt: 2});
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe('hasWorkflowRunFilters', () => {
|
|
175
|
+
test.each([
|
|
176
|
+
['search', {search: 'deploy'}],
|
|
177
|
+
['status', {status: ['failed' as const]}],
|
|
178
|
+
['branch', {branch: ['main']}],
|
|
179
|
+
['actor', {actor: ['octocat']}],
|
|
180
|
+
['event', {event: ['push']}],
|
|
181
|
+
['after', {after: '2026-05-01'}],
|
|
182
|
+
['before', {before: '2026-05-31'}],
|
|
183
|
+
])('reports %s as an active filter', (_dimension, search) => {
|
|
184
|
+
expect(hasWorkflowRunFilters(search)).toBe(true);
|
|
10
185
|
});
|
|
11
186
|
|
|
12
|
-
|
|
13
|
-
expect(
|
|
14
|
-
|
|
15
|
-
|
|
187
|
+
test('does not count a run selection parameter as a filter', () => {
|
|
188
|
+
expect(hasWorkflowRunFilters({runAttempt: 2, jobId: 'job-1'})).toBe(false);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
describe('workflowRouteParams', () => {
|
|
193
|
+
test('requires workspace and project path parameters', () => {
|
|
194
|
+
expect(workflowRouteParams({workspaceSlug: 'workspace-1', projectSlug: 'project-1'})).toEqual({
|
|
195
|
+
workspaceSlug: 'workspace-1',
|
|
196
|
+
projectSlug: 'project-1',
|
|
16
197
|
});
|
|
17
|
-
expect(() => workflowRouteParams({
|
|
198
|
+
expect(() => workflowRouteParams({workspaceSlug: 'workspace-1'})).toThrow(
|
|
18
199
|
'Workflow route is missing required path parameters.',
|
|
19
200
|
);
|
|
20
|
-
expect(() => workflowRouteParams({
|
|
201
|
+
expect(() => workflowRouteParams({workspaceSlug: 'workspace-1', projectSlug: null})).toThrow();
|
|
21
202
|
});
|
|
22
203
|
});
|
package/src/routes/inputs.ts
CHANGED
|
@@ -1,18 +1,53 @@
|
|
|
1
|
-
import type {WorkflowRunListStatusFilter} from '#components/workflow-run-list/types.js';
|
|
2
1
|
import type {WorkflowRunSelectionInput} from '#core/workflow-run-url-state.js';
|
|
3
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Statuses the run list can filter by. Absent means all; there is deliberately no `all`
|
|
5
|
+
* value, so "no filter" and "every filter" are the same URL rather than two.
|
|
6
|
+
*/
|
|
7
|
+
export const WORKFLOW_RUN_LIST_STATUSES = ['succeeded', 'failed', 'running', 'cancelled'] as const;
|
|
8
|
+
|
|
9
|
+
export type WorkflowRunListStatus = (typeof WORKFLOW_RUN_LIST_STATUSES)[number];
|
|
10
|
+
|
|
4
11
|
export interface WorkflowRunsSearch extends WorkflowRunSelectionInput {
|
|
5
12
|
search?: string;
|
|
6
|
-
status?:
|
|
13
|
+
status?: WorkflowRunListStatus[];
|
|
14
|
+
branch?: string[];
|
|
15
|
+
actor?: string[];
|
|
16
|
+
event?: string[];
|
|
17
|
+
/** Inclusive lower bound on the run's local calendar date, `YYYY-MM-DD`. */
|
|
18
|
+
after?: string;
|
|
19
|
+
/** Inclusive upper bound on the run's local calendar date, `YYYY-MM-DD`. */
|
|
20
|
+
before?: string;
|
|
7
21
|
}
|
|
8
22
|
|
|
23
|
+
const STATUS_VALUES = new Set<string>(WORKFLOW_RUN_LIST_STATUSES);
|
|
24
|
+
const CALENDAR_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/u;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Reads the run list and run detail query string.
|
|
28
|
+
*
|
|
29
|
+
* Every value is dropped rather than rejected when it does not fit: a truncated or
|
|
30
|
+
* hand-edited URL should degrade to a sensible page, never to an error screen. Unknown
|
|
31
|
+
* parameters are ignored for the same reason.
|
|
32
|
+
*/
|
|
9
33
|
export function validateWorkflowRunsSearch(input: Record<string, unknown>): WorkflowRunsSearch {
|
|
10
34
|
const search = string(input.search);
|
|
11
|
-
const status = input.status
|
|
35
|
+
const status = repeatable(input.status).filter(isWorkflowRunListStatus);
|
|
36
|
+
const branch = repeatable(input.branch);
|
|
37
|
+
const actor = repeatable(input.actor);
|
|
38
|
+
const event = repeatable(input.event);
|
|
39
|
+
const after = calendarDate(input.after);
|
|
40
|
+
const before = calendarDate(input.before);
|
|
12
41
|
const runAttempt = positiveInteger(input.runAttempt);
|
|
42
|
+
|
|
13
43
|
return {
|
|
14
44
|
...(search ? {search} : {}),
|
|
15
|
-
...(status
|
|
45
|
+
...(status.length > 0 ? {status} : {}),
|
|
46
|
+
...(branch.length > 0 ? {branch} : {}),
|
|
47
|
+
...(actor.length > 0 ? {actor} : {}),
|
|
48
|
+
...(event.length > 0 ? {event} : {}),
|
|
49
|
+
...(after ? {after} : {}),
|
|
50
|
+
...(before ? {before} : {}),
|
|
16
51
|
...(string(input.job) ? {jobId: string(input.job)} : {}),
|
|
17
52
|
...(string(input.jobExecution) ? {jobExecutionId: string(input.jobExecution)} : {}),
|
|
18
53
|
...(string(input.step) ? {stepId: string(input.step)} : {}),
|
|
@@ -21,13 +56,24 @@ export function validateWorkflowRunsSearch(input: Record<string, unknown>): Work
|
|
|
21
56
|
};
|
|
22
57
|
}
|
|
23
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Writes the query string back.
|
|
61
|
+
*
|
|
62
|
+
* Array values reach the router as arrays and the app's `stringifySearch` expands each into
|
|
63
|
+
* repeated keys; joining them here would defeat that and break on branch names with commas.
|
|
64
|
+
*/
|
|
24
65
|
export function workflowRunSearchParams(
|
|
25
66
|
search: WorkflowRunsSearch,
|
|
26
67
|
selection: WorkflowRunSelectionInput = search,
|
|
27
68
|
) {
|
|
28
69
|
return {
|
|
29
70
|
...(search.search ? {search: search.search} : {}),
|
|
30
|
-
...(search.status
|
|
71
|
+
...(search.status?.length ? {status: search.status} : {}),
|
|
72
|
+
...(search.branch?.length ? {branch: search.branch} : {}),
|
|
73
|
+
...(search.actor?.length ? {actor: search.actor} : {}),
|
|
74
|
+
...(search.event?.length ? {event: search.event} : {}),
|
|
75
|
+
...(search.after ? {after: search.after} : {}),
|
|
76
|
+
...(search.before ? {before: search.before} : {}),
|
|
31
77
|
...(selection.jobId ? {job: selection.jobId} : {}),
|
|
32
78
|
...(selection.jobExecutionId ? {jobExecution: selection.jobExecutionId} : {}),
|
|
33
79
|
...(selection.stepId ? {step: selection.stepId} : {}),
|
|
@@ -36,16 +82,129 @@ export function workflowRunSearchParams(
|
|
|
36
82
|
};
|
|
37
83
|
}
|
|
38
84
|
|
|
85
|
+
/**
|
|
86
|
+
* A filter change. Each member is explicitly optional-or-undefined so that "present and
|
|
87
|
+
* undefined" (clear this filter) stays distinguishable from "absent" (leave it alone) under
|
|
88
|
+
* `exactOptionalPropertyTypes`.
|
|
89
|
+
*/
|
|
90
|
+
export interface WorkflowRunFilterPatch {
|
|
91
|
+
search?: string | undefined;
|
|
92
|
+
status?: WorkflowRunListStatus[] | undefined;
|
|
93
|
+
branch?: string[] | undefined;
|
|
94
|
+
actor?: string[] | undefined;
|
|
95
|
+
event?: string[] | undefined;
|
|
96
|
+
after?: string | undefined;
|
|
97
|
+
before?: string | undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Applies a filter change.
|
|
102
|
+
*
|
|
103
|
+
* A key present with `undefined`, an empty string, or an empty array clears that filter; a
|
|
104
|
+
* key left out is untouched. Cleared filters are deleted rather than stored empty, so "no
|
|
105
|
+
* filter" is one URL instead of several that render the same list.
|
|
106
|
+
*/
|
|
107
|
+
export function applyWorkflowRunFilterPatch(
|
|
108
|
+
search: WorkflowRunsSearch,
|
|
109
|
+
patch: WorkflowRunFilterPatch,
|
|
110
|
+
): WorkflowRunsSearch {
|
|
111
|
+
const next: WorkflowRunsSearch = {...search};
|
|
112
|
+
if ('search' in patch) setOrDelete(next, 'search', patch.search || undefined);
|
|
113
|
+
if ('status' in patch) setOrDelete(next, 'status', nonEmptyList(patch.status));
|
|
114
|
+
if ('branch' in patch) setOrDelete(next, 'branch', nonEmptyList(patch.branch));
|
|
115
|
+
if ('actor' in patch) setOrDelete(next, 'actor', nonEmptyList(patch.actor));
|
|
116
|
+
if ('event' in patch) setOrDelete(next, 'event', nonEmptyList(patch.event));
|
|
117
|
+
if ('after' in patch) setOrDelete(next, 'after', patch.after || undefined);
|
|
118
|
+
if ('before' in patch) setOrDelete(next, 'before', patch.before || undefined);
|
|
119
|
+
return next;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Drops every filter while keeping the run-selection parameters the detail route owns. */
|
|
123
|
+
export function clearWorkflowRunFilters(search: WorkflowRunsSearch): WorkflowRunsSearch {
|
|
124
|
+
return applyWorkflowRunFilterPatch(search, {
|
|
125
|
+
search: undefined,
|
|
126
|
+
status: undefined,
|
|
127
|
+
branch: undefined,
|
|
128
|
+
actor: undefined,
|
|
129
|
+
event: undefined,
|
|
130
|
+
after: undefined,
|
|
131
|
+
before: undefined,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** True when any list filter is active, which separates "no matches" from "no runs". */
|
|
136
|
+
export function hasWorkflowRunFilters(search: WorkflowRunsSearch): boolean {
|
|
137
|
+
return Boolean(
|
|
138
|
+
search.search ||
|
|
139
|
+
search.status?.length ||
|
|
140
|
+
search.branch?.length ||
|
|
141
|
+
search.actor?.length ||
|
|
142
|
+
search.event?.length ||
|
|
143
|
+
search.after ||
|
|
144
|
+
search.before,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
39
148
|
export function workflowRouteParams(input: Record<string, unknown>): {
|
|
40
|
-
|
|
41
|
-
|
|
149
|
+
workspaceSlug: string;
|
|
150
|
+
projectSlug: string;
|
|
42
151
|
workflowRunId?: string;
|
|
43
152
|
} {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
153
|
+
const workspaceSlug = string(input.workspaceSlug);
|
|
154
|
+
const projectSlug = string(input.projectSlug);
|
|
155
|
+
if (!workspaceSlug || !projectSlug)
|
|
156
|
+
throw new Error('Workflow route is missing required path parameters.');
|
|
47
157
|
const workflowRunId = string(input.workflowRunId);
|
|
48
|
-
return workflowRunId ? {
|
|
158
|
+
return workflowRunId ? {workspaceSlug, projectSlug, workflowRunId} : {workspaceSlug, projectSlug};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function setOrDelete<TKey extends keyof WorkflowRunsSearch>(
|
|
162
|
+
target: WorkflowRunsSearch,
|
|
163
|
+
key: TKey,
|
|
164
|
+
value: WorkflowRunsSearch[TKey] | undefined,
|
|
165
|
+
): void {
|
|
166
|
+
if (value === undefined) delete target[key];
|
|
167
|
+
else target[key] = value;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function nonEmptyList<TValue>(value: readonly TValue[] | undefined): TValue[] | undefined {
|
|
171
|
+
return value && value.length > 0 ? [...value] : undefined;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function isWorkflowRunListStatus(value: string): value is WorkflowRunListStatus {
|
|
175
|
+
return STATUS_VALUES.has(value);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Normalizes a repeatable parameter into a deduplicated list.
|
|
180
|
+
*
|
|
181
|
+
* A single occurrence parses as a scalar rather than a one-element array, and the parser
|
|
182
|
+
* coerces bare digits to numbers, so `?branch=2024` has to survive as the string `"2024"`.
|
|
183
|
+
*/
|
|
184
|
+
function repeatable(value: unknown): string[] {
|
|
185
|
+
const values = Array.isArray(value) ? value : [value];
|
|
186
|
+
const normalized = values.flatMap((entry) => {
|
|
187
|
+
if (typeof entry === 'string') return entry.length > 0 ? [entry] : [];
|
|
188
|
+
if (typeof entry === 'number' && Number.isFinite(entry)) return [String(entry)];
|
|
189
|
+
if (typeof entry === 'boolean') return [String(entry)];
|
|
190
|
+
return [];
|
|
191
|
+
});
|
|
192
|
+
return [...new Set(normalized)];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function calendarDate(value: unknown): string | undefined {
|
|
196
|
+
if (typeof value !== 'string' || !CALENDAR_DATE_PATTERN.test(value)) return undefined;
|
|
197
|
+
// Rejects a well-shaped but impossible date such as 2026-02-31, which Date rolls forward.
|
|
198
|
+
// Parsed as UTC: whether `2026-05-01` is a real date does not depend on the reader's zone,
|
|
199
|
+
// and a local-time parse would reject a day the reader's zone skipped outright.
|
|
200
|
+
const [year, month, day] = value.split('-').map(Number) as [number, number, number];
|
|
201
|
+
const parsed = new Date(`${value}T00:00:00.000Z`);
|
|
202
|
+
const isRealDate =
|
|
203
|
+
!Number.isNaN(parsed.getTime()) &&
|
|
204
|
+
parsed.getUTCFullYear() === year &&
|
|
205
|
+
parsed.getUTCMonth() === month - 1 &&
|
|
206
|
+
parsed.getUTCDate() === day;
|
|
207
|
+
return isRealDate ? value : undefined;
|
|
49
208
|
}
|
|
50
209
|
|
|
51
210
|
function string(value: unknown): string | undefined {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {type Project, useMaybeActiveProjectQuery} from '@shipfox/client-projects';
|
|
2
|
+
import {QueryLoadError} from '@shipfox/client-ui';
|
|
3
|
+
import {EmptyState} from '@shipfox/react-ui/empty-state';
|
|
4
|
+
import {FullPageLoader} from '@shipfox/react-ui/loader';
|
|
5
|
+
import type {ReactNode} from 'react';
|
|
6
|
+
|
|
7
|
+
export function ProjectRoute({children}: {children: (project: Project) => ReactNode}) {
|
|
8
|
+
const projectQuery = useMaybeActiveProjectQuery();
|
|
9
|
+
|
|
10
|
+
if (projectQuery.isPending) return <FullPageLoader />;
|
|
11
|
+
if (projectQuery.isError && projectQuery.data === undefined) {
|
|
12
|
+
return <QueryLoadError query={projectQuery} subject="project" />;
|
|
13
|
+
}
|
|
14
|
+
if (!projectQuery.data) {
|
|
15
|
+
return (
|
|
16
|
+
<EmptyState
|
|
17
|
+
icon="errorWarningLine"
|
|
18
|
+
title="Project not found"
|
|
19
|
+
description="This project doesn't exist, or you don't have access to it."
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return children(projectQuery.data);
|
|
25
|
+
}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import {defineRoute, useRouteParams, useRouteSearch} from '@shipfox/client-shell/runtime';
|
|
2
|
-
import {
|
|
2
|
+
import {WorkflowRunDetailPage} from '#pages/workflow-run-detail-page.js';
|
|
3
3
|
import {validateWorkflowRunsSearch, workflowRouteParams} from './inputs.js';
|
|
4
|
+
import {ProjectRoute} from './project-route.js';
|
|
4
5
|
|
|
5
6
|
export default defineRoute({
|
|
6
7
|
staticData: {layout: 'full-bleed'},
|
|
7
8
|
validateSearch: validateWorkflowRunsSearch,
|
|
8
9
|
component: () => {
|
|
9
|
-
const {
|
|
10
|
+
const {workspaceSlug, projectSlug, workflowRunId} = useRouteParams(workflowRouteParams);
|
|
11
|
+
const search = useRouteSearch(validateWorkflowRunsSearch);
|
|
10
12
|
return (
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
<ProjectRoute>
|
|
14
|
+
{(project) => (
|
|
15
|
+
<WorkflowRunDetailPage
|
|
16
|
+
projectId={project.id}
|
|
17
|
+
workspaceSlug={workspaceSlug}
|
|
18
|
+
projectSlug={projectSlug}
|
|
19
|
+
workflowRunId={workflowRunId}
|
|
20
|
+
search={search}
|
|
21
|
+
/>
|
|
22
|
+
)}
|
|
23
|
+
</ProjectRoute>
|
|
17
24
|
);
|
|
18
25
|
},
|
|
19
26
|
});
|
package/src/routes/runs.tsx
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import {defineRoute, useRouteParams, useRouteSearch} from '@shipfox/client-shell/runtime';
|
|
2
|
-
import {
|
|
2
|
+
import {WorkflowRunsPage} from '#pages/workflow-run-list-page.js';
|
|
3
3
|
import {validateWorkflowRunsSearch, workflowRouteParams} from './inputs.js';
|
|
4
|
+
import {ProjectRoute} from './project-route.js';
|
|
4
5
|
|
|
5
6
|
export default defineRoute({
|
|
6
7
|
staticData: {layout: 'full-bleed'},
|
|
7
8
|
validateSearch: validateWorkflowRunsSearch,
|
|
8
9
|
component: () => {
|
|
9
|
-
const {
|
|
10
|
+
const {workspaceSlug, projectSlug} = useRouteParams(workflowRouteParams);
|
|
11
|
+
const search = useRouteSearch(validateWorkflowRunsSearch);
|
|
10
12
|
return (
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
<ProjectRoute>
|
|
14
|
+
{(project) => (
|
|
15
|
+
<WorkflowRunsPage
|
|
16
|
+
projectId={project.id}
|
|
17
|
+
workspaceSlug={workspaceSlug}
|
|
18
|
+
projectSlug={projectSlug}
|
|
19
|
+
search={search}
|
|
20
|
+
/>
|
|
21
|
+
)}
|
|
22
|
+
</ProjectRoute>
|
|
16
23
|
);
|
|
17
24
|
},
|
|
18
25
|
});
|
package/src/routes/workflows.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {defineRoute
|
|
1
|
+
import {defineRoute} from '@shipfox/client-shell/runtime';
|
|
2
2
|
import {ProjectWorkflowsPage} from '#pages/project-workflows-page.js';
|
|
3
|
-
import {
|
|
3
|
+
import {ProjectRoute} from './project-route.js';
|
|
4
4
|
|
|
5
5
|
export default defineRoute({
|
|
6
6
|
component: () => {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
return (
|
|
8
|
+
<ProjectRoute>{(project) => <ProjectWorkflowsPage projectId={project.id} />}</ProjectRoute>
|
|
9
|
+
);
|
|
9
10
|
},
|
|
10
11
|
});
|