@ploykit/ui 0.6.0 → 0.6.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/dist/AppProviders.js +2 -2
- package/dist/components/ConfirmDialog.js +1 -1
- package/dist/components/CronInput.js +3 -3
- package/dist/components/DataTable.js +4 -4
- package/dist/components/FormField.js +1 -1
- package/dist/components/ImpersonationBanner.js +1 -1
- package/dist/components/NotificationBell.js +1 -1
- package/dist/components/OnboardingChecklist.js +3 -3
- package/dist/components/Page.js +2 -2
- package/dist/components/ReauthDialog.js +4 -4
- package/dist/components/SecretModal.js +2 -2
- package/dist/components/SettingsCard.js +2 -2
- package/dist/components/SiteBanner.js +1 -1
- package/dist/components/SiteBannerLayer.js +1 -1
- package/dist/components/StatusBadge.js +1 -1
- package/dist/components/UserMenu.js +3 -3
- package/dist/components/WorkspaceSwitcher.js +7 -7
- package/dist/components/ui/alert-dialog.js +2 -2
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/dialog.js +2 -2
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.js +3 -3
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/label.js +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/sheet.js +2 -2
- package/dist/components/ui/sidebar.js +8 -8
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/index.js +78 -78
- package/dist/layouts/AppShell.js +4 -4
- package/dist/layouts/SettingsShell.js +4 -4
- package/dist/pages/LoginPage.js +5 -5
- package/dist/pages/account/NotificationPreferencesPage.js +3 -3
- package/dist/pages/account/ProfileSettingsPage.js +9 -9
- package/dist/pages/account/SecuritySettingsPage.js +13 -13
- package/dist/pages/account/TokensPage.js +12 -12
- package/dist/pages/admin/AdminSettingsPage.js +11 -11
- package/dist/pages/admin/AdminShell.js +3 -3
- package/dist/pages/admin/AuditPage.js +8 -8
- package/dist/pages/admin/OrdersPage.js +12 -12
- package/dist/pages/admin/OverviewPage.js +13 -13
- package/dist/pages/admin/SSOPage.js +6 -6
- package/dist/pages/admin/UserDetailPage.js +13 -13
- package/dist/pages/admin/UsersPage.js +13 -13
- package/dist/pages/admin/WebhookDeliveriesPage.js +9 -9
- package/dist/pages/admin/WorkspaceDetailPage.js +14 -14
- package/dist/pages/admin/WorkspacesPage.js +9 -9
- package/dist/pages/admin/shared.js +1 -1
- package/dist/pages/auth/ForgotPasswordPage.js +4 -4
- package/dist/pages/auth/InviteAcceptPage.js +6 -6
- package/dist/pages/auth/RegisterPage.js +7 -7
- package/dist/pages/auth/ResetPasswordPage.js +5 -5
- package/dist/pages/auth/VerifyEmailPage.js +3 -3
- package/dist/pages/workspace/BillingPage.js +11 -11
- package/dist/pages/workspace/BillingSuccessPage.js +2 -2
- package/dist/pages/workspace/MembersPage.js +15 -15
- package/dist/pages/workspace/RolePermissionsPage.js +9 -9
- package/dist/pages/workspace/SchedulesPage.js +12 -12
- package/dist/pages/workspace/UsagePage.js +6 -6
- package/dist/pages/workspace/WebhooksPage.js +16 -16
- package/dist/pages/workspace/WorkspaceAuditPage.js +7 -7
- package/dist/pages/workspace/WorkspaceGeneralPage.js +9 -9
- package/package.json +6 -5
- package/src/AppProviders.tsx +29 -0
- package/src/components/ConfirmDialog.tsx +77 -0
- package/src/components/CronInput.tsx +195 -0
- package/src/components/DataTable.tsx +152 -0
- package/src/components/ErrorBoundary.tsx +46 -0
- package/src/components/FormField.tsx +56 -0
- package/src/components/ImpersonationBanner.tsx +23 -0
- package/src/components/NotificationBell.tsx +135 -0
- package/src/components/OnboardingChecklist.tsx +114 -0
- package/src/components/Page.tsx +67 -0
- package/src/components/ReauthDialog.tsx +94 -0
- package/src/components/SecretModal.tsx +147 -0
- package/src/components/SettingsCard.tsx +39 -0
- package/src/components/SiteBanner.tsx +32 -0
- package/src/components/SiteBannerLayer.tsx +29 -0
- package/src/components/StatusBadge.tsx +12 -0
- package/src/components/UserMenu.tsx +103 -0
- package/src/components/WorkspaceSwitcher.tsx +159 -0
- package/src/components/__tests__/AppProviders.test.tsx +111 -0
- package/src/components/__tests__/CronInput.test.tsx +180 -0
- package/src/components/__tests__/DataTable.test.tsx +208 -0
- package/src/components/__tests__/ErrorBoundary.test.tsx +61 -0
- package/src/components/__tests__/ImpersonationBanner.test.tsx +59 -0
- package/src/components/__tests__/NotificationBell.test.tsx +207 -0
- package/src/components/__tests__/OnboardingChecklist.test.tsx +97 -0
- package/src/components/__tests__/SecretModal.test.tsx +112 -0
- package/src/components/__tests__/SiteBannerLayer.test.tsx +44 -0
- package/src/components/__tests__/UserMenu.test.tsx +98 -0
- package/src/components/__tests__/WorkspaceSwitcher.test.tsx +162 -0
- package/src/components/__tests__/form.test.tsx +133 -0
- package/src/components/__tests__/semantic-tokens.test.ts +41 -0
- package/src/components/__tests__/smoke.test.tsx +11 -0
- package/src/components/__tests__/toast.test.tsx +27 -0
- package/src/components/toast.tsx +23 -0
- package/src/components/ui/__tests__/alert-dialog.test.tsx +66 -0
- package/src/components/ui/__tests__/avatar.test.tsx +30 -0
- package/src/components/ui/__tests__/checkbox.test.tsx +18 -0
- package/src/components/ui/__tests__/dropdown-menu.test.tsx +33 -0
- package/src/components/ui/__tests__/field.test.tsx +43 -0
- package/src/components/ui/__tests__/overlay-size.test.tsx +84 -0
- package/src/components/ui/__tests__/popover.test.tsx +32 -0
- package/src/components/ui/__tests__/progress.test.tsx +24 -0
- package/src/components/ui/__tests__/select-callback.test.tsx +72 -0
- package/src/components/ui/__tests__/select.test.tsx +48 -0
- package/src/components/ui/__tests__/sidebar.test.tsx +121 -0
- package/src/components/ui/__tests__/stock-mirror.test.ts +39 -0
- package/src/components/ui/__tests__/subpath.test.tsx +38 -0
- package/src/components/ui/__tests__/switch.test.tsx +24 -0
- package/src/components/ui/__tests__/tabs.test.tsx +24 -0
- package/src/components/ui/__tests__/textarea.test.tsx +41 -0
- package/src/components/ui/alert-dialog.tsx +187 -0
- package/src/components/ui/avatar.tsx +108 -0
- package/src/components/ui/badge.tsx +51 -0
- package/src/components/ui/breadcrumb.tsx +124 -0
- package/src/components/ui/button.tsx +57 -0
- package/src/components/ui/card.tsx +102 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/dialog.tsx +166 -0
- package/src/components/ui/dropdown-menu.tsx +265 -0
- package/src/components/ui/empty.tsx +103 -0
- package/src/components/ui/field.tsx +238 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/label.tsx +17 -0
- package/src/components/ui/popover.tsx +89 -0
- package/src/components/ui/progress.tsx +82 -0
- package/src/components/ui/select.tsx +235 -0
- package/src/components/ui/separator.tsx +24 -0
- package/src/components/ui/sheet.tsx +146 -0
- package/src/components/ui/sidebar.tsx +723 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/tabs.tsx +79 -0
- package/src/components/ui/textarea.tsx +26 -0
- package/src/components/ui/tooltip.tsx +63 -0
- package/src/dev.css +1 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/index.ts +150 -0
- package/src/layouts/AppShell.tsx +163 -0
- package/src/layouts/AuthShell.tsx +24 -0
- package/src/layouts/SettingsShell.tsx +129 -0
- package/src/layouts/__tests__/AppShell.test.tsx +163 -0
- package/src/layouts/__tests__/SettingsShell.test.tsx +146 -0
- package/src/lib/__tests__/api-error.test.ts +163 -0
- package/src/lib/__tests__/utils.test.ts +21 -0
- package/src/lib/api-error.ts +98 -0
- package/src/lib/utils.ts +109 -0
- package/src/pages/LandingPage.tsx +88 -0
- package/src/pages/LoginPage.tsx +291 -0
- package/src/pages/__tests__/LandingPage.test.tsx +58 -0
- package/src/pages/__tests__/LoginPage.test.tsx +229 -0
- package/src/pages/__tests__/RegisterPage.test.tsx +138 -0
- package/src/pages/__tests__/ssr-smoke.test.tsx +99 -0
- package/src/pages/account/NotificationPreferencesPage.tsx +138 -0
- package/src/pages/account/ProfileSettingsPage.tsx +189 -0
- package/src/pages/account/SecuritySettingsPage.tsx +214 -0
- package/src/pages/account/TokensPage.tsx +211 -0
- package/src/pages/account/__tests__/NotificationPreferencesPage.test.tsx +150 -0
- package/src/pages/account/__tests__/ProfileSettingsPage.test.tsx +173 -0
- package/src/pages/account/__tests__/SecuritySettingsPage.test.tsx +212 -0
- package/src/pages/account/__tests__/TokensPage.test.tsx +180 -0
- package/src/pages/admin/AdminSettingsPage.tsx +564 -0
- package/src/pages/admin/AdminShell.tsx +199 -0
- package/src/pages/admin/AuditPage.tsx +338 -0
- package/src/pages/admin/OrdersPage.tsx +642 -0
- package/src/pages/admin/OverviewPage.tsx +559 -0
- package/src/pages/admin/SSOPage.tsx +166 -0
- package/src/pages/admin/UserDetailPage.tsx +641 -0
- package/src/pages/admin/UsersPage.tsx +462 -0
- package/src/pages/admin/WebhookDeliveriesPage.tsx +318 -0
- package/src/pages/admin/WorkspaceDetailPage.tsx +551 -0
- package/src/pages/admin/WorkspacesPage.tsx +299 -0
- package/src/pages/admin/__tests__/AdminSettingsPage.test.tsx +260 -0
- package/src/pages/admin/__tests__/OrdersPageMarkPaid.test.tsx +207 -0
- package/src/pages/admin/__tests__/OverviewPageActivity.test.tsx +213 -0
- package/src/pages/admin/__tests__/SSOPage.test.tsx +128 -0
- package/src/pages/admin/__tests__/UsersPageActions.test.tsx +188 -0
- package/src/pages/admin/__tests__/WorkspaceDetailPageTransfer.test.tsx +170 -0
- package/src/pages/admin/__tests__/WorkspacesPagePlans.test.tsx +138 -0
- package/src/pages/admin/shared.ts +42 -0
- package/src/pages/auth/ForgotPasswordPage.tsx +83 -0
- package/src/pages/auth/InviteAcceptPage.tsx +105 -0
- package/src/pages/auth/RegisterPage.tsx +204 -0
- package/src/pages/auth/ResetPasswordPage.tsx +150 -0
- package/src/pages/auth/VerifyEmailPage.tsx +76 -0
- package/src/pages/auth/__tests__/ForgotPasswordPage.test.tsx +67 -0
- package/src/pages/auth/__tests__/InviteAcceptPage.test.tsx +86 -0
- package/src/pages/auth/__tests__/ResetPasswordPage.test.tsx +115 -0
- package/src/pages/auth/__tests__/VerifyEmailPage.test.tsx +74 -0
- package/src/pages/workspace/BillingPage.tsx +361 -0
- package/src/pages/workspace/BillingSuccessPage.tsx +115 -0
- package/src/pages/workspace/MembersPage.tsx +568 -0
- package/src/pages/workspace/RolePermissionsPage.tsx +202 -0
- package/src/pages/workspace/SchedulesPage.tsx +387 -0
- package/src/pages/workspace/UsagePage.tsx +207 -0
- package/src/pages/workspace/WebhooksPage.tsx +506 -0
- package/src/pages/workspace/WorkspaceAuditPage.tsx +229 -0
- package/src/pages/workspace/WorkspaceGeneralPage.tsx +184 -0
- package/src/pages/workspace/__tests__/BillingPage.test.tsx +302 -0
- package/src/pages/workspace/__tests__/BillingSuccessPage.test.tsx +134 -0
- package/src/pages/workspace/__tests__/MembersPage.test.tsx +347 -0
- package/src/pages/workspace/__tests__/RolePermissionsPage.test.tsx +138 -0
- package/src/pages/workspace/__tests__/SchedulesPage.test.tsx +239 -0
- package/src/pages/workspace/__tests__/UsagePage.test.tsx +223 -0
- package/src/pages/workspace/__tests__/WebhooksPage.test.tsx +309 -0
- package/src/pages/workspace/__tests__/WorkspaceAuditPage.test.tsx +112 -0
- package/src/pages/workspace/__tests__/WorkspaceGeneralPage.test.tsx +164 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useSearchParams } from 'react-router';
|
|
4
|
+
import { RefreshCw } from 'lucide-react';
|
|
5
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
6
|
+
import { DataTable, type Column } from '../../components/DataTable';
|
|
7
|
+
import { PageEmpty, PageError, PageHeader } from '../../components/Page';
|
|
8
|
+
import { toast } from '../../components/toast';
|
|
9
|
+
import { Badge } from '../../components/ui/badge'
|
|
10
|
+
import { StatusBadge } from '../../components/StatusBadge';
|
|
11
|
+
import { Button } from '../../components/ui/button';
|
|
12
|
+
import {
|
|
13
|
+
Select,
|
|
14
|
+
SelectContent,
|
|
15
|
+
SelectItem,
|
|
16
|
+
SelectTrigger,
|
|
17
|
+
SelectValue,
|
|
18
|
+
} from '../../components/ui/select';
|
|
19
|
+
import { useApi } from '@ploykit/hooks';
|
|
20
|
+
import { formatDateTime, shortID, statusLabel } from '../../lib/utils';
|
|
21
|
+
import {
|
|
22
|
+
ADMIN_PAGE_SIZE,
|
|
23
|
+
adminError,
|
|
24
|
+
adminListQuery,
|
|
25
|
+
type AdminListEnvelope,
|
|
26
|
+
} from './shared';
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
interface AdminWebhookDeliveryRow {
|
|
30
|
+
id: string;
|
|
31
|
+
workspace_id: string;
|
|
32
|
+
url: string;
|
|
33
|
+
subscription_id: string;
|
|
34
|
+
event_id: string;
|
|
35
|
+
event_type: string;
|
|
36
|
+
status: string;
|
|
37
|
+
attempts: number;
|
|
38
|
+
last_status_code?: number;
|
|
39
|
+
last_error?: string;
|
|
40
|
+
delivered_at?: string;
|
|
41
|
+
created_at: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const DELIVERY_STATUSES = ['pending', 'delivered', 'dead'];
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const LIST_REFETCH_MS = 30_000;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const COUNT_STALE_MS = 60_000;
|
|
52
|
+
|
|
53
|
+
export function WebhookDeliveriesPage() {
|
|
54
|
+
const api = useApi();
|
|
55
|
+
const qc = useQueryClient();
|
|
56
|
+
|
|
57
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
58
|
+
const statusParam = searchParams.get('status') ?? '';
|
|
59
|
+
const status = DELIVERY_STATUSES.includes(statusParam) ? statusParam : '';
|
|
60
|
+
const page = Math.max(
|
|
61
|
+
1,
|
|
62
|
+
Number.parseInt(searchParams.get('page') ?? '1', 10) || 1,
|
|
63
|
+
);
|
|
64
|
+
const setFilter = (nextStatus: string, nextPage = 1) => {
|
|
65
|
+
const p = new URLSearchParams(searchParams);
|
|
66
|
+
if (nextStatus) p.set('status', nextStatus);
|
|
67
|
+
else p.delete('status');
|
|
68
|
+
if (nextPage > 1) p.set('page', String(nextPage));
|
|
69
|
+
else p.delete('page');
|
|
70
|
+
setSearchParams(p, { replace: true });
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const listQ = useQuery({
|
|
74
|
+
queryKey: ['admin', 'webhook-deliveries', page, status],
|
|
75
|
+
queryFn: () =>
|
|
76
|
+
api.get<AdminListEnvelope<AdminWebhookDeliveryRow>>(
|
|
77
|
+
`/api/admin/webhook-deliveries${adminListQuery(page, ADMIN_PAGE_SIZE, { status })}`,
|
|
78
|
+
),
|
|
79
|
+
|
|
80
|
+
refetchInterval: LIST_REFETCH_MS,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
const countQuery = (s: string) => ({
|
|
86
|
+
queryKey: ['admin', 'webhook-deliveries-count', s],
|
|
87
|
+
queryFn: () =>
|
|
88
|
+
api.get<AdminListEnvelope<AdminWebhookDeliveryRow>>(
|
|
89
|
+
`/api/admin/webhook-deliveries${adminListQuery(1, 1, { status: s })}`,
|
|
90
|
+
),
|
|
91
|
+
staleTime: COUNT_STALE_MS,
|
|
92
|
+
});
|
|
93
|
+
const pendingCountQ = useQuery(countQuery('pending'));
|
|
94
|
+
const deliveredCountQ = useQuery(countQuery('delivered'));
|
|
95
|
+
const deadCountQ = useQuery(countQuery('dead'));
|
|
96
|
+
const statusCounts: Record<string, number | undefined> = {
|
|
97
|
+
pending: pendingCountQ.data?.total,
|
|
98
|
+
delivered: deliveredCountQ.data?.total,
|
|
99
|
+
dead: deadCountQ.data?.total,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
const redeliverM = useMutation({
|
|
104
|
+
mutationFn: (d: AdminWebhookDeliveryRow) =>
|
|
105
|
+
api.post<AdminWebhookDeliveryRow>(
|
|
106
|
+
`/api/admin/webhook-deliveries/${d.id}/redeliver`,
|
|
107
|
+
),
|
|
108
|
+
onSuccess: (d2, d) => {
|
|
109
|
+
|
|
110
|
+
toast.success(`已重新入队(新投递 ${shortID(d2?.id ?? '')},溯源 ${d.event_id}.r)`);
|
|
111
|
+
void qc.invalidateQueries({ queryKey: ['admin', 'webhook-deliveries'] });
|
|
112
|
+
},
|
|
113
|
+
onError: (e) => toast.error(adminError(e, '重投失败')),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const items = listQ.data?.items ?? [];
|
|
117
|
+
const total = listQ.data?.total ?? 0;
|
|
118
|
+
const pastEnd = !listQ.isPending && items.length === 0 && page > 1;
|
|
119
|
+
|
|
120
|
+
const columns: Column<AdminWebhookDeliveryRow>[] = [
|
|
121
|
+
{
|
|
122
|
+
key: 'workspace_id',
|
|
123
|
+
header: '工作区',
|
|
124
|
+
className: 'w-24',
|
|
125
|
+
render: (d) =>
|
|
126
|
+
d.workspace_id ? (
|
|
127
|
+
<span className="font-mono text-xs" title={d.workspace_id}>
|
|
128
|
+
{shortID(d.workspace_id)}
|
|
129
|
+
</span>
|
|
130
|
+
) : (
|
|
131
|
+
<Badge variant="outline" className="text-muted-foreground">
|
|
132
|
+
孤儿
|
|
133
|
+
</Badge>
|
|
134
|
+
),
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
key: 'url',
|
|
138
|
+
header: '目标 URL',
|
|
139
|
+
render: (d) =>
|
|
140
|
+
d.url ? (
|
|
141
|
+
<p className="max-w-[22rem] truncate font-mono text-xs" title={d.url}>
|
|
142
|
+
{d.url}
|
|
143
|
+
</p>
|
|
144
|
+
) : (
|
|
145
|
+
<span className="text-xs text-muted-foreground">(订阅已删除)</span>
|
|
146
|
+
),
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
|
|
150
|
+
key: 'event_id',
|
|
151
|
+
header: '事件 ID',
|
|
152
|
+
className: 'w-32',
|
|
153
|
+
render: (d) => (
|
|
154
|
+
<code
|
|
155
|
+
className="block max-w-[8rem] truncate rounded bg-muted px-1.5 py-0.5 font-mono text-xs"
|
|
156
|
+
title={d.event_id}
|
|
157
|
+
>
|
|
158
|
+
{d.event_id}
|
|
159
|
+
</code>
|
|
160
|
+
),
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
key: 'event_type',
|
|
164
|
+
header: '事件',
|
|
165
|
+
className: 'w-40',
|
|
166
|
+
render: (d) => (
|
|
167
|
+
<code
|
|
168
|
+
className="block max-w-[10rem] truncate rounded bg-muted px-1.5 py-0.5 font-mono text-xs"
|
|
169
|
+
title={d.event_type}
|
|
170
|
+
>
|
|
171
|
+
{d.event_type}
|
|
172
|
+
</code>
|
|
173
|
+
),
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
key: 'status',
|
|
177
|
+
header: '状态',
|
|
178
|
+
className: 'w-24',
|
|
179
|
+
render: (d) => <StatusBadge status={d.status} />,
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
key: 'attempts',
|
|
183
|
+
header: '尝试',
|
|
184
|
+
className: 'w-16 text-right',
|
|
185
|
+
render: (d) => <span className="tabular-nums">{d.attempts}</span>,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
key: 'last_status',
|
|
189
|
+
header: '最近响应',
|
|
190
|
+
className: 'w-32',
|
|
191
|
+
render: (d) =>
|
|
192
|
+
d.last_status_code ? (
|
|
193
|
+
<span className="font-mono text-xs" title={d.last_error ?? undefined}>
|
|
194
|
+
{d.last_status_code}
|
|
195
|
+
</span>
|
|
196
|
+
) : d.last_error ? (
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
<span
|
|
200
|
+
className="block max-w-[12rem] truncate text-xs text-destructive"
|
|
201
|
+
title={d.last_error}
|
|
202
|
+
>
|
|
203
|
+
{d.last_error}
|
|
204
|
+
</span>
|
|
205
|
+
) : (
|
|
206
|
+
<span className="text-xs text-muted-foreground">—</span>
|
|
207
|
+
),
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
key: 'created_at',
|
|
211
|
+
header: '时间',
|
|
212
|
+
className: 'w-44',
|
|
213
|
+
render: (d) => (
|
|
214
|
+
<span className="whitespace-nowrap text-muted-foreground">
|
|
215
|
+
{formatDateTime(d.created_at)}
|
|
216
|
+
</span>
|
|
217
|
+
),
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
key: 'actions',
|
|
221
|
+
header: '操作',
|
|
222
|
+
className: 'w-20',
|
|
223
|
+
render: (d) => (
|
|
224
|
+
<Button
|
|
225
|
+
variant="outline"
|
|
226
|
+
size="sm"
|
|
227
|
+
disabled={redeliverM.isPending}
|
|
228
|
+
onClick={() => redeliverM.mutate(d)}
|
|
229
|
+
>
|
|
230
|
+
重投
|
|
231
|
+
</Button>
|
|
232
|
+
),
|
|
233
|
+
},
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
return (
|
|
237
|
+
<div>
|
|
238
|
+
<PageHeader
|
|
239
|
+
title="Webhooks"
|
|
240
|
+
|
|
241
|
+
description="所有工作区的 Webhook 投递与重试记录,按时间倒序"
|
|
242
|
+
/>
|
|
243
|
+
|
|
244
|
+
<div className="mb-4 flex flex-wrap items-center gap-2">
|
|
245
|
+
<Select
|
|
246
|
+
value={status || 'all'}
|
|
247
|
+
onValueChange={(v) => {
|
|
248
|
+
|
|
249
|
+
setFilter(typeof v === 'string' && v !== 'all' ? v : '', 1);
|
|
250
|
+
}}
|
|
251
|
+
>
|
|
252
|
+
<SelectTrigger size="sm" className="w-44" aria-label="按投递状态过滤">
|
|
253
|
+
<SelectValue>
|
|
254
|
+
{status ? statusLabel(status) : '全部状态'}
|
|
255
|
+
</SelectValue>
|
|
256
|
+
</SelectTrigger>
|
|
257
|
+
<SelectContent align="start">
|
|
258
|
+
<SelectItem value="all">全部状态</SelectItem>
|
|
259
|
+
{DELIVERY_STATUSES.map((s) => (
|
|
260
|
+
<SelectItem key={s} value={s}>
|
|
261
|
+
{/* B-webhook-7:选项内联计数(dead (7))给积压规模语境 */}
|
|
262
|
+
{statusLabel(s)}
|
|
263
|
+
{typeof statusCounts[s] === 'number' ? ` (${statusCounts[s]})` : ''}
|
|
264
|
+
</SelectItem>
|
|
265
|
+
))}
|
|
266
|
+
</SelectContent>
|
|
267
|
+
</Select>
|
|
268
|
+
{/* B-webhook-2:手动刷新出口(观测页等待无需 F5) */}
|
|
269
|
+
<Button
|
|
270
|
+
variant="outline"
|
|
271
|
+
size="sm"
|
|
272
|
+
disabled={listQ.isFetching}
|
|
273
|
+
onClick={() => void listQ.refetch()}
|
|
274
|
+
>
|
|
275
|
+
<RefreshCw size={14} aria-hidden="true" />
|
|
276
|
+
{listQ.isFetching ? '刷新中…' : '刷新'}
|
|
277
|
+
</Button>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
{listQ.isError ? (
|
|
281
|
+
<PageError
|
|
282
|
+
message={adminError(listQ.error, '投递列表加载失败')}
|
|
283
|
+
onRetry={() => void listQ.refetch()}
|
|
284
|
+
/>
|
|
285
|
+
) : (
|
|
286
|
+
<DataTable
|
|
287
|
+
columns={columns}
|
|
288
|
+
rows={items}
|
|
289
|
+
rowKey={(d) => d.id}
|
|
290
|
+
loading={listQ.isPending}
|
|
291
|
+
pagination={{
|
|
292
|
+
page,
|
|
293
|
+
pageSize: ADMIN_PAGE_SIZE,
|
|
294
|
+
total,
|
|
295
|
+
onPageChange: (p) => setFilter(status, p),
|
|
296
|
+
}}
|
|
297
|
+
empty={
|
|
298
|
+
pastEnd ? (
|
|
299
|
+
<div className="flex flex-col items-center gap-2">
|
|
300
|
+
<PageEmpty label="没有更多投递了" hint="当前页数据可能已被删除" />
|
|
301
|
+
<Button variant="outline" size="sm" onClick={() => setFilter(status, 1)}>
|
|
302
|
+
返回第一页
|
|
303
|
+
</Button>
|
|
304
|
+
</div>
|
|
305
|
+
) : status ? (
|
|
306
|
+
<PageEmpty label="没有该状态的投递" hint="换个状态或清除过滤" />
|
|
307
|
+
) : (
|
|
308
|
+
<PageEmpty
|
|
309
|
+
label="暂无投递记录"
|
|
310
|
+
hint="工作区触发事件后,订阅投递会在此出现"
|
|
311
|
+
/>
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
/>
|
|
315
|
+
)}
|
|
316
|
+
</div>
|
|
317
|
+
);
|
|
318
|
+
}
|