@runwisp/ui 0.14.0 → 0.15.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/package.json +4 -7
- package/src/lib/actions/portal.ts +0 -3
- package/src/lib/components/CronInput.svelte +0 -4
- package/src/lib/components/DataGrid.svelte +1 -3
- package/src/lib/components/Drawer.svelte +0 -3
- package/src/lib/components/Dropdown.svelte +2 -6
- package/src/lib/components/Modal.svelte +0 -3
- package/src/lib/components/Select.svelte +2 -5
- package/src/lib/components/StatusIndicator.svelte +0 -3
- package/src/lib/components/Tabs.svelte +0 -2
- package/src/lib/components/ToastContainer.svelte +0 -5
- package/src/lib/components/Tooltip.svelte +5 -2
- package/src/lib/components/dashboard/RunDetailPanel.svelte +133 -226
- package/src/lib/components/dashboard/RunFilterPopover.svelte +14 -14
- package/src/lib/components/dashboard/RunsList.svelte +29 -29
- package/src/lib/components/dashboard/run-filters.test.ts +31 -33
- package/src/lib/components/dashboard/run-filters.ts +33 -33
- package/src/lib/components/dashboard/run-helpers.test.ts +42 -17
- package/src/lib/components/dashboard/run-helpers.ts +53 -17
- package/src/lib/components/dashboard/status-config.ts +9 -8
- package/src/lib/utils/error.ts +0 -3
- package/src/lib/utils/format.test.ts +2 -6
- package/src/lib/utils/format.ts +28 -3
|
@@ -45,7 +45,7 @@ export const RUN_STATUS_CONFIG: Record<RunStatus, RunStatusConfig> = {
|
|
|
45
45
|
border: "border-success-soft",
|
|
46
46
|
dot: "bg-success-surface",
|
|
47
47
|
badge: "bg-success-soft text-success-soft-text",
|
|
48
|
-
description: "The run finished with exit code 0.",
|
|
48
|
+
description: "The run finished with exit code 0 - everything OK.",
|
|
49
49
|
},
|
|
50
50
|
failed: {
|
|
51
51
|
icon: CircleX,
|
|
@@ -64,7 +64,7 @@ export const RUN_STATUS_CONFIG: Record<RunStatus, RunStatusConfig> = {
|
|
|
64
64
|
dot: "bg-danger-surface",
|
|
65
65
|
badge: "bg-danger-soft text-danger-soft-text",
|
|
66
66
|
description:
|
|
67
|
-
"The process was killed, or the daemon found it still 'running' after a hard crash and marked it crashed
|
|
67
|
+
"The process was killed, or the daemon found it still 'running' after a hard crash and marked it crashed. It was not resumed.",
|
|
68
68
|
},
|
|
69
69
|
stopped: {
|
|
70
70
|
icon: CircleStop,
|
|
@@ -73,7 +73,7 @@ export const RUN_STATUS_CONFIG: Record<RunStatus, RunStatusConfig> = {
|
|
|
73
73
|
border: "border-warning-soft",
|
|
74
74
|
dot: "bg-warning-surface",
|
|
75
75
|
badge: "bg-warning-soft text-warning-soft-text",
|
|
76
|
-
description: "
|
|
76
|
+
description: "A human or an external script manually stopped this run before it finished.",
|
|
77
77
|
},
|
|
78
78
|
timeout: {
|
|
79
79
|
icon: TimerOff,
|
|
@@ -82,7 +82,8 @@ export const RUN_STATUS_CONFIG: Record<RunStatus, RunStatusConfig> = {
|
|
|
82
82
|
border: "border-warning-soft",
|
|
83
83
|
dot: "bg-warning-surface",
|
|
84
84
|
badge: "bg-warning-soft text-warning-soft-text",
|
|
85
|
-
description:
|
|
85
|
+
description:
|
|
86
|
+
"The run exceeded its configured timeout and was terminated. Timeout duration can be changed.",
|
|
86
87
|
},
|
|
87
88
|
skipped: {
|
|
88
89
|
icon: SkipForward,
|
|
@@ -101,7 +102,7 @@ export const RUN_STATUS_CONFIG: Record<RunStatus, RunStatusConfig> = {
|
|
|
101
102
|
border: "border-danger-soft",
|
|
102
103
|
dot: "bg-danger-surface",
|
|
103
104
|
badge: "bg-danger-soft text-danger-soft-text",
|
|
104
|
-
description: "The run hit log_max_size and was handled
|
|
105
|
+
description: "The run hit log_max_size and was handled because of log_on_full.",
|
|
105
106
|
},
|
|
106
107
|
queue_full: {
|
|
107
108
|
icon: SkipForward,
|
|
@@ -150,7 +151,7 @@ export const RUN_STATUS_CONFIG: Record<RunStatus, RunStatusConfig> = {
|
|
|
150
151
|
dot: "bg-danger-surface",
|
|
151
152
|
badge: "bg-danger-soft text-danger-soft-text",
|
|
152
153
|
description:
|
|
153
|
-
"The service kept failing to stay up for healthy_after; after
|
|
154
|
+
"The service kept failing to stay up for healthy_after; after restart_attempts the supervisor gave up (FATAL) and stopped restarting it.",
|
|
154
155
|
},
|
|
155
156
|
pending: {
|
|
156
157
|
icon: Clock,
|
|
@@ -176,6 +177,6 @@ export function getRunStatusConfig(status: RunStatus): RunStatusConfig {
|
|
|
176
177
|
return RUN_STATUS_CONFIG[status];
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
export function runDisplayStatus(run: Pick<Run, "status" | "
|
|
180
|
-
return displayStatus(run.status, run.
|
|
180
|
+
export function runDisplayStatus(run: Pick<Run, "status" | "endReason">): RunStatus {
|
|
181
|
+
return displayStatus(run.status, run.endReason);
|
|
181
182
|
}
|
package/src/lib/utils/error.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: PoppyCake, s.r.o.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Extracts a human-readable message from an unknown caught value.
|
|
6
|
-
*/
|
|
7
4
|
export function extractErrorMessage(
|
|
8
5
|
err: unknown,
|
|
9
6
|
fallback = "An unexpected error occurred",
|
|
@@ -124,12 +124,8 @@ describe("formatRelativeTimeWithAbsolute", () => {
|
|
|
124
124
|
describe("formatRelativeTime", () => {
|
|
125
125
|
it("advances as the supplied now advances", () => {
|
|
126
126
|
const date = new Date("2024-01-01T12:00:00Z");
|
|
127
|
-
expect(formatRelativeTime(date, new Date("2024-01-01T14:00:00Z"))).toBe(
|
|
128
|
-
|
|
129
|
-
);
|
|
130
|
-
expect(formatRelativeTime(date, new Date("2024-01-01T15:00:00Z"))).toBe(
|
|
131
|
-
"about 3 hours ago",
|
|
132
|
-
);
|
|
127
|
+
expect(formatRelativeTime(date, new Date("2024-01-01T14:00:00Z"))).toBe("2 hours ago");
|
|
128
|
+
expect(formatRelativeTime(date, new Date("2024-01-01T15:00:00Z"))).toBe("3 hours ago");
|
|
133
129
|
});
|
|
134
130
|
});
|
|
135
131
|
|
package/src/lib/utils/format.ts
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: PoppyCake, s.r.o.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// Signed magnitude thresholds for Intl.RelativeTimeFormat, largest-first
|
|
5
|
+
// division. Mirrors the buckets date-fns' formatDistance used to pick.
|
|
6
|
+
const RELATIVE_DIVISIONS: [amount: number, unit: Intl.RelativeTimeFormatUnit][] = [
|
|
7
|
+
[60, "seconds"],
|
|
8
|
+
[60, "minutes"],
|
|
9
|
+
[24, "hours"],
|
|
10
|
+
[7, "days"],
|
|
11
|
+
[4.34524, "weeks"],
|
|
12
|
+
[12, "months"],
|
|
13
|
+
[Number.POSITIVE_INFINITY, "years"],
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
// formatDistance renders a signed date delta as "N units ago" / "in N units"
|
|
17
|
+
// using the platform Intl formatter. Negative delta (date before base) reads as
|
|
18
|
+
// past, positive as future.
|
|
19
|
+
function formatDistance(date: Date, base: Date): string {
|
|
20
|
+
const rtf = new Intl.RelativeTimeFormat(undefined, { numeric: "always" });
|
|
21
|
+
let delta = (date.getTime() - base.getTime()) / 1000;
|
|
22
|
+
for (const [amount, unit] of RELATIVE_DIVISIONS) {
|
|
23
|
+
if (Math.abs(delta) < amount) {
|
|
24
|
+
return rtf.format(Math.round(delta), unit);
|
|
25
|
+
}
|
|
26
|
+
delta /= amount;
|
|
27
|
+
}
|
|
28
|
+
return rtf.format(Math.round(delta), "years");
|
|
29
|
+
}
|
|
5
30
|
|
|
6
31
|
export function formatBytes(bytes: number): string {
|
|
7
32
|
const units: [string, ...string[]] = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
@@ -17,7 +42,7 @@ export function formatBytes(bytes: number): string {
|
|
|
17
42
|
}
|
|
18
43
|
|
|
19
44
|
export function formatRelativeTime(dateStr: string | Date, now: Date = new Date()): string {
|
|
20
|
-
return formatDistance(new Date(dateStr), now
|
|
45
|
+
return formatDistance(new Date(dateStr), now);
|
|
21
46
|
}
|
|
22
47
|
|
|
23
48
|
export function formatRelativeTimeWithAbsolute(
|
|
@@ -25,7 +50,7 @@ export function formatRelativeTimeWithAbsolute(
|
|
|
25
50
|
now: Date = new Date(),
|
|
26
51
|
): string {
|
|
27
52
|
const date = new Date(dateStr);
|
|
28
|
-
const relative = formatDistance(date, now
|
|
53
|
+
const relative = formatDistance(date, now);
|
|
29
54
|
const diffMs = Math.abs(now.getTime() - date.getTime());
|
|
30
55
|
const diffDays = diffMs / (1000 * 60 * 60 * 24);
|
|
31
56
|
|