@allbluecn/admin-app 0.1.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.
Files changed (276) hide show
  1. package/package.json +86 -0
  2. package/src/client.tsx +31 -0
  3. package/src/components/admin/admin-user-menu.tsx +90 -0
  4. package/src/components/admin/developer-log.tsx +356 -0
  5. package/src/components/ai-provider/model-list-editor.tsx +147 -0
  6. package/src/components/ai-provider/provider-form.tsx +434 -0
  7. package/src/components/ai-provider/provider-icon.tsx +43 -0
  8. package/src/components/ai-provider/provider-logo.tsx +87 -0
  9. package/src/components/ai-provider/provider-table.tsx +258 -0
  10. package/src/components/auth/admin-login-form.tsx +214 -0
  11. package/src/components/auth/auth-brand-panel.tsx +60 -0
  12. package/src/components/auth/auth-header.tsx +38 -0
  13. package/src/components/auth/auth-layout.tsx +66 -0
  14. package/src/components/auth/auth-providers.tsx +34 -0
  15. package/src/components/auth/icon-input.tsx +46 -0
  16. package/src/components/auth/oauth-section.tsx +51 -0
  17. package/src/components/auth/password-input.tsx +67 -0
  18. package/src/components/common/page-header.tsx +42 -0
  19. package/src/components/common/placeholder-page.tsx +42 -0
  20. package/src/components/component/component-form-dialog.tsx +348 -0
  21. package/src/components/component/component-import-dialog.tsx +235 -0
  22. package/src/components/component/component-table.tsx +153 -0
  23. package/src/components/data-table/data-table-pagination.tsx +114 -0
  24. package/src/components/data-table/data-table.tsx +218 -0
  25. package/src/components/data-table/table-detail-layout.tsx +99 -0
  26. package/src/components/dependency/changelog-dialog.tsx +108 -0
  27. package/src/components/dependency/columns.tsx +232 -0
  28. package/src/components/dependency/dependency-table.tsx +368 -0
  29. package/src/components/dependency/edit-dialog.tsx +200 -0
  30. package/src/components/knowledge-public/bookmark-form-dialog.tsx +215 -0
  31. package/src/components/knowledge-public/compliance-form-dialog.tsx +308 -0
  32. package/src/components/knowledge-public/legal-form-dialog.tsx +315 -0
  33. package/src/components/layout/sidebar-02/app-sidebar.tsx +160 -0
  34. package/src/components/layout/sidebar-02/index.tsx +33 -0
  35. package/src/components/layout/sidebar-02/logo.tsx +40 -0
  36. package/src/components/layout/sidebar-02/nav-main.tsx +153 -0
  37. package/src/components/layout/sidebar-02/nav-notifications.tsx +78 -0
  38. package/src/components/layout/sidebar-02/team-switcher.tsx +106 -0
  39. package/src/components/magicui/animated-theme-toggler.tsx +272 -0
  40. package/src/components/magicui/rainbow-button.tsx +78 -0
  41. package/src/components/market/columns.tsx +151 -0
  42. package/src/components/market/market-app-form.tsx +237 -0
  43. package/src/components/market/market-app-list.tsx +156 -0
  44. package/src/components/monitoring/error-list.tsx +143 -0
  45. package/src/components/monitoring/health-cards.tsx +152 -0
  46. package/src/components/monitoring/metrics-stats.tsx +184 -0
  47. package/src/components/monitoring/request-log-table.tsx +179 -0
  48. package/src/components/providers/theme-toggle.tsx +59 -0
  49. package/src/components/settings/avatar/avatar-config.ts +46 -0
  50. package/src/components/ui/alert-dialog.tsx +216 -0
  51. package/src/components/ui/alert.tsx +76 -0
  52. package/src/components/ui/avatar.tsx +129 -0
  53. package/src/components/ui/badge.tsx +66 -0
  54. package/src/components/ui/button.tsx +84 -0
  55. package/src/components/ui/card.tsx +120 -0
  56. package/src/components/ui/checkbox.tsx +50 -0
  57. package/src/components/ui/collapsible.tsx +50 -0
  58. package/src/components/ui/dialog.tsx +185 -0
  59. package/src/components/ui/dropdown-menu.tsx +286 -0
  60. package/src/components/ui/field.tsx +255 -0
  61. package/src/components/ui/input-group.tsx +171 -0
  62. package/src/components/ui/input.tsx +36 -0
  63. package/src/components/ui/label.tsx +41 -0
  64. package/src/components/ui/pagination.tsx +146 -0
  65. package/src/components/ui/select.tsx +209 -0
  66. package/src/components/ui/separator.tsx +45 -0
  67. package/src/components/ui/sheet.tsx +164 -0
  68. package/src/components/ui/sidebar.tsx +719 -0
  69. package/src/components/ui/skeleton.tsx +30 -0
  70. package/src/components/ui/sonner.tsx +37 -0
  71. package/src/components/ui/switch.tsx +48 -0
  72. package/src/components/ui/table.tsx +133 -0
  73. package/src/components/ui/textarea.tsx +35 -0
  74. package/src/components/ui/tooltip.tsx +74 -0
  75. package/src/components/user/columns.tsx +153 -0
  76. package/src/components/user/settings-activity-log.tsx +358 -0
  77. package/src/components/user/settings-profile/constants.ts +42 -0
  78. package/src/components/user/settings-profile/types.ts +47 -0
  79. package/src/components/user/settings-profile.tsx +664 -0
  80. package/src/components/user/user-create-dialog.tsx +137 -0
  81. package/src/components/user/user-filters.tsx +117 -0
  82. package/src/hooks/use-mobile.ts +36 -0
  83. package/src/instrument.client.ts +34 -0
  84. package/src/lib/anyhub/capabilities.ts +59 -0
  85. package/src/lib/anyhub/types.ts +43 -0
  86. package/src/lib/auth-client.ts +83 -0
  87. package/src/lib/auth-utils.ts +24 -0
  88. package/src/lib/auth.config.ts +264 -0
  89. package/src/lib/avatar.ts +41 -0
  90. package/src/lib/i18n/client.ts +32 -0
  91. package/src/lib/i18n/config.ts +40 -0
  92. package/src/lib/i18n/detect.ts +43 -0
  93. package/src/lib/i18n/locales/en/admin-ai.json +128 -0
  94. package/src/lib/i18n/locales/en/admin-billing.json +56 -0
  95. package/src/lib/i18n/locales/en/admin-users.json +88 -0
  96. package/src/lib/i18n/locales/en/common.json +877 -0
  97. package/src/lib/i18n/locales/en/enterprise.json +208 -0
  98. package/src/lib/i18n/locales/zh/admin-ai.json +128 -0
  99. package/src/lib/i18n/locales/zh/admin-billing.json +56 -0
  100. package/src/lib/i18n/locales/zh/admin-users.json +88 -0
  101. package/src/lib/i18n/locales/zh/common.json +877 -0
  102. package/src/lib/i18n/locales/zh/enterprise.json +208 -0
  103. package/src/lib/i18n/server.ts +18 -0
  104. package/src/lib/i18n/types.ts +5 -0
  105. package/src/lib/monitoring-benchmarks.ts +85 -0
  106. package/src/lib/monitoring-descriptions.ts +78 -0
  107. package/src/lib/prisma.ts +18 -0
  108. package/src/lib/router-context.ts +38 -0
  109. package/src/lib/session.ts +38 -0
  110. package/src/lib/utils.ts +23 -0
  111. package/src/providers/index.tsx +45 -0
  112. package/src/routeTree.gen.ts +1199 -0
  113. package/src/router.tsx +51 -0
  114. package/src/routes/__root.tsx +170 -0
  115. package/src/routes/_nav/ai-providers/$id/edit/route.lazy.tsx +74 -0
  116. package/src/routes/_nav/ai-providers/$id/edit/route.tsx +35 -0
  117. package/src/routes/_nav/ai-providers/index/route.lazy.tsx +33 -0
  118. package/src/routes/_nav/ai-providers/new/route.lazy.tsx +31 -0
  119. package/src/routes/_nav/ai-providers/new/route.tsx +20 -0
  120. package/src/routes/_nav/ai-providers/route.lazy.tsx +26 -0
  121. package/src/routes/_nav/ai-providers/route.tsx +31 -0
  122. package/src/routes/_nav/apps/route.lazy.tsx +30 -0
  123. package/src/routes/_nav/apps/route.tsx +20 -0
  124. package/src/routes/_nav/audit/route.lazy.tsx +100 -0
  125. package/src/routes/_nav/audit/route.tsx +25 -0
  126. package/src/routes/_nav/billing/invoices/route.lazy.tsx +86 -0
  127. package/src/routes/_nav/billing/invoices/route.tsx +25 -0
  128. package/src/routes/_nav/billing/route.lazy.tsx +48 -0
  129. package/src/routes/_nav/billing/route.tsx +27 -0
  130. package/src/routes/_nav/billing/subscriptions/$subscriptionId/route.lazy.tsx +160 -0
  131. package/src/routes/_nav/billing/subscriptions/$subscriptionId/route.tsx +25 -0
  132. package/src/routes/_nav/billing/subscriptions/route.lazy.tsx +113 -0
  133. package/src/routes/_nav/billing/subscriptions/route.tsx +28 -0
  134. package/src/routes/_nav/compliance/route.lazy.tsx +184 -0
  135. package/src/routes/_nav/compliance/route.tsx +25 -0
  136. package/src/routes/_nav/components/route.lazy.tsx +184 -0
  137. package/src/routes/_nav/components/route.tsx +40 -0
  138. package/src/routes/_nav/dashboard/route.lazy.tsx +33 -0
  139. package/src/routes/_nav/dashboard/route.tsx +20 -0
  140. package/src/routes/_nav/dependencies/route.lazy.tsx +66 -0
  141. package/src/routes/_nav/dependencies/route.tsx +32 -0
  142. package/src/routes/_nav/developer-logs/route.lazy.tsx +6 -0
  143. package/src/routes/_nav/developer-logs/route.tsx +14 -0
  144. package/src/routes/_nav/docs/route.lazy.tsx +30 -0
  145. package/src/routes/_nav/docs/route.tsx +20 -0
  146. package/src/routes/_nav/knowledge-public/bookmarks/route.lazy.tsx +355 -0
  147. package/src/routes/_nav/knowledge-public/bookmarks/route.tsx +40 -0
  148. package/src/routes/_nav/knowledge-public/compliance/route.lazy.tsx +245 -0
  149. package/src/routes/_nav/knowledge-public/compliance/route.tsx +40 -0
  150. package/src/routes/_nav/knowledge-public/legal/route.lazy.tsx +242 -0
  151. package/src/routes/_nav/knowledge-public/legal/route.tsx +40 -0
  152. package/src/routes/_nav/licenses/$licenseId/route.lazy.tsx +235 -0
  153. package/src/routes/_nav/licenses/$licenseId/route.tsx +25 -0
  154. package/src/routes/_nav/licenses/new/route.lazy.tsx +237 -0
  155. package/src/routes/_nav/licenses/route.lazy.tsx +143 -0
  156. package/src/routes/_nav/licenses/route.tsx +25 -0
  157. package/src/routes/_nav/market/route.lazy.tsx +31 -0
  158. package/src/routes/_nav/market/route.tsx +20 -0
  159. package/src/routes/_nav/monitoring/ai-usage/route.lazy.tsx +305 -0
  160. package/src/routes/_nav/monitoring/ai-usage/route.tsx +3 -0
  161. package/src/routes/_nav/monitoring/errors/route.lazy.tsx +111 -0
  162. package/src/routes/_nav/monitoring/health/route.lazy.tsx +260 -0
  163. package/src/routes/_nav/monitoring/logs/route.lazy.tsx +165 -0
  164. package/src/routes/_nav/monitoring/metrics/route.lazy.tsx +240 -0
  165. package/src/routes/_nav/monitoring/overview/route.lazy.tsx +138 -0
  166. package/src/routes/_nav/monitoring/route.lazy.tsx +68 -0
  167. package/src/routes/_nav/monitoring/route.tsx +20 -0
  168. package/src/routes/_nav/monitoring/sentry/route.lazy.tsx +399 -0
  169. package/src/routes/_nav/monitoring/sentry/route.tsx +20 -0
  170. package/src/routes/_nav/permissions/route.lazy.tsx +504 -0
  171. package/src/routes/_nav/permissions/route.tsx +26 -0
  172. package/src/routes/_nav/route.lazy.tsx +31 -0
  173. package/src/routes/_nav/route.tsx +34 -0
  174. package/src/routes/_nav/settings/route.lazy.tsx +30 -0
  175. package/src/routes/_nav/settings/route.tsx +20 -0
  176. package/src/routes/_nav/sso/route.lazy.tsx +145 -0
  177. package/src/routes/_nav/sso/route.tsx +25 -0
  178. package/src/routes/_nav/users/$userId/route.lazy.tsx +432 -0
  179. package/src/routes/_nav/users/$userId/route.tsx +27 -0
  180. package/src/routes/_nav/users/-components/users-table.tsx +38 -0
  181. package/src/routes/_nav/users/route.lazy.tsx +74 -0
  182. package/src/routes/_nav/users/route.tsx +43 -0
  183. package/src/routes/api/compliance-download/$jobId.ts +35 -0
  184. package/src/routes/api/observability/errors.ts +41 -0
  185. package/src/routes/api/observability/health.ts +30 -0
  186. package/src/routes/api.auth.$.ts +31 -0
  187. package/src/routes/api.sentry-test.ts +33 -0
  188. package/src/routes/index/route.lazy.tsx +22 -0
  189. package/src/routes/index/route.tsx +24 -0
  190. package/src/routes/login/route.lazy.tsx +46 -0
  191. package/src/routes/login/route.tsx +28 -0
  192. package/src/routes/sentry-tunnel.ts +61 -0
  193. package/src/routes/setup/route.lazy.tsx +94 -0
  194. package/src/routes/setup/route.tsx +28 -0
  195. package/src/server/__tests__/admin-ai-alerts.test.ts +113 -0
  196. package/src/server/__tests__/licenses-issue.test.ts +98 -0
  197. package/src/server/admin-ai-alerts.ts +177 -0
  198. package/src/server/admin-ai-usage.ts +134 -0
  199. package/src/server/auth-helpers.ts +51 -0
  200. package/src/server/entitlements.ts +24 -0
  201. package/src/server/knowledge-public/canonical-id.ts +55 -0
  202. package/src/server/knowledge-public/github-sync.ts +86 -0
  203. package/src/server/license-issue.ts +78 -0
  204. package/src/server/middlewares/request.ts +26 -0
  205. package/src/server/observability/debug-middleware.ts +39 -0
  206. package/src/server/observability/error-reporter.ts +99 -0
  207. package/src/server/observability/health-check.ts +140 -0
  208. package/src/server/observability/index.ts +33 -0
  209. package/src/server/observability/logger.ts +49 -0
  210. package/src/server/observability/metrics.ts +105 -0
  211. package/src/server/observability/request-middleware.ts +125 -0
  212. package/src/server/observability/timing.ts +42 -0
  213. package/src/server/pro-services.ts +32 -0
  214. package/src/server/serverFns/admin-billing.ts +94 -0
  215. package/src/server/serverFns/ai-provider/create.ts +92 -0
  216. package/src/server/serverFns/ai-provider/delete.ts +42 -0
  217. package/src/server/serverFns/ai-provider/get.ts +35 -0
  218. package/src/server/serverFns/ai-provider/list.ts +92 -0
  219. package/src/server/serverFns/ai-provider/update.ts +73 -0
  220. package/src/server/serverFns/anyhub/market.ts +64 -0
  221. package/src/server/serverFns/audit.ts +57 -0
  222. package/src/server/serverFns/auth/session.ts +26 -0
  223. package/src/server/serverFns/auth/setup.ts +73 -0
  224. package/src/server/serverFns/compliance.ts +85 -0
  225. package/src/server/serverFns/components/import.ts +197 -0
  226. package/src/server/serverFns/components/list.ts +51 -0
  227. package/src/server/serverFns/components/mutations.ts +84 -0
  228. package/src/server/serverFns/dependency/helpers.ts +245 -0
  229. package/src/server/serverFns/dependency/list.ts +127 -0
  230. package/src/server/serverFns/dependency/sync.ts +123 -0
  231. package/src/server/serverFns/dependency/update.ts +51 -0
  232. package/src/server/serverFns/developer-log-auto-generate.ts +176 -0
  233. package/src/server/serverFns/developer-logs.ts +132 -0
  234. package/src/server/serverFns/knowledge-public/bookmarks/create.ts +53 -0
  235. package/src/server/serverFns/knowledge-public/bookmarks/delete.ts +31 -0
  236. package/src/server/serverFns/knowledge-public/bookmarks/detail.ts +32 -0
  237. package/src/server/serverFns/knowledge-public/bookmarks/list.ts +66 -0
  238. package/src/server/serverFns/knowledge-public/bookmarks/sync-all-github.ts +56 -0
  239. package/src/server/serverFns/knowledge-public/bookmarks/update.ts +50 -0
  240. package/src/server/serverFns/knowledge-public/compliance/create.ts +58 -0
  241. package/src/server/serverFns/knowledge-public/compliance/delete.ts +31 -0
  242. package/src/server/serverFns/knowledge-public/compliance/detail.ts +32 -0
  243. package/src/server/serverFns/knowledge-public/compliance/list.ts +59 -0
  244. package/src/server/serverFns/knowledge-public/compliance/update.ts +53 -0
  245. package/src/server/serverFns/knowledge-public/legal/create.ts +62 -0
  246. package/src/server/serverFns/knowledge-public/legal/delete.ts +31 -0
  247. package/src/server/serverFns/knowledge-public/legal/detail.ts +32 -0
  248. package/src/server/serverFns/knowledge-public/legal/list.ts +60 -0
  249. package/src/server/serverFns/knowledge-public/legal/update.ts +55 -0
  250. package/src/server/serverFns/licenses.ts +92 -0
  251. package/src/server/serverFns/locale.ts +10 -0
  252. package/src/server/serverFns/monitoring/check-ai-alerts.ts +13 -0
  253. package/src/server/serverFns/monitoring/get-ai-usage-overview.ts +25 -0
  254. package/src/server/serverFns/monitoring/get-errors.ts +43 -0
  255. package/src/server/serverFns/monitoring/get-health-settings.ts +35 -0
  256. package/src/server/serverFns/monitoring/get-health.ts +55 -0
  257. package/src/server/serverFns/monitoring/get-metrics.ts +46 -0
  258. package/src/server/serverFns/monitoring/get-request-logs.ts +66 -0
  259. package/src/server/serverFns/monitoring/report-error.ts +55 -0
  260. package/src/server/serverFns/monitoring/reset.ts +70 -0
  261. package/src/server/serverFns/permissions.ts +214 -0
  262. package/src/server/serverFns/sentry/config.ts +88 -0
  263. package/src/server/serverFns/sso-config.ts +83 -0
  264. package/src/server/serverFns/user/create.ts +40 -0
  265. package/src/server/serverFns/user/delete.ts +29 -0
  266. package/src/server/serverFns/user/detail.ts +45 -0
  267. package/src/server/serverFns/user/list.ts +56 -0
  268. package/src/server/serverFns/user/reset-password.ts +28 -0
  269. package/src/server/serverFns/user/update-role.ts +26 -0
  270. package/src/server/serverFns/user/update-status.ts +26 -0
  271. package/src/server.ts +27 -0
  272. package/src/start.ts +85 -0
  273. package/src/styles/_keyframe-animations.scss +91 -0
  274. package/src/styles/_variables.scss +296 -0
  275. package/src/styles/globals.css +200 -0
  276. package/src/types/start-authjs.d.ts +27 -0
