@alepha/ui 0.25.0 → 0.25.2
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 -5
- package/src/components/account/__tests__/account-router.spec.ts +201 -0
- package/src/components/account/account-connections.tsx +103 -0
- package/src/components/account/account-delete-dialog.tsx +184 -0
- package/src/components/account/account-header.tsx +57 -0
- package/src/components/account/account-keys.tsx +221 -0
- package/src/components/account/account-layout.tsx +63 -0
- package/src/components/account/account-password-dialog.tsx +152 -0
- package/src/components/account/account-profile.tsx +229 -0
- package/src/components/account/account-router-options.tsx +74 -0
- package/src/components/account/account-router-page.tsx +69 -0
- package/src/components/account/account-router.tsx +214 -0
- package/src/components/account/account-security.tsx +150 -0
- package/src/components/account/account-sessions.tsx +140 -0
- package/src/components/admin/__tests__/admin-keys-token-dialog.browser.spec.tsx +62 -0
- package/src/components/admin/__tests__/admin-layout.browser.spec.tsx +82 -0
- package/src/components/admin/__tests__/admin-router-page.spec.ts +54 -0
- package/src/components/admin/__tests__/admin-router.spec.ts +208 -0
- package/src/components/admin/__tests__/admin-user-cell.browser.spec.tsx +99 -0
- package/src/components/admin/__tests__/admin-user-detail.spec.ts +29 -0
- package/src/components/admin/admin-analytics-query-panel.tsx +149 -0
- package/src/components/admin/admin-analytics-results.tsx +95 -0
- package/src/components/admin/admin-analytics.tsx +104 -0
- package/src/components/admin/admin-audits.tsx +12 -15
- package/src/components/admin/admin-files.tsx +10 -18
- package/src/components/admin/admin-jobs-executions-panel.tsx +2 -1
- package/src/components/admin/admin-jobs.tsx +3 -1
- package/src/components/admin/admin-keys-token-dialog.tsx +123 -0
- package/src/components/admin/admin-keys.tsx +54 -3
- package/src/components/admin/admin-layout.tsx +107 -0
- package/src/components/admin/admin-payments.tsx +4 -5
- package/src/components/admin/admin-router-options.tsx +130 -0
- package/src/components/admin/admin-router-page.tsx +74 -0
- package/src/components/admin/admin-router.tsx +379 -0
- package/src/components/admin/admin-sessions.tsx +2 -16
- package/src/components/admin/admin-user-cell.tsx +70 -0
- package/src/components/admin/admin-user-detail-overview-tab.tsx +28 -0
- package/src/components/admin/admin-user-detail-profile-policy.spec.ts +146 -0
- package/src/components/admin/admin-user-detail-profile-policy.ts +147 -0
- package/src/components/admin/admin-user-detail-security-tab.tsx +1 -1
- package/src/components/admin/admin-user-detail.tsx +76 -32
- package/src/components/admin/admin-users-status-filter.tsx +2 -0
- package/src/components/admin/admin-workflows-execution-sheet.tsx +277 -0
- package/src/components/admin/admin-workflows-executions-panel.tsx +170 -0
- package/src/components/admin/admin-workflows-status-badge.tsx +40 -0
- package/src/components/admin/admin-workflows.tsx +207 -0
- package/src/components/alepha-table/alepha-table.tsx +73 -17
- package/src/components/app-actions/__tests__/app-actions.browser.spec.tsx +79 -0
- package/src/components/app-actions/app-actions.tsx +113 -0
- package/src/components/app-shell/app-shell.tsx +122 -0
- package/src/components/auth/auth-reset-password.tsx +81 -8
- package/src/components/button-user/button-user.tsx +58 -1
- package/src/components/control/control.tsx +14 -71
- package/src/components/control-password/control-password.tsx +87 -0
- package/src/components/control-select/__tests__/control-select-clear-label.browser.spec.tsx +101 -0
- package/src/components/control-select/__tests__/control-select-deselect.browser.spec.tsx +126 -0
- package/src/components/control-select/__tests__/control-select-searchable.browser.spec.tsx +142 -0
- package/src/components/control-select/control-select.tsx +133 -111
- package/src/components/control-upload/control-upload.tsx +27 -1
- package/src/components/markdown-view/markdown-view.tsx +6 -0
- package/src/components/nav-shell/nav-page.tsx +3 -3
- package/src/components/settings/__tests__/settings-nav.browser.spec.tsx +123 -0
- package/src/components/settings/__tests__/settings-section.browser.spec.tsx +130 -0
- package/src/components/settings/settings-danger-section.tsx +59 -0
- package/src/components/settings/settings-layout.tsx +56 -0
- package/src/components/settings/settings-nav.tsx +131 -0
- package/src/components/settings/settings-row.tsx +81 -0
- package/src/components/settings/settings-section.tsx +64 -0
- package/src/components/ui/alert-dialog.tsx +1 -1
- package/src/components/ui/avatar.tsx +2 -0
- package/src/components/ui/breadcrumb.tsx +1 -1
- package/src/components/ui/calendar.tsx +11 -6
- package/src/components/ui/card.tsx +5 -5
- package/src/components/ui/carousel.tsx +4 -4
- package/src/components/ui/chart.tsx +2 -0
- package/src/components/ui/collapsible.tsx +2 -0
- package/src/components/ui/combobox.tsx +3 -1
- package/src/components/ui/context-menu.tsx +3 -3
- package/src/components/ui/dialog.tsx +6 -1
- package/src/components/ui/direction.tsx +2 -0
- package/src/components/ui/drawer.tsx +134 -37
- package/src/components/ui/dropdown-menu.tsx +13 -3
- package/src/components/ui/empty.tsx +4 -1
- package/src/components/ui/input-otp.tsx +2 -0
- package/src/components/ui/menubar.tsx +2 -2
- package/src/components/ui/pagination.tsx +2 -2
- package/src/components/ui/popover.tsx +2 -0
- package/src/components/ui/radio-group.tsx +2 -0
- package/src/components/ui/scroll-area.tsx +2 -0
- package/src/components/ui/select.tsx +1 -1
- package/src/components/ui/separator.tsx +2 -0
- package/src/components/ui/sheet.tsx +4 -1
- package/src/components/ui/sidebar.tsx +1 -1
- package/src/components/ui/spinner.tsx +1 -0
- package/src/components/ui/switch.tsx +2 -0
- package/src/components/ui/tabs.tsx +2 -0
- package/src/components/ui/toggle-group.tsx +2 -0
- package/src/components/ui/tooltip.tsx +2 -0
- package/src/lib/__tests__/rehype-safe-img.spec.ts +121 -0
- package/src/lib/i18n-fr.ts +68 -0
- package/src/lib/rehype-safe-img.ts +150 -0
- package/src/lib/resize-image.ts +135 -0
- package/src/styles.css +126 -1
- /package/src/components/{admin/admin-user-detail-provider-labels.ts → auth/provider-labels.ts} +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { WorkflowExecutionSheet } from "@alepha/ui/components/admin/admin-workflows-execution-sheet";
|
|
2
|
+
import { WorkflowStatusBadge } from "@alepha/ui/components/admin/admin-workflows-status-badge";
|
|
3
|
+
import { AlephaTable } from "@alepha/ui/components/alepha-table/alepha-table";
|
|
4
|
+
import { Control } from "@alepha/ui/components/control/control";
|
|
5
|
+
import { type Infer, z } from "alepha";
|
|
6
|
+
import type {
|
|
7
|
+
AdminWorkflowController,
|
|
8
|
+
WorkflowExecutionResource,
|
|
9
|
+
} from "alepha/api/workflows";
|
|
10
|
+
import { useClient } from "alepha/react";
|
|
11
|
+
import { useI18n } from "alepha/react/i18n";
|
|
12
|
+
import { CircleDot } from "lucide-react";
|
|
13
|
+
import { useCallback, useState } from "react";
|
|
14
|
+
|
|
15
|
+
const EXEC_POLL_MS = 10_000;
|
|
16
|
+
|
|
17
|
+
const execFiltersSchema = z.object({
|
|
18
|
+
status: z.string().optional(),
|
|
19
|
+
});
|
|
20
|
+
type ExecFilters = Infer<typeof execFiltersSchema>;
|
|
21
|
+
|
|
22
|
+
export interface WorkflowExecutionsPanelProps {
|
|
23
|
+
workflowName: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Server-paginated executions table for a single workflow. Row click opens
|
|
28
|
+
* the execution detail sheet (step timeline + admin actions).
|
|
29
|
+
*/
|
|
30
|
+
export const WorkflowExecutionsPanel = (
|
|
31
|
+
props: WorkflowExecutionsPanelProps,
|
|
32
|
+
) => {
|
|
33
|
+
const client = useClient<AdminWorkflowController>();
|
|
34
|
+
const { l, tr } = useI18n();
|
|
35
|
+
const [openExecution, setOpenExecution] = useState<string | null>(null);
|
|
36
|
+
|
|
37
|
+
const fetcher = useCallback(
|
|
38
|
+
async (params: {
|
|
39
|
+
page: number;
|
|
40
|
+
size: number;
|
|
41
|
+
sort?: string;
|
|
42
|
+
filters?: ExecFilters;
|
|
43
|
+
}) => {
|
|
44
|
+
return client.findWorkflowExecutions({
|
|
45
|
+
query: {
|
|
46
|
+
page: params.page,
|
|
47
|
+
size: params.size,
|
|
48
|
+
sort: params.sort,
|
|
49
|
+
workflow: props.workflowName,
|
|
50
|
+
status: params.filters?.status as
|
|
51
|
+
| WorkflowExecutionResource["status"]
|
|
52
|
+
| undefined,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
[client, props.workflowName],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
<AlephaTable<WorkflowExecutionResource>
|
|
62
|
+
className="min-h-0 flex-1"
|
|
63
|
+
persistenceKey={`admin.workflows.executions.${props.workflowName}`}
|
|
64
|
+
pollMs={EXEC_POLL_MS}
|
|
65
|
+
rowKey={(e) => e.id}
|
|
66
|
+
fetch={fetcher}
|
|
67
|
+
onRowClick={(e) => setOpenExecution(e.id)}
|
|
68
|
+
filters={{
|
|
69
|
+
schema: execFiltersSchema,
|
|
70
|
+
render: (form) => (
|
|
71
|
+
<Control
|
|
72
|
+
input={form.input.status}
|
|
73
|
+
label=""
|
|
74
|
+
clearable
|
|
75
|
+
icon={CircleDot}
|
|
76
|
+
clearLabel={String(
|
|
77
|
+
tr("admin.workflows.statusAll", { default: "All statuses" }),
|
|
78
|
+
)}
|
|
79
|
+
triggerClassName="w-48"
|
|
80
|
+
items={[
|
|
81
|
+
{ value: "pending", label: "pending" },
|
|
82
|
+
{ value: "running", label: "running" },
|
|
83
|
+
{ value: "completed", label: "completed" },
|
|
84
|
+
{ value: "failed", label: "failed" },
|
|
85
|
+
{ value: "timed_out", label: "timed_out" },
|
|
86
|
+
{ value: "compensating", label: "compensating" },
|
|
87
|
+
{ value: "compensated", label: "compensated" },
|
|
88
|
+
{ value: "compensation_failed", label: "compensation_failed" },
|
|
89
|
+
{ value: "cancelled", label: "cancelled" },
|
|
90
|
+
]}
|
|
91
|
+
/>
|
|
92
|
+
),
|
|
93
|
+
}}
|
|
94
|
+
columns={{
|
|
95
|
+
status: {
|
|
96
|
+
label: tr("admin.workflows.colStatus", { default: "Status" }),
|
|
97
|
+
cell: (e) => <WorkflowStatusBadge status={e.status} />,
|
|
98
|
+
},
|
|
99
|
+
currentStep: {
|
|
100
|
+
label: tr("admin.workflows.colStep", { default: "Step" }),
|
|
101
|
+
cell: (e) =>
|
|
102
|
+
e.currentStep ? (
|
|
103
|
+
<code className="text-xs">{e.currentStep}</code>
|
|
104
|
+
) : (
|
|
105
|
+
<span className="text-muted-foreground">—</span>
|
|
106
|
+
),
|
|
107
|
+
},
|
|
108
|
+
createdAt: {
|
|
109
|
+
label: tr("admin.workflows.colCreated", { default: "Created" }),
|
|
110
|
+
sortable: true,
|
|
111
|
+
cell: (e) => (
|
|
112
|
+
<span className="text-muted-foreground text-xs">
|
|
113
|
+
{String(l(e.createdAt, { date: "fromNow" }))}
|
|
114
|
+
</span>
|
|
115
|
+
),
|
|
116
|
+
},
|
|
117
|
+
duration: {
|
|
118
|
+
label: tr("admin.workflows.colDuration", { default: "Duration" }),
|
|
119
|
+
align: "right",
|
|
120
|
+
cell: (e) => {
|
|
121
|
+
if (!e.startedAt || !e.completedAt) {
|
|
122
|
+
return <span className="text-muted-foreground">—</span>;
|
|
123
|
+
}
|
|
124
|
+
const ms =
|
|
125
|
+
new Date(e.completedAt).getTime() -
|
|
126
|
+
new Date(e.startedAt).getTime();
|
|
127
|
+
return (
|
|
128
|
+
<span className="text-xs">
|
|
129
|
+
{ms < 1000 ? `${ms} ms` : `${(ms / 1000).toFixed(1)} s`}
|
|
130
|
+
</span>
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
triggeredBy: {
|
|
135
|
+
label: tr("admin.workflows.colTriggeredBy", {
|
|
136
|
+
default: "Triggered by",
|
|
137
|
+
}),
|
|
138
|
+
cell: (e) => (
|
|
139
|
+
<span className="text-muted-foreground text-xs">
|
|
140
|
+
{e.triggeredByName ?? e.triggeredBy ?? "—"}
|
|
141
|
+
</span>
|
|
142
|
+
),
|
|
143
|
+
},
|
|
144
|
+
error: {
|
|
145
|
+
label: tr("admin.workflows.colError", { default: "Error" }),
|
|
146
|
+
cell: (e) =>
|
|
147
|
+
e.error ? (
|
|
148
|
+
<span
|
|
149
|
+
className="text-destructive line-clamp-2 text-xs"
|
|
150
|
+
title={e.error}
|
|
151
|
+
>
|
|
152
|
+
{e.error}
|
|
153
|
+
</span>
|
|
154
|
+
) : (
|
|
155
|
+
<span className="text-muted-foreground">—</span>
|
|
156
|
+
),
|
|
157
|
+
},
|
|
158
|
+
}}
|
|
159
|
+
emptyMessage={String(
|
|
160
|
+
tr("admin.workflows.noExecs", { default: "No executions yet." }),
|
|
161
|
+
)}
|
|
162
|
+
/>
|
|
163
|
+
|
|
164
|
+
<WorkflowExecutionSheet
|
|
165
|
+
executionId={openExecution}
|
|
166
|
+
onClose={() => setOpenExecution(null)}
|
|
167
|
+
/>
|
|
168
|
+
</>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Badge } from "@alepha/ui/components/ui/badge";
|
|
2
|
+
import { useI18n } from "alepha/react/i18n";
|
|
3
|
+
|
|
4
|
+
export interface WorkflowStatusBadgeProps {
|
|
5
|
+
/**
|
|
6
|
+
* Accepts both execution statuses and step statuses — the two sets
|
|
7
|
+
* overlap on everything but `timed_out` / `skipped`.
|
|
8
|
+
*/
|
|
9
|
+
status: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const VARIANTS: Record<
|
|
13
|
+
string,
|
|
14
|
+
"default" | "secondary" | "outline" | "destructive"
|
|
15
|
+
> = {
|
|
16
|
+
pending: "secondary",
|
|
17
|
+
running: "default",
|
|
18
|
+
completed: "outline",
|
|
19
|
+
skipped: "outline",
|
|
20
|
+
failed: "destructive",
|
|
21
|
+
timed_out: "destructive",
|
|
22
|
+
compensating: "secondary",
|
|
23
|
+
compensated: "outline",
|
|
24
|
+
compensation_failed: "destructive",
|
|
25
|
+
cancelled: "outline",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Coloured badge for a workflow execution or step status.
|
|
30
|
+
*/
|
|
31
|
+
export const WorkflowStatusBadge = (props: WorkflowStatusBadgeProps) => {
|
|
32
|
+
const { tr } = useI18n();
|
|
33
|
+
return (
|
|
34
|
+
<Badge variant={VARIANTS[props.status] ?? "outline"}>
|
|
35
|
+
{tr(`admin.workflows.status.${props.status}` as any, {
|
|
36
|
+
default: props.status,
|
|
37
|
+
})}
|
|
38
|
+
</Badge>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
void React;
|
|
4
|
+
|
|
5
|
+
import { AdminPage } from "@alepha/ui/components/admin/admin-page";
|
|
6
|
+
import { WorkflowExecutionsPanel } from "@alepha/ui/components/admin/admin-workflows-executions-panel";
|
|
7
|
+
import { AlephaTable } from "@alepha/ui/components/alepha-table/alepha-table";
|
|
8
|
+
import { Control } from "@alepha/ui/components/control/control";
|
|
9
|
+
import { Badge } from "@alepha/ui/components/ui/badge";
|
|
10
|
+
import {
|
|
11
|
+
Sheet,
|
|
12
|
+
SheetContent,
|
|
13
|
+
SheetDescription,
|
|
14
|
+
SheetHeader,
|
|
15
|
+
SheetTitle,
|
|
16
|
+
} from "@alepha/ui/components/ui/sheet";
|
|
17
|
+
import { type Infer, type Page, z } from "alepha";
|
|
18
|
+
import type {
|
|
19
|
+
AdminWorkflowController,
|
|
20
|
+
WorkflowRegistration,
|
|
21
|
+
} from "alepha/api/workflows";
|
|
22
|
+
import { useClient } from "alepha/react";
|
|
23
|
+
import { useI18n } from "alepha/react/i18n";
|
|
24
|
+
import { ListOrdered, Search } from "lucide-react";
|
|
25
|
+
import { useCallback, useState } from "react";
|
|
26
|
+
|
|
27
|
+
const POLL_MS = 30_000;
|
|
28
|
+
|
|
29
|
+
const workflowFiltersSchema = z.object({
|
|
30
|
+
search: z.string().optional(),
|
|
31
|
+
});
|
|
32
|
+
type WorkflowFilters = Infer<typeof workflowFiltersSchema>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Wrap an in-memory array as a `Page<T>` so it can feed `AlephaTable`'s
|
|
36
|
+
* fetcher without server-side pagination — appropriate for the bounded
|
|
37
|
+
* workflow registry.
|
|
38
|
+
*/
|
|
39
|
+
function asPage<T>(items: T[]): Page<T> {
|
|
40
|
+
return {
|
|
41
|
+
content: items,
|
|
42
|
+
page: {
|
|
43
|
+
number: 0,
|
|
44
|
+
size: items.length,
|
|
45
|
+
offset: 0,
|
|
46
|
+
numberOfElements: items.length,
|
|
47
|
+
totalElements: items.length,
|
|
48
|
+
totalPages: 1,
|
|
49
|
+
isEmpty: items.length === 0,
|
|
50
|
+
isFirst: true,
|
|
51
|
+
isLast: true,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function applyWorkflowFilters(
|
|
57
|
+
workflows: WorkflowRegistration[],
|
|
58
|
+
filters?: WorkflowFilters,
|
|
59
|
+
): WorkflowRegistration[] {
|
|
60
|
+
const q = filters?.search?.trim().toLowerCase();
|
|
61
|
+
if (!q) return workflows;
|
|
62
|
+
return workflows.filter(
|
|
63
|
+
(w) =>
|
|
64
|
+
w.name.toLowerCase().includes(q) ||
|
|
65
|
+
(w.tags?.some((t) => t.toLowerCase().includes(q)) ?? false),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function AdminWorkflows() {
|
|
70
|
+
const client = useClient<AdminWorkflowController>();
|
|
71
|
+
const { tr } = useI18n();
|
|
72
|
+
const [openWorkflow, setOpenWorkflow] = useState<WorkflowRegistration | null>(
|
|
73
|
+
null,
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const fetcher = useCallback(
|
|
77
|
+
async (params: { filters?: WorkflowFilters }) => {
|
|
78
|
+
const workflows = await client.getWorkflowRegistry();
|
|
79
|
+
return asPage(applyWorkflowFilters(workflows, params.filters));
|
|
80
|
+
},
|
|
81
|
+
[client],
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<AdminPage>
|
|
86
|
+
<AlephaTable<WorkflowRegistration>
|
|
87
|
+
className="min-h-0 flex-1"
|
|
88
|
+
persistenceKey="admin.workflows"
|
|
89
|
+
pollMs={POLL_MS}
|
|
90
|
+
rowKey={(w) => w.name}
|
|
91
|
+
fetch={fetcher}
|
|
92
|
+
onRowClick={(w) => setOpenWorkflow(w)}
|
|
93
|
+
filters={{
|
|
94
|
+
schema: workflowFiltersSchema,
|
|
95
|
+
render: (form) => (
|
|
96
|
+
<div className="w-72">
|
|
97
|
+
<Control
|
|
98
|
+
input={form.input.search}
|
|
99
|
+
label=""
|
|
100
|
+
icon={Search}
|
|
101
|
+
placeholder={String(
|
|
102
|
+
tr("admin.workflows.searchPlaceholder", {
|
|
103
|
+
default: "Search…",
|
|
104
|
+
}),
|
|
105
|
+
)}
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
),
|
|
109
|
+
}}
|
|
110
|
+
columns={{
|
|
111
|
+
name: {
|
|
112
|
+
label: tr("admin.workflows.colName", { default: "Name" }),
|
|
113
|
+
sortable: true,
|
|
114
|
+
cell: (w) => (
|
|
115
|
+
<div className="flex min-w-0 flex-col">
|
|
116
|
+
<span className="truncate font-medium">{w.name}</span>
|
|
117
|
+
<span className="text-muted-foreground truncate text-xs">
|
|
118
|
+
{w.steps.map((s) => s.name).join(" → ")}
|
|
119
|
+
</span>
|
|
120
|
+
</div>
|
|
121
|
+
),
|
|
122
|
+
},
|
|
123
|
+
steps: {
|
|
124
|
+
label: tr("admin.workflows.colSteps", { default: "Steps" }),
|
|
125
|
+
align: "right",
|
|
126
|
+
cell: (w) => w.stepCount,
|
|
127
|
+
},
|
|
128
|
+
onError: {
|
|
129
|
+
label: tr("admin.workflows.colOnError", { default: "On error" }),
|
|
130
|
+
cell: (w) => (
|
|
131
|
+
<Badge
|
|
132
|
+
variant={w.onError === "compensate" ? "secondary" : "outline"}
|
|
133
|
+
>
|
|
134
|
+
{w.onError}
|
|
135
|
+
</Badge>
|
|
136
|
+
),
|
|
137
|
+
},
|
|
138
|
+
priority: {
|
|
139
|
+
label: tr("admin.workflows.colPriority", { default: "Priority" }),
|
|
140
|
+
cell: (w) => <Badge variant="outline">{w.priority}</Badge>,
|
|
141
|
+
},
|
|
142
|
+
running: {
|
|
143
|
+
label: tr("admin.workflows.colRunning", { default: "Running" }),
|
|
144
|
+
align: "right",
|
|
145
|
+
cell: (w) => w.running,
|
|
146
|
+
},
|
|
147
|
+
pending: {
|
|
148
|
+
label: tr("admin.workflows.colPending", { default: "Pending" }),
|
|
149
|
+
align: "right",
|
|
150
|
+
cell: (w) => w.pending,
|
|
151
|
+
},
|
|
152
|
+
failed: {
|
|
153
|
+
label: tr("admin.workflows.colFailed", { default: "Failed" }),
|
|
154
|
+
align: "right",
|
|
155
|
+
cell: (w) => (
|
|
156
|
+
<span className={w.failed > 0 ? "text-destructive" : undefined}>
|
|
157
|
+
{w.failed}
|
|
158
|
+
</span>
|
|
159
|
+
),
|
|
160
|
+
},
|
|
161
|
+
}}
|
|
162
|
+
rowActions={(w) => [
|
|
163
|
+
{
|
|
164
|
+
label: tr("admin.workflows.viewExecutions", {
|
|
165
|
+
default: "View executions",
|
|
166
|
+
}),
|
|
167
|
+
icon: ListOrdered,
|
|
168
|
+
onClick: () => setOpenWorkflow(w),
|
|
169
|
+
},
|
|
170
|
+
]}
|
|
171
|
+
emptyMessage={String(
|
|
172
|
+
tr("admin.workflows.none", { default: "No workflows registered." }),
|
|
173
|
+
)}
|
|
174
|
+
/>
|
|
175
|
+
|
|
176
|
+
<Sheet
|
|
177
|
+
open={openWorkflow !== null}
|
|
178
|
+
onOpenChange={(open) => {
|
|
179
|
+
if (!open) setOpenWorkflow(null);
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
<SheetContent
|
|
183
|
+
side="right"
|
|
184
|
+
className="flex w-full flex-col gap-0 data-[side=right]:sm:max-w-[60vw]"
|
|
185
|
+
>
|
|
186
|
+
{openWorkflow && (
|
|
187
|
+
<>
|
|
188
|
+
<SheetHeader>
|
|
189
|
+
<SheetTitle>{openWorkflow.name}</SheetTitle>
|
|
190
|
+
<SheetDescription>
|
|
191
|
+
{tr("admin.workflows.execsDescription", {
|
|
192
|
+
default: "Executions for this workflow.",
|
|
193
|
+
})}
|
|
194
|
+
</SheetDescription>
|
|
195
|
+
</SheetHeader>
|
|
196
|
+
<div className="flex min-h-0 flex-1 flex-col p-4">
|
|
197
|
+
<WorkflowExecutionsPanel workflowName={openWorkflow.name} />
|
|
198
|
+
</div>
|
|
199
|
+
</>
|
|
200
|
+
)}
|
|
201
|
+
</SheetContent>
|
|
202
|
+
</Sheet>
|
|
203
|
+
</AdminPage>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export default AdminWorkflows;
|
|
@@ -228,6 +228,12 @@ export interface AlephaTableProps<T> {
|
|
|
228
228
|
/**
|
|
229
229
|
* Extra slot rendered to the right of the filter inputs in the
|
|
230
230
|
* toolbar — typically a "New" / "Create" button.
|
|
231
|
+
*
|
|
232
|
+
* Controls placed here must be h-9 (`Button size="lg"`, or an explicit
|
|
233
|
+
* `h-9`): the bar bottom-aligns its children (`items-end`, so controls
|
|
234
|
+
* share a baseline with label-topped filter inputs) and pins its built-in
|
|
235
|
+
* icon buttons to h-9 — a shorter control hangs from the bottom edge and
|
|
236
|
+
* reads as vertically off-center.
|
|
231
237
|
*/
|
|
232
238
|
toolbar?: ReactNode;
|
|
233
239
|
/**
|
|
@@ -646,7 +652,28 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
646
652
|
)}
|
|
647
653
|
|
|
648
654
|
{showToolbar && (
|
|
649
|
-
|
|
655
|
+
// `bg-muted`, paired with the pagination footer below: the filter bar
|
|
656
|
+
// and the footer are the table's chrome and bracket it top and
|
|
657
|
+
// bottom, so they sit one step off the page while the table itself
|
|
658
|
+
// (header included) stays on it. They were `bg-card` — pure white in
|
|
659
|
+
// light, the same colour as the page, so neither had an edge.
|
|
660
|
+
//
|
|
661
|
+
// The controls need an explicit fill because of that. shadcn ships
|
|
662
|
+
// inputs and select triggers `bg-transparent` in light and only fills
|
|
663
|
+
// them in dark (`dark:bg-input/30`) — the light case assumes a white
|
|
664
|
+
// page, where transparent already reads as a white field. On this bar
|
|
665
|
+
// it does not: they would take the muted grey and the border alone
|
|
666
|
+
// would have to say "input". Scoped here rather than to the
|
|
667
|
+
// primitives, which `yarn w @alepha/ui sync` overwrites.
|
|
668
|
+
//
|
|
669
|
+
// `bg-background` suits both modes: white against the muted bar in
|
|
670
|
+
// light, near-black in dark, so the control reads as a well sunk
|
|
671
|
+
// into the chrome either way. The `dark:` copy is not redundant —
|
|
672
|
+
// the primitives ship `dark:bg-input/30` at (0,2,0), a translucent
|
|
673
|
+
// WHITE wash that leaves the field lighter than the bar. Only the
|
|
674
|
+
// dark-scoped rule (0,3,0) outranks it, and without it the two
|
|
675
|
+
// controls disagreed: the trigger went dark, the input stayed light.
|
|
676
|
+
<div className="bg-muted flex flex-wrap items-end gap-2 rounded-md rounded-b-none border p-2 [&_:is(input,[role=combobox])]:bg-background dark:[&_:is(input,[role=combobox])]:bg-background">
|
|
650
677
|
{props.filters && form ? (
|
|
651
678
|
<form
|
|
652
679
|
{...form.props}
|
|
@@ -804,10 +831,20 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
804
831
|
</div>
|
|
805
832
|
)}
|
|
806
833
|
|
|
834
|
+
{/*
|
|
835
|
+
The toolbar, the rows and the footer are one panel: each facing edge
|
|
836
|
+
is flattened and its border dropped so no double line appears, and
|
|
837
|
+
`-mt-2` cancels the wrapper's `gap-2`. The footer half is
|
|
838
|
+
unconditional because the page row below already renders
|
|
839
|
+
unconditionally — gating it on `meta` would pop the bar in and flip
|
|
840
|
+
this bottom border on every load, since `meta` starts null and only
|
|
841
|
+
fills after the fetch.
|
|
842
|
+
*/}
|
|
807
843
|
<div
|
|
808
844
|
className={cn(
|
|
809
845
|
"flex min-h-0 flex-1 flex-col overflow-auto rounded-md border",
|
|
810
846
|
showToolbar && "-mt-2 rounded-t-none border-t-0",
|
|
847
|
+
"rounded-b-none border-b-0",
|
|
811
848
|
)}
|
|
812
849
|
>
|
|
813
850
|
<Table>
|
|
@@ -961,7 +998,8 @@ export function AlephaTable<T>(props: AlephaTableProps<T>) {
|
|
|
961
998
|
</Table>
|
|
962
999
|
</div>
|
|
963
1000
|
|
|
964
|
-
|
|
1001
|
+
{/* `bg-muted`, paired with the filter bar above — see the note there. */}
|
|
1002
|
+
<div className="bg-muted -mt-2 flex flex-wrap items-center justify-between gap-2 rounded-md rounded-t-none border p-2">
|
|
965
1003
|
<p className="text-muted-foreground text-xs">
|
|
966
1004
|
{meta
|
|
967
1005
|
? `Page ${meta.number + 1}${meta.totalPages ? ` of ${meta.totalPages}` : ""} · ${meta.numberOfElements} of ${meta.totalElements ?? "?"}`
|
|
@@ -1033,23 +1071,41 @@ function ColumnPicker<T>(props: {
|
|
|
1033
1071
|
}) {
|
|
1034
1072
|
const { tr } = useI18n();
|
|
1035
1073
|
const entries = Object.entries(props.columns);
|
|
1074
|
+
const label = tr("alephaTable.toggleColumns", {
|
|
1075
|
+
default: "Toggle columns",
|
|
1076
|
+
});
|
|
1036
1077
|
return (
|
|
1037
1078
|
<DropdownMenu>
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1079
|
+
{/*
|
|
1080
|
+
* The trigger is composed rather than plain: it has to be the dropdown
|
|
1081
|
+
* trigger AND the tooltip trigger at once, or this button is the only
|
|
1082
|
+
* icon-only control in the toolbar with no tooltip (reset-filters and
|
|
1083
|
+
* refresh sit right next to it and both have one).
|
|
1084
|
+
*
|
|
1085
|
+
* `TooltipTrigger` wraps the rendered element rather than the other way
|
|
1086
|
+
* round, matching how `sidebar.tsx` composes the same two primitives.
|
|
1087
|
+
* `TooltipProvider` is supplied by the toolbar that renders this.
|
|
1088
|
+
*/}
|
|
1089
|
+
<Tooltip>
|
|
1090
|
+
<DropdownMenuTrigger
|
|
1091
|
+
render={
|
|
1092
|
+
<TooltipTrigger
|
|
1093
|
+
render={
|
|
1094
|
+
<Button
|
|
1095
|
+
type="button"
|
|
1096
|
+
size="sm"
|
|
1097
|
+
variant="ghost"
|
|
1098
|
+
className="h-9 w-9 p-0"
|
|
1099
|
+
aria-label={label}
|
|
1100
|
+
/>
|
|
1101
|
+
}
|
|
1102
|
+
/>
|
|
1103
|
+
}
|
|
1104
|
+
>
|
|
1105
|
+
<Columns3 className="size-4" />
|
|
1106
|
+
</DropdownMenuTrigger>
|
|
1107
|
+
<TooltipContent>{label}</TooltipContent>
|
|
1108
|
+
</Tooltip>
|
|
1053
1109
|
<DropdownMenuContent align="end">
|
|
1054
1110
|
<DropdownMenuGroup>
|
|
1055
1111
|
<DropdownMenuLabel>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import { Alepha } from "alepha";
|
|
3
|
+
import { AlephaContext } from "alepha/react";
|
|
4
|
+
import { $page, AlephaReactRouter } from "alepha/react/router";
|
|
5
|
+
import { setupJsdomMocks } from "alepha/react/testing";
|
|
6
|
+
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
|
7
|
+
import { ButtonUser } from "../../button-user/button-user.tsx";
|
|
8
|
+
import { DropdownMenu, DropdownMenuContent } from "../../ui/dropdown-menu.tsx";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* What this pins is the bug that prompted the shared cluster: `apps/lore`'s
|
|
12
|
+
* header pushed a route called `me`, which stopped existing when the profile
|
|
13
|
+
* pages moved to `/account`. It kept compiling — `router.push` falls back to a
|
|
14
|
+
* plain `string` overload — and threw only when somebody clicked it.
|
|
15
|
+
*
|
|
16
|
+
* `AccountMenuItem` owns its destination so no caller can pass a dead name,
|
|
17
|
+
* and hides itself when the account area is not mounted so an application
|
|
18
|
+
* without one gets no entry rather than a broken one.
|
|
19
|
+
*/
|
|
20
|
+
describe("ButtonUser.AccountMenuItem", () => {
|
|
21
|
+
let alepha: Alepha | undefined;
|
|
22
|
+
|
|
23
|
+
beforeAll(() => {
|
|
24
|
+
setupJsdomMocks();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(async () => {
|
|
28
|
+
await alepha?.stop();
|
|
29
|
+
alepha = undefined;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const mount = async (options: { withAccountRoute: boolean }) => {
|
|
33
|
+
alepha = Alepha.create().with(AlephaReactRouter);
|
|
34
|
+
|
|
35
|
+
if (options.withAccountRoute) {
|
|
36
|
+
class AccountLike {
|
|
37
|
+
account = $page({
|
|
38
|
+
name: "account",
|
|
39
|
+
path: "/account",
|
|
40
|
+
component: () => "account",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
alepha.with(AccountLike);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// A signed-in viewer; the item is account-holder-only.
|
|
47
|
+
alepha.store.set("alepha.security.user", {
|
|
48
|
+
id: "u-1",
|
|
49
|
+
email: "ada@example.com",
|
|
50
|
+
} as never);
|
|
51
|
+
await alepha.start();
|
|
52
|
+
|
|
53
|
+
// `DropdownMenuItem` needs a menu ancestor (Base UI throws without one),
|
|
54
|
+
// and the menu must be open for its content to mount.
|
|
55
|
+
return render(
|
|
56
|
+
<AlephaContext.Provider value={alepha}>
|
|
57
|
+
<DropdownMenu open>
|
|
58
|
+
<DropdownMenuContent>
|
|
59
|
+
<ButtonUser.AccountMenuItem />
|
|
60
|
+
</DropdownMenuContent>
|
|
61
|
+
</DropdownMenu>
|
|
62
|
+
</AlephaContext.Provider>,
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
it("renders nothing when no account route is mounted", async () => {
|
|
67
|
+
// An application that never mounts AccountRouter must get no entry — a
|
|
68
|
+
// visible one would throw on click, which is exactly the old failure.
|
|
69
|
+
await mount({ withAccountRoute: false });
|
|
70
|
+
|
|
71
|
+
expect(screen.queryByText("User Account")).toBeNull();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("labels itself 'User Account' when the area exists", async () => {
|
|
75
|
+
await mount({ withAccountRoute: true });
|
|
76
|
+
|
|
77
|
+
expect(screen.getByText("User Account")).toBeTruthy();
|
|
78
|
+
});
|
|
79
|
+
});
|