@durablex/react-ui 0.1.0-beta.3 → 0.1.0-beta.4
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/dist/index.d.ts +13 -6
- package/dist/index.js +31 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/RunsView.tsx +49 -5
- package/src/components/WorkflowsView.tsx +2 -2
- package/src/index.ts +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@durablex/react-ui",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"description": "Styled, themeable React components for durablex - the shell, run tables, and status views built on @durablex/react.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { X } from "lucide-react";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
2
3
|
import { toast } from "sonner";
|
|
3
4
|
import { type TriggerKind, useReplayRun, useRuns, useRunStats } from "@durablex/react";
|
|
4
5
|
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "../ui/resizable";
|
|
5
6
|
import { useKeysetPager } from "../hooks/use-keyset-pager";
|
|
6
7
|
import { ALL_FILTER, type RunTypeFilter, type StatusFilter } from "../lib/run-filters";
|
|
7
|
-
import { type RunSort, type RunSortKey, toggleRunSort } from "../lib/run-sort";
|
|
8
|
-
import { timeLabel, windowSince } from "../lib/time-range";
|
|
8
|
+
import { DEFAULT_RUN_SORT, type RunSort, type RunSortKey, toggleRunSort } from "../lib/run-sort";
|
|
9
|
+
import { DEFAULT_TIME_RANGE, timeLabel, windowSince } from "../lib/time-range";
|
|
9
10
|
import { BulkReplayButton } from "./BulkReplayButton";
|
|
10
11
|
import { CursorPager } from "./CursorPager";
|
|
11
12
|
import { RetryFromStepButton } from "./RetryFromStepButton";
|
|
@@ -37,14 +38,57 @@ export interface RunsViewState {
|
|
|
37
38
|
replayOf: string | null;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export
|
|
41
|
+
export const DEFAULT_RUNS_VIEW_STATE: RunsViewState = {
|
|
42
|
+
status: ALL_FILTER,
|
|
43
|
+
app: ALL_FILTER,
|
|
44
|
+
runType: ALL_FILTER,
|
|
45
|
+
time: DEFAULT_TIME_RANGE,
|
|
46
|
+
q: "",
|
|
47
|
+
deep: false,
|
|
48
|
+
sort: DEFAULT_RUN_SORT,
|
|
49
|
+
run: null,
|
|
50
|
+
event: null,
|
|
51
|
+
replayOf: null,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Local-state backing for consumers that do not wire RunsView to their own store
|
|
55
|
+
// (the OSS dashboard backs it with the URL instead). `initial` seeds deep-links.
|
|
56
|
+
export function useRunsViewState(initial?: Partial<RunsViewState>): {
|
|
41
57
|
state: RunsViewState;
|
|
42
|
-
onChange: (patch: Partial<RunsViewState
|
|
58
|
+
onChange: (patch: Partial<RunsViewState>) => void;
|
|
59
|
+
} {
|
|
60
|
+
const [state, setState] = useState<RunsViewState>(() => ({
|
|
61
|
+
...DEFAULT_RUNS_VIEW_STATE,
|
|
62
|
+
...initial,
|
|
63
|
+
}));
|
|
64
|
+
const onChange = useCallback(
|
|
65
|
+
(patch: Partial<RunsViewState>) => setState((s) => ({ ...s, ...patch })),
|
|
66
|
+
[],
|
|
67
|
+
);
|
|
68
|
+
return { state, onChange };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface RunsViewProps {
|
|
72
|
+
// Controlled: pass both to back the view with your own store. Omit both to run
|
|
73
|
+
// uncontrolled with internal state seeded by initialState.
|
|
74
|
+
state?: RunsViewState;
|
|
75
|
+
onChange?: (patch: Partial<RunsViewState>, opts?: { push?: boolean }) => void;
|
|
76
|
+
initialState?: Partial<RunsViewState>;
|
|
43
77
|
// Omit the write surface (run controls, replay, bulk replay) for a read-only embed.
|
|
44
78
|
readOnly?: boolean;
|
|
45
79
|
}
|
|
46
80
|
|
|
47
|
-
export function RunsView({
|
|
81
|
+
export function RunsView({
|
|
82
|
+
state: controlledState,
|
|
83
|
+
onChange: controlledOnChange,
|
|
84
|
+
initialState,
|
|
85
|
+
readOnly = false,
|
|
86
|
+
}: RunsViewProps) {
|
|
87
|
+
// Uncontrolled by default (own local state); a consumer that wants to back the
|
|
88
|
+
// view with its own store (the OSS dashboard uses the URL) passes state + onChange.
|
|
89
|
+
const local = useRunsViewState(initialState);
|
|
90
|
+
const state = controlledState ?? local.state;
|
|
91
|
+
const onChange = controlledOnChange ?? local.onChange;
|
|
48
92
|
const {
|
|
49
93
|
app,
|
|
50
94
|
runType,
|
|
@@ -19,7 +19,7 @@ export function WorkflowsView({
|
|
|
19
19
|
onOpenRun,
|
|
20
20
|
renderRunAction,
|
|
21
21
|
}: {
|
|
22
|
-
onOpenRun(runId: string)
|
|
22
|
+
onOpenRun?: (runId: string) => void;
|
|
23
23
|
renderRunAction?: (workflow: WorkflowDef) => ReactNode;
|
|
24
24
|
}) {
|
|
25
25
|
const { data, isLoading, isError, error } = useWorkflows();
|
|
@@ -91,7 +91,7 @@ export function WorkflowsView({
|
|
|
91
91
|
key={selectedKey ?? ""}
|
|
92
92
|
workflow={selected}
|
|
93
93
|
onClose={() => setSelectedKey(null)}
|
|
94
|
-
onOpenRun={onOpenRun}
|
|
94
|
+
onOpenRun={onOpenRun ?? (() => {})}
|
|
95
95
|
renderRunAction={renderRunAction}
|
|
96
96
|
/>
|
|
97
97
|
</ResizablePanel>
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,11 @@ export { Topbar } from "./shell/Topbar";
|
|
|
6
6
|
export { RunInspector } from "./components/RunInspector";
|
|
7
7
|
export type { RunInspectorProps } from "./components/RunInspector";
|
|
8
8
|
export { RunInspectorActions } from "./components/RunInspectorActions";
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
DEFAULT_RUNS_VIEW_STATE,
|
|
11
|
+
RunsView,
|
|
12
|
+
useRunsViewState,
|
|
13
|
+
} from "./components/RunsView";
|
|
10
14
|
export type { RunsViewProps, RunsViewState } from "./components/RunsView";
|
|
11
15
|
export { Meta } from "./components/Meta";
|
|
12
16
|
export { JsonBlock } from "./components/JsonBlock";
|