@@ -0,0 +1,153 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import { Edit, Trash2 } from 'lucide-react'
19
+ import { useTranslation } from 'react-i18next'
20
+ import { Badge } from '@/components/ui/badge'
21
+ import { Button } from '@/components/ui/button'
22
+ import {
23
+ Table,
24
+ TableBody,
25
+ TableCell,
26
+ TableHead,
27
+ TableHeader,
28
+ TableRow,
29
+ } from '@/components/ui/table'
30
+ import { cn } from '@/lib/utils'
31
+
32
+ export interface ComponentItem {
33
+ id: string
34
+ name: string
35
+ description: string | null
36
+ type: string
37
+ category: string | null
38
+ subCategory: string | null
39
+ path: string | null
40
+ defaultWidth: number
41
+ defaultHeight: number
42
+ prototypeKey: string | null
43
+ config: unknown
44
+ source: string
45
+ sourceId: string | null
46
+ isHidden: boolean
47
+ sortOrder: number
48
+ version: number
49
+ tags: string[]
50
+ defaultProps: Record<string, unknown> | null
51
+ defaultStyle: Record<string, unknown> | null
52
+ createdAt: Date
53
+ updatedAt: Date
54
+ }
55
+
56
+ export function ComponentTable({
57
+ items,
58
+ onEdit,
59
+ onDelete,
60
+ }: {
61
+ items: ComponentItem[]
62
+ onEdit: (item: ComponentItem) => void
63
+ onDelete: (item: ComponentItem) => void
64
+ }) {
65
+ const { t } = useTranslation('common')
66
+ const categoryLabel = (k: string) => {
67
+ const map: Record<string, string> = { base: t('component.categories.base'), block: t('component.categories.block'), template: t('component.categories.template') }
68
+ return map[k] ?? k
69
+ }
70
+
71
+ if (items.length === 0) {
72
+ return (
73
+ <div className="flex h-40 items-center justify-center rounded-lg border border-dashed">
74
+ <p className="text-sm text-muted-foreground">{t('component.table.empty')}</p>
75
+ </div>
76
+ )
77
+ }
78
+
79
+ return (
80
+ <div className="rounded-lg border">
81
+ <Table>
82
+ <TableHeader>
83
+ <TableRow>
84
+ <TableHead className="w-[28%]">{t('component.table.columns.component')}</TableHead>
85
+ <TableHead>{t('component.table.columns.category')}</TableHead>
86
+ <TableHead>{t('component.table.columns.type')}</TableHead>
87
+ <TableHead>{t('component.table.columns.tags')}</TableHead>
88
+ <TableHead>{t('component.table.columns.source')}</TableHead>
89
+ <TableHead>{t('component.table.columns.status')}</TableHead>
90
+ <TableHead className="text-right">{t('component.table.columns.actions')}</TableHead>
91
+ </TableRow>
92
+ </TableHeader>
93
+ <TableBody>
94
+ {items.map((item) => {
95
+ return (
96
+ <TableRow key={item.id}>
97
+ <TableCell>
98
+ <div className="min-w-0 py-1">
99
+ <div className="truncate text-sm font-medium">{item.name}</div>
100
+ {item.description && (
101
+ <div className="truncate text-xs text-muted-foreground">{item.description}</div>
102
+ )}
103
+ </div>
104
+ </TableCell>
105
+ <TableCell>
106
+ <span className="text-sm">{categoryLabel(item.category ?? '') ?? item.category ?? '-'}</span>
107
+ </TableCell>
108
+ <TableCell>
109
+ <Badge variant="outline" className="font-mono text-[10px]">{item.type}</Badge>
110
+ </TableCell>
111
+ <TableCell>
112
+ <div className="flex flex-wrap gap-1">
113
+ {item.tags.length > 0 ? (
114
+ item.tags.map((tag) => (
115
+ <Badge key={tag} variant="secondary" className="text-[10px]">{tag}</Badge>
116
+ ))
117
+ ) : (
118
+ <span className="text-xs text-muted-foreground/50">-</span>
119
+ )}
120
+ </div>
121
+ </TableCell>
122
+ <TableCell>
123
+ <span className="text-xs text-muted-foreground">{item.source}</span>
124
+ </TableCell>
125
+ <TableCell>
126
+ <span className={cn('text-xs', item.isHidden ? 'text-muted-foreground' : 'text-foreground')}>
127
+ {item.isHidden ? t('component.table.status.hidden') : t('component.table.status.visible')}
128
+ </span>
129
+ </TableCell>
130
+ <TableCell className="text-right">
131
+ <div className="flex items-center justify-end gap-1">
132
+ <Button variant="ghost" size="icon-sm" onClick={() => onEdit(item)} aria-label={t('common.edit')}>
133
+ <Edit className="size-4" />
134
+ </Button>
135
+ <Button
136
+ variant="ghost"
137
+ size="icon-sm"
138
+ onClick={() => onDelete(item)}
139
+ className="text-destructive hover:bg-destructive/10"
140
+ aria-label={t('common.delete')}
141
+ >
142
+ <Trash2 className="size-4" />
143
+ </Button>
144
+ </div>
145
+ </TableCell>
146
+ </TableRow>
147
+ )
148
+ })}
149
+ </TableBody>
150
+ </Table>
151
+ </div>
152
+ )
153
+ }
@@ -0,0 +1,114 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import {
19
+ Pagination,
20
+ PaginationContent,
21
+ PaginationEllipsis,
22
+ PaginationItem,
23
+ PaginationLink,
24
+ PaginationNext,
25
+ PaginationPrevious,
26
+ } from "@/components/ui/pagination";
27
+ import { useTranslation } from 'react-i18next'
28
+
29
+ interface DataTablePaginationProps {
30
+ page: number;
31
+ totalPages: number;
32
+ total: number;
33
+ onPageChange: (page: number) => void;
34
+ }
35
+
36
+ function getPageNumbers(current: number, total: number): (number | "ellipsis")[] {
37
+ if (total <= 5) {
38
+ return Array.from({ length: total }, (_, i) => i + 1);
39
+ }
40
+
41
+ const pages: (number | "ellipsis")[] = [1];
42
+
43
+ if (current > 3) {
44
+ pages.push("ellipsis");
45
+ }
46
+
47
+ const start = Math.max(2, current - 1);
48
+ const end = Math.min(total - 1, current + 1);
49
+
50
+ for (let i = start; i <= end; i++) {
51
+ pages.push(i);
52
+ }
53
+
54
+ if (current < total - 2) {
55
+ pages.push("ellipsis");
56
+ }
57
+
58
+ pages.push(total);
59
+
60
+ return pages;
61
+ }
62
+
63
+ export function DataTablePagination({
64
+ page,
65
+ totalPages,
66
+ total,
67
+ onPageChange,
68
+ }: DataTablePaginationProps) {
69
+ const { t } = useTranslation('common')
70
+ const pages = getPageNumbers(page, totalPages);
71
+
72
+ return (
73
+ <div className="flex items-center justify-between gap-4 px-2 py-4">
74
+ <div className="text-sm text-muted-foreground whitespace-nowrap shrink-0">
75
+ {t('pagination.total', { total, page, totalPages })}
76
+ </div>
77
+ <Pagination className="justify-end">
78
+ <PaginationContent>
79
+ <PaginationItem>
80
+ <PaginationPrevious
81
+ text={t('pagination.prev')}
82
+ onClick={() => page > 1 && onPageChange(page - 1)}
83
+ className={page <= 1 ? "pointer-events-none opacity-50" : "cursor-pointer"}
84
+ />
85
+ </PaginationItem>
86
+ {pages.map((p, i) =>
87
+ p === "ellipsis" ? (
88
+ <PaginationItem key={`ellipsis-${i}`}>
89
+ <PaginationEllipsis />
90
+ </PaginationItem>
91
+ ) : (
92
+ <PaginationItem key={p}>
93
+ <PaginationLink
94
+ isActive={p === page}
95
+ onClick={() => onPageChange(p)}
96
+ className="cursor-pointer"
97
+ >
98
+ {p}
99
+ </PaginationLink>
100
+ </PaginationItem>
101
+ )
102
+ )}
103
+ <PaginationItem>
104
+ <PaginationNext
105
+ text={t('pagination.next')}
106
+ onClick={() => page < totalPages && onPageChange(page + 1)}
107
+ className={page >= totalPages ? "pointer-events-none opacity-50" : "cursor-pointer"}
108
+ />
109
+ </PaginationItem>
110
+ </PaginationContent>
111
+ </Pagination>
112
+ </div>
113
+ );
114
+ }
@@ -0,0 +1,218 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import type { CSSProperties } from 'react'
19
+ import { useRef } from 'react'
20
+ import {
21
+ type ColumnDef,
22
+ type RowData,
23
+ columnVisibilityFeature,
24
+ flexRender,
25
+ tableFeatures,
26
+ useTable,
27
+ } from '@tanstack/react-table'
28
+ import { useVirtualizer } from '@tanstack/react-virtual'
29
+ import {
30
+ Table,
31
+ TableBody,
32
+ TableCell,
33
+ TableHead,
34
+ TableHeader,
35
+ TableRow,
36
+ } from '@/components/ui/table'
37
+ import { VIRTUALIZE_THRESHOLD } from '@allbluecn/kernel'
38
+
39
+ export const dataTableFeatures = tableFeatures({
40
+ columnVisibilityFeature,
41
+ })
42
+
43
+ export type AdminColumnDef<
44
+ TData extends RowData,
45
+ TValue = unknown,
46
+ > = ColumnDef<typeof dataTableFeatures, TData, TValue> & {
47
+ meta?: { style?: CSSProperties }
48
+ }
49
+
50
+ export interface DataTableProps<TData extends RowData> {
51
+ columns: AdminColumnDef<TData>[];
52
+ data: TData[];
53
+ onRowClick?: (row: TData) => void;
54
+ actions?: React.ReactNode;
55
+ }
56
+
57
+ const ROW_HEIGHT = 48
58
+
59
+ function ColGroup({ columns }: { columns: AdminColumnDef<any>[] }) {
60
+ return (
61
+ <colgroup>
62
+ {columns.map((col, i) => {
63
+ const style = (col.meta as { style?: CSSProperties } | undefined)?.style
64
+ const width = style?.width
65
+ return width != null ? <col key={i} style={{ width }} /> : null
66
+ })}
67
+ </colgroup>
68
+ )
69
+ }
70
+
71
+ export function DataTable<TData extends RowData>({
72
+ columns,
73
+ data,
74
+ onRowClick,
75
+ actions,
76
+ }: DataTableProps<TData>) {
77
+ const table = useTable({
78
+ features: dataTableFeatures,
79
+ data,
80
+ columns,
81
+ });
82
+
83
+ const { rows } = table.getRowModel();
84
+ const parentRef = useRef<HTMLDivElement>(null);
85
+
86
+ const shouldVirtualize = rows.length > VIRTUALIZE_THRESHOLD;
87
+
88
+ const rowVirtualizer = useVirtualizer({
89
+ count: shouldVirtualize ? rows.length : 0,
90
+ getScrollElement: () => parentRef.current,
91
+ estimateSize: () => ROW_HEIGHT,
92
+ overscan: 10,
93
+ enabled: shouldVirtualize,
94
+ });
95
+
96
+ const virtualRows = shouldVirtualize ? rowVirtualizer.getVirtualItems() : [];
97
+ const totalHeight = shouldVirtualize ? rowVirtualizer.getTotalSize() : 0;
98
+ const paddingTop = virtualRows.length > 0 ? virtualRows[0].start : 0;
99
+ const paddingBottom =
100
+ virtualRows.length > 0
101
+ ? totalHeight - virtualRows[virtualRows.length - 1].end
102
+ : 0;
103
+
104
+ const headerGroups = table.getHeaderGroups();
105
+
106
+ const renderRows = () => {
107
+ if (!shouldVirtualize) {
108
+ return rows.map((row) => (
109
+ <TableRow
110
+ key={row.id}
111
+ className={onRowClick ? 'cursor-pointer' : undefined}
112
+ onClick={() => onRowClick?.(row.original)}
113
+ >
114
+ {row.getVisibleCells().map((cell) => {
115
+ const style = (cell.column.columnDef.meta as
116
+ | { style?: CSSProperties }
117
+ | undefined)?.style
118
+ const alignClass =
119
+ style?.textAlign === 'right' ? 'text-right' : undefined
120
+ return (
121
+ <TableCell
122
+ key={cell.id}
123
+ className={alignClass}
124
+ style={{ width: style?.width }}
125
+ >
126
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
127
+ </TableCell>
128
+ )
129
+ })}
130
+ </TableRow>
131
+ ))
132
+ }
133
+
134
+ return (
135
+ <>
136
+ {paddingTop > 0 && <tr style={{ height: paddingTop }} />}
137
+ {virtualRows.map((virtualRow) => {
138
+ const row = rows[virtualRow.index]
139
+ return (
140
+ <TableRow
141
+ key={row.id}
142
+ style={{
143
+ position: 'absolute',
144
+ transform: `translateY(${virtualRow.start}px)`,
145
+ height: ROW_HEIGHT,
146
+ }}
147
+ className={onRowClick ? 'cursor-pointer' : undefined}
148
+ onClick={() => onRowClick?.(row.original)}
149
+ >
150
+ {row.getVisibleCells().map((cell) => {
151
+ const style = (cell.column.columnDef.meta as
152
+ | { style?: CSSProperties }
153
+ | undefined)?.style
154
+ const alignClass =
155
+ style?.textAlign === 'right' ? 'text-right' : undefined
156
+ return (
157
+ <TableCell
158
+ key={cell.id}
159
+ className={alignClass}
160
+ style={{ width: style?.width }}
161
+ >
162
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
163
+ </TableCell>
164
+ )
165
+ })}
166
+ </TableRow>
167
+ )
168
+ })}
169
+ {paddingBottom > 0 && <tr style={{ height: paddingBottom }} />}
170
+ </>
171
+ );
172
+ };
173
+
174
+ return (
175
+ <div className="rounded-md border flex flex-col min-h-0 flex-1 overflow-x-hidden">
176
+ <div className="shrink-0">
177
+ <Table className="table-fixed">
178
+ <ColGroup columns={columns} />
179
+ <TableHeader>
180
+ {headerGroups.map((headerGroup) => (
181
+ <TableRow key={headerGroup.id}>
182
+ {headerGroup.headers.map((header) => {
183
+ const style = (
184
+ header.column.columnDef.meta as
185
+ | { style?: CSSProperties }
186
+ | undefined
187
+ )?.style
188
+ const alignClass =
189
+ style?.textAlign === 'right' ? 'text-right' : undefined
190
+ return (
191
+ <TableHead
192
+ key={header.id}
193
+ className={alignClass}
194
+ style={{ width: style?.width }}
195
+ >
196
+ {header.isPlaceholder
197
+ ? null
198
+ : flexRender(header.column.columnDef.header, header.getContext())}
199
+ </TableHead>
200
+ )
201
+ })}
202
+ </TableRow>
203
+ ))}
204
+ </TableHeader>
205
+ </Table>
206
+ </div>
207
+ <div ref={parentRef} className="overflow-y-auto flex-1 min-h-0">
208
+ <div style={{ position: "relative", height: shouldVirtualize ? totalHeight : undefined }}>
209
+ <Table className="table-fixed">
210
+ <ColGroup columns={columns} />
211
+ <TableBody>{renderRows()}</TableBody>
212
+ </Table>
213
+ </div>
214
+ </div>
215
+ {actions && <div className="shrink-0 border-t">{actions}</div>}
216
+ </div>
217
+ );
218
+ }
@@ -0,0 +1,99 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import { useNavigate } from "@tanstack/react-router";
19
+ import { useTranslation } from 'react-i18next'
20
+ import { Button } from "@/components/ui/button";
21
+ import { Skeleton } from "@/components/ui/skeleton";
22
+ import { ArrowLeftIcon } from "lucide-react";
23
+
24
+ interface TableDetailLayoutProps {
25
+ backHref: string;
26
+ backLabel?: string;
27
+ title: string;
28
+ subtitle?: string;
29
+ avatar?: React.ReactNode;
30
+ badges?: React.ReactNode;
31
+ actions?: React.ReactNode;
32
+ loading?: boolean;
33
+ children: React.ReactNode;
34
+ }
35
+
36
+ export function TableDetailLayout({
37
+ backHref,
38
+ backLabel,
39
+ title,
40
+ subtitle,
41
+ avatar,
42
+ badges,
43
+ actions,
44
+ loading,
45
+ children,
46
+ }: TableDetailLayoutProps) {
47
+ const { t } = useTranslation('common')
48
+ const navigate = useNavigate();
49
+ const resolvedBackLabel = backLabel ?? t('common.backToList')
50
+
51
+ if (loading) {
52
+ return (
53
+ <div className="p-6 space-y-6">
54
+ <Skeleton className="h-8 w-24" />
55
+ <div className="flex items-center gap-4">
56
+ <Skeleton className="h-12 w-12 rounded-full" />
57
+ <div className="space-y-2">
58
+ <Skeleton className="h-6 w-40" />
59
+ <Skeleton className="h-4 w-60" />
60
+ </div>
61
+ </div>
62
+ <Skeleton className="h-64 w-full" />
63
+ </div>
64
+ );
65
+ }
66
+
67
+ return (
68
+ <div>
69
+ <div className="sticky top-0 z-10 bg-background border-b px-6 py-2.5">
70
+ <Button
71
+ variant="ghost"
72
+ size="sm"
73
+ onClick={() => navigate({ to: backHref })}
74
+ className="gap-1.5 text-muted-foreground hover:text-foreground"
75
+ >
76
+ <ArrowLeftIcon className="h-4 w-4" />
77
+ {resolvedBackLabel}
78
+ </Button>
79
+ </div>
80
+ <div className="p-6 pt-4 space-y-6">
81
+ <div className="flex items-start justify-between">
82
+ <div className="flex items-center gap-4">
83
+ {avatar}
84
+ <div>
85
+ <div className="flex items-center gap-2">
86
+ <h1 className="text-2xl font-bold">{title}</h1>
87
+ {badges}
88
+ </div>
89
+ {subtitle && <p className="text-muted-foreground mt-1">{subtitle}</p>}
90
+ </div>
91
+ </div>
92
+ {actions && <div className="flex gap-2">{actions}</div>}
93
+ </div>
94
+
95
+ {children}
96
+ </div>
97
+ </div>
98
+ );
99
+ }
@@ -0,0 +1,108 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import { useState } from "react"
19
+ import { useTranslation } from 'react-i18next'
20
+ import ReactMarkdown from "react-markdown"
21
+ import remarkGfm from "remark-gfm"
22
+ import { ExternalLink, FileText } from "lucide-react"
23
+ import type { ThirdPartyDependencyRow } from "@allbluecn/kernel"
24
+ import { Button } from "@/components/ui/button"
25
+ import {
26
+ Dialog,
27
+ DialogContent,
28
+ DialogHeader,
29
+ DialogTitle,
30
+ DialogTrigger,
31
+ } from "@/components/ui/dialog"
32
+
33
+ export function ChangelogDialog({ row }: { row: ThirdPartyDependencyRow }) {
34
+ const [open, setOpen] = useState(false)
35
+ const { t } = useTranslation('common')
36
+ const hasChangelog = !!row.latestChangelog
37
+
38
+ if (!hasChangelog) {
39
+ return <span className="text-xs text-muted-foreground">—</span>
40
+ }
41
+
42
+ return (
43
+ <Dialog open={open} onOpenChange={setOpen}>
44
+ <DialogTrigger asChild>
45
+ <Button size="sm" variant="ghost" className="h-7 gap-1 px-2" title={t('dependency.table.cell.viewChangelog')}>
46
+ <FileText className="size-3.5" />
47
+ <span className="text-xs">{t('dependency.table.cell.changelogBtn')}</span>
48
+ </Button>
49
+ </DialogTrigger>
50
+ <DialogContent className="max-h-[85vh] w-200 max-w-4xl overflow-hidden p-0">
51
+ <DialogHeader className="border-b px-5 py-3">
52
+ <div className="flex items-center justify-between gap-2 pr-6">
53
+ <DialogTitle className="text-base">
54
+ {row.displayName}
55
+ <span className="ml-2 font-mono text-sm font-normal text-muted-foreground">
56
+ v{row.latestVersion}
57
+ </span>
58
+ </DialogTitle>
59
+ <a
60
+ href={`https://github.com/search?q=${encodeURIComponent(row.name)}&type=repositories`}
61
+ target="_blank"
62
+ rel="noreferrer"
63
+ className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"
64
+ >
65
+ GitHub <ExternalLink className="size-3" />
66
+ </a>
67
+ </div>
68
+ </DialogHeader>
69
+ <div className="max-h-[65vh] overflow-y-auto px-5 py-3">
70
+ <div className="text-sm">
71
+ <ReactMarkdown
72
+ remarkPlugins={[remarkGfm]}
73
+ components={{
74
+ h1: ({ children }) => <h1 className="mb-2 mt-3 text-base font-semibold">{children}</h1>,
75
+ h2: ({ children }) => <h2 className="mb-2 mt-3 text-sm font-semibold">{children}</h2>,
76
+ h3: ({ children }) => <h3 className="mb-1 mt-2 text-sm font-semibold">{children}</h3>,
77
+ p: ({ children }) => <p className="my-1.5 leading-relaxed">{children}</p>,
78
+ ul: ({ children }) => <ul className="my-1.5 list-disc space-y-0.5 pl-5">{children}</ul>,
79
+ ol: ({ children }) => <ol className="my-1.5 list-decimal space-y-0.5 pl-5">{children}</ol>,
80
+ li: ({ children }) => <li className="leading-relaxed">{children}</li>,
81
+ a: ({ children, href }) => (
82
+ <a href={href} target="_blank" rel="noreferrer" className="text-blue-500 underline underline-offset-2">
83
+ {children}
84
+ </a>
85
+ ),
86
+ strong: ({ children }) => <strong className="font-semibold">{children}</strong>,
87
+ code: ({ children }) => (
88
+ <code className="rounded bg-muted px-1 py-0.5 font-mono text-xs">{children}</code>
89
+ ),
90
+ pre: ({ children }) => (
91
+ <pre className="my-2 overflow-x-auto rounded bg-muted p-2 text-xs">{children}</pre>
92
+ ),
93
+ hr: () => <hr className="my-3 border-border" />,
94
+ blockquote: ({ children }) => (
95
+ <blockquote className="my-2 border-l-2 border-border pl-3 text-muted-foreground">
96
+ {children}
97
+ </blockquote>
98
+ ),
99
+ }}
100
+ >
101
+ {row.latestChangelog ?? ""}
102
+ </ReactMarkdown>
103
+ </div>
104
+ </div>
105
+ </DialogContent>
106
+ </Dialog>
107
+ )
108
+ }