@allbluecn/admin-app 0.3.8 → 0.4.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 (22) hide show
  1. package/package.json +3 -3
  2. package/src/components/dependency/dependency-table.tsx +21 -3
  3. package/src/components/invitations/invitations-page.tsx +16 -4
  4. package/src/components/user/user-detail/user-detail-dialogs.tsx +6 -6
  5. package/src/paraglide/messages/_index.js +8 -6
  6. package/src/paraglide/messages/admin_invitations_filter_showdisabled1.js +30 -0
  7. package/src/paraglide/messages/admin_users_action_deactivate.js +30 -0
  8. package/src/paraglide/messages/admin_users_dialog_deactivate_confirm.js +30 -0
  9. package/src/paraglide/messages/admin_users_dialog_deactivate_description.js +30 -0
  10. package/src/paraglide/messages/admin_users_dialog_deactivate_placeholder.js +30 -0
  11. package/src/paraglide/messages/admin_users_dialog_deactivate_title.js +30 -0
  12. package/src/paraglide/messages/admin_users_toast_deactivatefailed1.js +30 -0
  13. package/src/paraglide/messages/admin_users_toast_userdeactivated1.js +30 -0
  14. package/src/routes/_nav/users/$userId/route.lazy.tsx +10 -10
  15. package/src/server/serverFns/dependency/sync.ts +2 -2
  16. package/src/server/serverFns/user/{delete.ts → deactivate.ts} +2 -2
  17. package/src/paraglide/messages/admin_users_dialog_delete_confirm.js +0 -30
  18. package/src/paraglide/messages/admin_users_dialog_delete_description.js +0 -30
  19. package/src/paraglide/messages/admin_users_dialog_delete_placeholder.js +0 -30
  20. package/src/paraglide/messages/admin_users_dialog_delete_title.js +0 -30
  21. package/src/paraglide/messages/admin_users_toast_deletefailed1.js +0 -30
  22. package/src/paraglide/messages/admin_users_toast_userdeleted1.js +0 -30
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@allbluecn/admin-app",
3
- "version": "0.3.8",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@allbluecn/database": "0.9.5",
9
- "@allbluecn/kernel": "0.10.1",
8
+ "@allbluecn/database": "0.10.0",
9
+ "@allbluecn/kernel": "0.10.2",
10
10
  "@auth/core": "^0.41.2",
11
11
  "@base-ui/react": "^1.8.0",
12
12
  "@fontsource-variable/inter": "^5.3.0",
@@ -56,6 +56,7 @@ import { cn } from "@/lib/utils"
56
56
  import { getPageNumbers } from "@/components/data-table/data-table-pagination"
57
57
  import { dependencyTableFeatures, getDependencyColumns } from "./columns"
58
58
 
59
+ const SYNC_ALL_BATCH_SIZE = 50
59
60
  const PAGE_SIZE = 15
60
61
 
61
62
  const STATUS_FILTERS: Array<{ value: "all" | VersionStatus }> = [
@@ -89,6 +90,7 @@ export function DependencyTable({
89
90
  const [viewFilter, setViewFilter] = useState<"watched" | "all">("watched")
90
91
  const [syncing, setSyncing] = useState<Set<string>>(new Set())
91
92
  const [syncingAll, setSyncingAll] = useState(false)
93
+ const [syncAllProgress, setSyncAllProgress] = useState<{ done: number; total: number } | null>(null)
92
94
  const [{ pageIndex }, setPagination] = useState<PaginationState>({ pageIndex: 0, pageSize: PAGE_SIZE })
93
95
 
94
96
  // 外部筛选(搜索 + 分类 + 状态 + 视图),得到 filtered 后交给 TanStack Table 分页
@@ -173,7 +175,20 @@ export function DependencyTable({
173
175
  }
174
176
  setSyncingAll(true)
175
177
  try {
176
- const results = await syncAllDependenciesFn({ data: { names } })
178
+ // A10 超时治理:分批请求 + 游标续跑。单批(含网络级)失败只记该批结果,
179
+ // 游标继续,不中断整体;serverless 单请求时长因此有界(50 × 单包往返)。
180
+ const results: Awaited<ReturnType<typeof syncAllDependenciesFn>> = []
181
+ for (let cursor = 0; cursor < names.length; cursor += SYNC_ALL_BATCH_SIZE) {
182
+ const batch = names.slice(cursor, cursor + SYNC_ALL_BATCH_SIZE)
183
+ setSyncAllProgress({ done: cursor, total: names.length })
184
+ try {
185
+ results.push(...(await syncAllDependenciesFn({ data: { names: batch } })))
186
+ } catch (e) {
187
+ const msg = e instanceof Error ? e.message : String(e)
188
+ results.push(...batch.map((name) => ({ name, success: false as const, error: msg })))
189
+ }
190
+ }
191
+ setSyncAllProgress(null)
177
192
  const ok = results.filter((r) => r.success)
178
193
  const fail = results.filter((r) => !r.success)
179
194
  if (ok.length) toast.success(m.common_dependency_table_toast_syncSuccess({ count: ok.length }))
@@ -186,11 +201,12 @@ export function DependencyTable({
186
201
  })
187
202
  onMutated?.()
188
203
  } catch (e) {
189
- // 批量同步整体抛错同样此前无 catch(unhandled rejection)
204
+ // 兜底:分批循环外的意外错误(如 setSyncAllProgress 抛错等)
190
205
  toast.error(m.common_dependency_table_toast_syncAllFailed(), {
191
206
  description: e instanceof Error ? e.message : String(e),
192
207
  })
193
208
  } finally {
209
+ setSyncAllProgress(null)
194
210
  setSyncingAll(false)
195
211
  }
196
212
  }
@@ -211,7 +227,9 @@ export function DependencyTable({
211
227
  <div className="ml-auto flex items-center gap-2">
212
228
  <Button onClick={handleSyncAll} disabled={syncingAll} variant="outline" size="sm">
213
229
  {syncingAll ? <Loader2 className="mr-1 size-3.5 animate-spin" /> : <RefreshCw className="mr-1 size-3.5" />}
214
- {m.common_dependency_table_syncAll({ count: filtered.length })}
230
+ {syncingAll && syncAllProgress
231
+ ? `${syncAllProgress.done}/${syncAllProgress.total}`
232
+ : m.common_dependency_table_syncAll({ count: filtered.length })}
215
233
  </Button>
216
234
  </div>
217
235
  </div>
@@ -107,10 +107,12 @@ export function InvitationsPage(): React.ReactElement {
107
107
  const [usesViewer, setUsesViewer] = useState<InvitationCodeRow | null>(null)
108
108
  const [createOpen, setCreateOpen] = useState(false)
109
109
  const [createForm, setCreateForm] = useState({ code: "", maxUses: 1, validDays: 30 })
110
+ // 已禁用码默认隐藏(服务端同默认);开关打开后可查回并走「启用」恢复
111
+ const [includeDisabled, setIncludeDisabled] = useState(false)
110
112
 
111
113
  const codesQuery = useQuery({
112
- queryKey: ["invitations", "codes"],
113
- queryFn: () => listInvitationCodesFn({ data: { page: 1, pageSize: 100 } }),
114
+ queryKey: ["invitations", "codes", includeDisabled],
115
+ queryFn: () => listInvitationCodesFn({ data: { page: 1, pageSize: 100, includeDisabled } }),
114
116
  })
115
117
  const modeQuery = useQuery({
116
118
  queryKey: ["invitations", "mode"],
@@ -220,10 +222,20 @@ export function InvitationsPage(): React.ReactElement {
220
222
  <div className="space-y-3">
221
223
  <div className="flex items-center justify-between">
222
224
  <h2 className="text-lg font-semibold">{m["admin-invitations_page_title"]()}</h2>
223
- <Button onClick={() => setCreateOpen(true)}>
225
+ <div className="flex items-center gap-4">
226
+ <label className="flex cursor-pointer items-center gap-2 text-sm text-muted-foreground">
227
+ <Switch
228
+ checked={includeDisabled}
229
+ onCheckedChange={setIncludeDisabled}
230
+ aria-label={m["admin-invitations_filter_showDisabled"]()}
231
+ />
232
+ {m["admin-invitations_filter_showDisabled"]()}
233
+ </label>
234
+ <Button onClick={() => setCreateOpen(true)}>
224
235
  <Plus className="size-4" />
225
236
  {m["admin-invitations_create_title"]()}
226
- </Button>
237
+ </Button>
238
+ </div>
227
239
  </div>
228
240
 
229
241
  {loading ? (
@@ -30,7 +30,7 @@ import { Label } from '@/components/ui/label'
30
30
  import { Button } from '@/components/ui/button'
31
31
 
32
32
  export type UserDialogState = { open: boolean; value: string }
33
- export type UserDeleteDialogState = { open: boolean; confirmName: string }
33
+ export type UserDeactivateDialogState = { open: boolean; confirmName: string }
34
34
 
35
35
  type DialogProps = {
36
36
  username: string
@@ -164,7 +164,7 @@ export function UserPasswordDialog({
164
164
  }
165
165
 
166
166
  /** 删除用户确认对话框(输入用户名确认) */
167
- export function UserDeleteDialog({
167
+ export function UserDeactivateDialog({
168
168
  open,
169
169
  confirmName,
170
170
  username,
@@ -183,18 +183,18 @@ export function UserDeleteDialog({
183
183
  <AlertDialog open={open} onOpenChange={onOpenChange}>
184
184
  <AlertDialogContent>
185
185
  <AlertDialogHeader>
186
- <AlertDialogTitle>{m['admin-users_dialog_delete_title']()}</AlertDialogTitle>
186
+ <AlertDialogTitle>{m['admin-users_dialog_deactivate_title']()}</AlertDialogTitle>
187
187
  <AlertDialogDescription>
188
- {m['admin-users_dialog_delete_description']({ username })}
188
+ {m['admin-users_dialog_deactivate_description']({ username })}
189
189
  </AlertDialogDescription>
190
190
  </AlertDialogHeader>
191
- <Input placeholder={m['admin-users_dialog_delete_placeholder']()} value={confirmName} onChange={(e: React.ChangeEvent<HTMLInputElement>) => onConfirmNameChange(e.target.value)} />
191
+ <Input placeholder={m['admin-users_dialog_deactivate_placeholder']()} value={confirmName} onChange={(e: React.ChangeEvent<HTMLInputElement>) => onConfirmNameChange(e.target.value)} />
192
192
  <AlertDialogFooter>
193
193
  <AlertDialogCancel>{m.common_button_cancel()}</AlertDialogCancel>
194
194
  <AlertDialogAction
195
195
  disabled={confirmName !== username || isPending}
196
196
  onClick={onSubmit}
197
- >{m['admin-users_dialog_delete_confirm']()}</AlertDialogAction>
197
+ >{m['admin-users_dialog_deactivate_confirm']()}</AlertDialogAction>
198
198
  </AlertDialogFooter>
199
199
  </AlertDialogContent>
200
200
  </AlertDialog>
@@ -283,6 +283,7 @@ export * from './admin_invitations_delete_confirm_desc.js'
283
283
  export * from './admin_invitations_delete_confirm_title.js'
284
284
  export * from './admin_invitations_delete_disabled_hint.js'
285
285
  export * from './admin_invitations_empty.js'
286
+ export * from './admin_invitations_filter_showdisabled1.js'
286
287
  export * from './admin_invitations_mode_invite.js'
287
288
  export * from './admin_invitations_mode_invite_desc.js'
288
289
  export * from './admin_invitations_mode_open.js'
@@ -342,6 +343,7 @@ export * from './admin_loginproviders_toast_testfailed2.js'
342
343
  export * from './admin_loginproviders_toast_testok2.js'
343
344
  export * from './admin_users_action_changerole1.js'
344
345
  export * from './admin_users_action_changestatus1.js'
346
+ export * from './admin_users_action_deactivate.js'
345
347
  export * from './admin_users_action_resetpassword1.js'
346
348
  export * from './admin_users_action_viewdetails1.js'
347
349
  export * from './admin_users_column_email.js'
@@ -378,10 +380,10 @@ export * from './admin_users_detail_stats_prds.js'
378
380
  export * from './admin_users_detail_stats_reviews.js'
379
381
  export * from './admin_users_detail_stats_title.js'
380
382
  export * from './admin_users_detail_usernotfound2.js'
381
- export * from './admin_users_dialog_delete_confirm.js'
382
- export * from './admin_users_dialog_delete_description.js'
383
- export * from './admin_users_dialog_delete_placeholder.js'
384
- export * from './admin_users_dialog_delete_title.js'
383
+ export * from './admin_users_dialog_deactivate_confirm.js'
384
+ export * from './admin_users_dialog_deactivate_description.js'
385
+ export * from './admin_users_dialog_deactivate_placeholder.js'
386
+ export * from './admin_users_dialog_deactivate_title.js'
385
387
  export * from './admin_users_dialog_password_confirm.js'
386
388
  export * from './admin_users_dialog_password_newpassword1.js'
387
389
  export * from './admin_users_dialog_password_title.js'
@@ -444,13 +446,13 @@ export * from './admin_users_status_banned.js'
444
446
  export * from './admin_users_status_inactive.js'
445
447
  export * from './admin_users_toast_createfailed1.js'
446
448
  export * from './admin_users_toast_createsuccess1.js'
447
- export * from './admin_users_toast_deletefailed1.js'
449
+ export * from './admin_users_toast_deactivatefailed1.js'
448
450
  export * from './admin_users_toast_passwordreset1.js'
449
451
  export * from './admin_users_toast_resetfailed1.js'
450
452
  export * from './admin_users_toast_roleupdated1.js'
451
453
  export * from './admin_users_toast_statusupdated1.js'
452
454
  export * from './admin_users_toast_updatefailed1.js'
453
- export * from './admin_users_toast_userdeleted1.js'
455
+ export * from './admin_users_toast_userdeactivated1.js'
454
456
  export * from './common_activitylog_actiontype2.js'
455
457
  export * from './common_activitylog_actiontypes_all2.js'
456
458
  export * from './common_activitylog_actiontypes_create2.js'
@@ -0,0 +1,30 @@
1
+ /* eslint-disable */
2
+ import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
+
4
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
+
6
+ /** @typedef {{}} Admin_Invitations_Filter_Showdisabled1Inputs */
7
+
8
+ const zh_admin_invitations_filter_showdisabled1 = /** @type {(inputs: Admin_Invitations_Filter_Showdisabled1Inputs) => LocalizedString} */ () => {
9
+ return /** @type {LocalizedString} */ (`显示已禁用`)
10
+ };
11
+
12
+ const en_admin_invitations_filter_showdisabled1 = /** @type {(inputs: Admin_Invitations_Filter_Showdisabled1Inputs) => LocalizedString} */ () => {
13
+ return /** @type {LocalizedString} */ (`Show disabled`)
14
+ };
15
+
16
+ /**
17
+ * | output |
18
+ * | --- |
19
+ * | "Show disabled" |
20
+ *
21
+ * @param {Admin_Invitations_Filter_Showdisabled1Inputs} inputs
22
+ * @param {{ locale?: "zh" | "en" }} options
23
+ * @returns {LocalizedString}
24
+ */
25
+ const admin_invitations_filter_showdisabled1 = /** @type {((inputs?: Admin_Invitations_Filter_Showdisabled1Inputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Invitations_Filter_Showdisabled1Inputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
+ if (locale === "en") return en_admin_invitations_filter_showdisabled1(inputs)
28
+ return zh_admin_invitations_filter_showdisabled1(inputs)
29
+ });
30
+ export { admin_invitations_filter_showdisabled1 as "admin-invitations_filter_showDisabled" }
@@ -0,0 +1,30 @@
1
+ /* eslint-disable */
2
+ import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
+
4
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
+
6
+ /** @typedef {{}} Admin_Users_Action_DeactivateInputs */
7
+
8
+ const zh_admin_users_action_deactivate = /** @type {(inputs: Admin_Users_Action_DeactivateInputs) => LocalizedString} */ () => {
9
+ return /** @type {LocalizedString} */ (`停用账号`)
10
+ };
11
+
12
+ const en_admin_users_action_deactivate = /** @type {(inputs: Admin_Users_Action_DeactivateInputs) => LocalizedString} */ () => {
13
+ return /** @type {LocalizedString} */ (`Deactivate`)
14
+ };
15
+
16
+ /**
17
+ * | output |
18
+ * | --- |
19
+ * | "Deactivate" |
20
+ *
21
+ * @param {Admin_Users_Action_DeactivateInputs} inputs
22
+ * @param {{ locale?: "zh" | "en" }} options
23
+ * @returns {LocalizedString}
24
+ */
25
+ const admin_users_action_deactivate = /** @type {((inputs?: Admin_Users_Action_DeactivateInputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Action_DeactivateInputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
+ if (locale === "en") return en_admin_users_action_deactivate(inputs)
28
+ return zh_admin_users_action_deactivate(inputs)
29
+ });
30
+ export { admin_users_action_deactivate as "admin-users_action_deactivate" }
@@ -0,0 +1,30 @@
1
+ /* eslint-disable */
2
+ import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
+
4
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
+
6
+ /** @typedef {{}} Admin_Users_Dialog_Deactivate_ConfirmInputs */
7
+
8
+ const zh_admin_users_dialog_deactivate_confirm = /** @type {(inputs: Admin_Users_Dialog_Deactivate_ConfirmInputs) => LocalizedString} */ () => {
9
+ return /** @type {LocalizedString} */ (`确认停用`)
10
+ };
11
+
12
+ const en_admin_users_dialog_deactivate_confirm = /** @type {(inputs: Admin_Users_Dialog_Deactivate_ConfirmInputs) => LocalizedString} */ () => {
13
+ return /** @type {LocalizedString} */ (`Confirm Deactivate`)
14
+ };
15
+
16
+ /**
17
+ * | output |
18
+ * | --- |
19
+ * | "Confirm Deactivate" |
20
+ *
21
+ * @param {Admin_Users_Dialog_Deactivate_ConfirmInputs} inputs
22
+ * @param {{ locale?: "zh" | "en" }} options
23
+ * @returns {LocalizedString}
24
+ */
25
+ const admin_users_dialog_deactivate_confirm = /** @type {((inputs?: Admin_Users_Dialog_Deactivate_ConfirmInputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Dialog_Deactivate_ConfirmInputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
+ if (locale === "en") return en_admin_users_dialog_deactivate_confirm(inputs)
28
+ return zh_admin_users_dialog_deactivate_confirm(inputs)
29
+ });
30
+ export { admin_users_dialog_deactivate_confirm as "admin-users_dialog_deactivate_confirm" }
@@ -0,0 +1,30 @@
1
+ /* eslint-disable */
2
+ import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
+
4
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
+
6
+ /** @typedef {{ username: NonNullable<unknown> }} Admin_Users_Dialog_Deactivate_DescriptionInputs */
7
+
8
+ const zh_admin_users_dialog_deactivate_description = /** @type {(inputs: Admin_Users_Dialog_Deactivate_DescriptionInputs) => LocalizedString} */ (i) => {
9
+ return /** @type {LocalizedString} */ (`停用后该用户将无法登录,数据保留,可随时通过「修改状态」恢复为启用。请输入用户名 <strong>${i?.username}</strong> 以确认。`)
10
+ };
11
+
12
+ const en_admin_users_dialog_deactivate_description = /** @type {(inputs: Admin_Users_Dialog_Deactivate_DescriptionInputs) => LocalizedString} */ (i) => {
13
+ return /** @type {LocalizedString} */ (`Once deactivated, this user can no longer sign in. Their data is kept and the account can be re-enabled anytime via 'Change Status'. Please enter <strong>${i?.username}</strong> to confirm.`)
14
+ };
15
+
16
+ /**
17
+ * | output |
18
+ * | --- |
19
+ * | "Once deactivated, this user can no longer sign in. Their data is kept and the account can be re-enabled anytime via 'Change Status'. Please enter <strong>{us..." |
20
+ *
21
+ * @param {Admin_Users_Dialog_Deactivate_DescriptionInputs} inputs
22
+ * @param {{ locale?: "zh" | "en" }} options
23
+ * @returns {LocalizedString}
24
+ */
25
+ const admin_users_dialog_deactivate_description = /** @type {((inputs: Admin_Users_Dialog_Deactivate_DescriptionInputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Dialog_Deactivate_DescriptionInputs, { locale?: "zh" | "en" }, {}>} */ ((inputs, options = {}) => {
26
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
+ if (locale === "en") return en_admin_users_dialog_deactivate_description(inputs)
28
+ return zh_admin_users_dialog_deactivate_description(inputs)
29
+ });
30
+ export { admin_users_dialog_deactivate_description as "admin-users_dialog_deactivate_description" }
@@ -0,0 +1,30 @@
1
+ /* eslint-disable */
2
+ import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
+
4
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
+
6
+ /** @typedef {{}} Admin_Users_Dialog_Deactivate_PlaceholderInputs */
7
+
8
+ const zh_admin_users_dialog_deactivate_placeholder = /** @type {(inputs: Admin_Users_Dialog_Deactivate_PlaceholderInputs) => LocalizedString} */ () => {
9
+ return /** @type {LocalizedString} */ (`输入用户名确认`)
10
+ };
11
+
12
+ const en_admin_users_dialog_deactivate_placeholder = /** @type {(inputs: Admin_Users_Dialog_Deactivate_PlaceholderInputs) => LocalizedString} */ () => {
13
+ return /** @type {LocalizedString} */ (`Enter username to confirm`)
14
+ };
15
+
16
+ /**
17
+ * | output |
18
+ * | --- |
19
+ * | "Enter username to confirm" |
20
+ *
21
+ * @param {Admin_Users_Dialog_Deactivate_PlaceholderInputs} inputs
22
+ * @param {{ locale?: "zh" | "en" }} options
23
+ * @returns {LocalizedString}
24
+ */
25
+ const admin_users_dialog_deactivate_placeholder = /** @type {((inputs?: Admin_Users_Dialog_Deactivate_PlaceholderInputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Dialog_Deactivate_PlaceholderInputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
+ if (locale === "en") return en_admin_users_dialog_deactivate_placeholder(inputs)
28
+ return zh_admin_users_dialog_deactivate_placeholder(inputs)
29
+ });
30
+ export { admin_users_dialog_deactivate_placeholder as "admin-users_dialog_deactivate_placeholder" }
@@ -0,0 +1,30 @@
1
+ /* eslint-disable */
2
+ import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
+
4
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
+
6
+ /** @typedef {{}} Admin_Users_Dialog_Deactivate_TitleInputs */
7
+
8
+ const zh_admin_users_dialog_deactivate_title = /** @type {(inputs: Admin_Users_Dialog_Deactivate_TitleInputs) => LocalizedString} */ () => {
9
+ return /** @type {LocalizedString} */ (`确认停用用户`)
10
+ };
11
+
12
+ const en_admin_users_dialog_deactivate_title = /** @type {(inputs: Admin_Users_Dialog_Deactivate_TitleInputs) => LocalizedString} */ () => {
13
+ return /** @type {LocalizedString} */ (`Deactivate User`)
14
+ };
15
+
16
+ /**
17
+ * | output |
18
+ * | --- |
19
+ * | "Deactivate User" |
20
+ *
21
+ * @param {Admin_Users_Dialog_Deactivate_TitleInputs} inputs
22
+ * @param {{ locale?: "zh" | "en" }} options
23
+ * @returns {LocalizedString}
24
+ */
25
+ const admin_users_dialog_deactivate_title = /** @type {((inputs?: Admin_Users_Dialog_Deactivate_TitleInputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Dialog_Deactivate_TitleInputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
+ if (locale === "en") return en_admin_users_dialog_deactivate_title(inputs)
28
+ return zh_admin_users_dialog_deactivate_title(inputs)
29
+ });
30
+ export { admin_users_dialog_deactivate_title as "admin-users_dialog_deactivate_title" }
@@ -0,0 +1,30 @@
1
+ /* eslint-disable */
2
+ import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
+
4
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
+
6
+ /** @typedef {{}} Admin_Users_Toast_Deactivatefailed1Inputs */
7
+
8
+ const zh_admin_users_toast_deactivatefailed1 = /** @type {(inputs: Admin_Users_Toast_Deactivatefailed1Inputs) => LocalizedString} */ () => {
9
+ return /** @type {LocalizedString} */ (`停用失败`)
10
+ };
11
+
12
+ const en_admin_users_toast_deactivatefailed1 = /** @type {(inputs: Admin_Users_Toast_Deactivatefailed1Inputs) => LocalizedString} */ () => {
13
+ return /** @type {LocalizedString} */ (`Deactivation failed`)
14
+ };
15
+
16
+ /**
17
+ * | output |
18
+ * | --- |
19
+ * | "Deactivation failed" |
20
+ *
21
+ * @param {Admin_Users_Toast_Deactivatefailed1Inputs} inputs
22
+ * @param {{ locale?: "zh" | "en" }} options
23
+ * @returns {LocalizedString}
24
+ */
25
+ const admin_users_toast_deactivatefailed1 = /** @type {((inputs?: Admin_Users_Toast_Deactivatefailed1Inputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Toast_Deactivatefailed1Inputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
+ if (locale === "en") return en_admin_users_toast_deactivatefailed1(inputs)
28
+ return zh_admin_users_toast_deactivatefailed1(inputs)
29
+ });
30
+ export { admin_users_toast_deactivatefailed1 as "admin-users_toast_deactivateFailed" }
@@ -0,0 +1,30 @@
1
+ /* eslint-disable */
2
+ import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
+
4
+ /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
+
6
+ /** @typedef {{}} Admin_Users_Toast_Userdeactivated1Inputs */
7
+
8
+ const zh_admin_users_toast_userdeactivated1 = /** @type {(inputs: Admin_Users_Toast_Userdeactivated1Inputs) => LocalizedString} */ () => {
9
+ return /** @type {LocalizedString} */ (`用户已停用`)
10
+ };
11
+
12
+ const en_admin_users_toast_userdeactivated1 = /** @type {(inputs: Admin_Users_Toast_Userdeactivated1Inputs) => LocalizedString} */ () => {
13
+ return /** @type {LocalizedString} */ (`User deactivated`)
14
+ };
15
+
16
+ /**
17
+ * | output |
18
+ * | --- |
19
+ * | "User deactivated" |
20
+ *
21
+ * @param {Admin_Users_Toast_Userdeactivated1Inputs} inputs
22
+ * @param {{ locale?: "zh" | "en" }} options
23
+ * @returns {LocalizedString}
24
+ */
25
+ const admin_users_toast_userdeactivated1 = /** @type {((inputs?: Admin_Users_Toast_Userdeactivated1Inputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Toast_Userdeactivated1Inputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
+ const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
+ if (locale === "en") return en_admin_users_toast_userdeactivated1(inputs)
28
+ return zh_admin_users_toast_userdeactivated1(inputs)
29
+ });
30
+ export { admin_users_toast_userdeactivated1 as "admin-users_toast_userDeactivated" }
@@ -29,7 +29,7 @@ import { getUserDetailFn } from '@/server/serverFns/user/detail'
29
29
  import { updateUserRoleFn } from '@/server/serverFns/user/update-role'
30
30
  import { updateUserStatusFn } from '@/server/serverFns/user/update-status'
31
31
  import { resetUserPasswordFn } from '@/server/serverFns/user/reset-password'
32
- import { deleteUserFn } from '@/server/serverFns/user/delete'
32
+ import { deactivateUserFn } from '@/server/serverFns/user/deactivate'
33
33
  import { TableDetailLayout } from '@/components/data-table/table-detail-layout'
34
34
  import { Badge } from '@/components/ui/badge'
35
35
  import { Separator } from '@/components/ui/separator'
@@ -51,7 +51,7 @@ import {
51
51
  } from '@/components/ui/card'
52
52
  import { AdminUserErrorBoundary } from '@/components/user/user-detail/error-boundary'
53
53
  import {
54
- UserDeleteDialog,
54
+ UserDeactivateDialog,
55
55
  UserPasswordDialog,
56
56
  UserRoleDialog,
57
57
  UserStatusDialog,
@@ -138,7 +138,7 @@ function UserDetailPage() {
138
138
  const [roleDialog, setRoleDialog] = useState({ open: false, value: '' })
139
139
  const [statusDialog, setStatusDialog] = useState({ open: false, value: '' })
140
140
  const [passwordDialog, setPasswordDialog] = useState({ open: false, value: '' })
141
- const [deleteDialog, setDeleteDialog] = useState({ open: false, confirmName: '' })
141
+ const [deactivateDialog, setDeleteDialog] = useState({ open: false, confirmName: '' })
142
142
 
143
143
  // loader 对未知 id throw notFound(),此处仅作类型层面的防御性兜底
144
144
  if (!user) return null
@@ -200,7 +200,7 @@ function UserDetailPage() {
200
200
  {m['admin-users_action_resetPassword']()}
201
201
  </Button>
202
202
  <Button variant="destructive" size="sm" onClick={() => setDeleteDialog({ open: true, confirmName: '' })}>
203
- {m.common_button_delete()}
203
+ {m['admin-users_action_deactivate']()}
204
204
  </Button>
205
205
  </>
206
206
  }
@@ -383,19 +383,19 @@ function UserDetailPage() {
383
383
  })}
384
384
  />
385
385
 
386
- <UserDeleteDialog
387
- open={deleteDialog.open}
388
- confirmName={deleteDialog.confirmName}
386
+ <UserDeactivateDialog
387
+ open={deactivateDialog.open}
388
+ confirmName={deactivateDialog.confirmName}
389
389
  username={user.username}
390
390
  isPending={isPending}
391
391
  onOpenChange={(o) => setDeleteDialog((d) => ({ ...d, open: o }))}
392
392
  onConfirmNameChange={(v) => setDeleteDialog((d) => ({ ...d, confirmName: v }))}
393
393
  onSubmit={() => startTransition(async () => {
394
394
  try {
395
- await deleteUserFn({ data: { userId: user.id } })
396
- toast.success(m['admin-users_toast_userDeleted']())
395
+ await deactivateUserFn({ data: { userId: user.id } })
396
+ toast.success(m['admin-users_toast_userDeactivated']())
397
397
  await navigate({ to: '/users' })
398
- } catch { toast.error(m['admin-users_toast_deleteFailed']()) }
398
+ } catch { toast.error(m['admin-users_toast_deactivateFailed']()) }
399
399
  })}
400
400
  />
401
401
  </>
@@ -57,8 +57,8 @@ export const syncDependencyFn = createServerFn({ method: "POST" })
57
57
 
58
58
  const syncAllInput = z.object({
59
59
  /** 要同步的包名列表(前端传当前视图的全部包名,含未跟踪的会 upsert 创建) */
60
- // 上限 500 为滥用兜底(当前全仓去重依赖名 ~240);顺序同步耗时随数量线性增长,
61
- // 真正的超时治理需前端分批调用(见审计 A10 待决策)
60
+ // 前端按 50/批分批调用(dependency-table.tsx,A10 超时治理已落地);
61
+ // 此上限 500 为直连滥用的最终兜底
62
62
  names: z.array(packageNameSchema).max(500),
63
63
  })
64
64
 
@@ -20,11 +20,11 @@ import { z } from 'zod'
20
20
  import { requireAdmin } from '@/server/auth-helpers'
21
21
  import { updateUserGuarded } from '@/server/user-admin-guard'
22
22
 
23
- export const deleteUserFn = createServerFn({ method: 'POST' })
23
+ export const deactivateUserFn = createServerFn({ method: 'POST' })
24
24
  .validator(z.object({ userId: z.string() }))
25
25
  .handler(async ({ data }) => {
26
26
  const session = await requireAdmin()
27
- // 自保护:不能停用自己的账号(软删语义,误操作即自锁)
27
+ // 自保护:不能停用自己的账号(软停用语义,误操作即自锁)
28
28
  if (data.userId === session.user?.id) throw new Error('不能停用自己的账号')
29
29
  // 软删 = INACTIVE:同受「不得触碰超管 / 不得清空最后一名启用超管」约束
30
30
  return updateUserGuarded(session.user?.role, data.userId, { status: 'INACTIVE' }, (tx) =>
@@ -1,30 +0,0 @@
1
- /* eslint-disable */
2
- import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
-
4
- /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
-
6
- /** @typedef {{}} Admin_Users_Dialog_Delete_ConfirmInputs */
7
-
8
- const zh_admin_users_dialog_delete_confirm = /** @type {(inputs: Admin_Users_Dialog_Delete_ConfirmInputs) => LocalizedString} */ () => {
9
- return /** @type {LocalizedString} */ (`确认删除`)
10
- };
11
-
12
- const en_admin_users_dialog_delete_confirm = /** @type {(inputs: Admin_Users_Dialog_Delete_ConfirmInputs) => LocalizedString} */ () => {
13
- return /** @type {LocalizedString} */ (`Confirm Delete`)
14
- };
15
-
16
- /**
17
- * | output |
18
- * | --- |
19
- * | "Confirm Delete" |
20
- *
21
- * @param {Admin_Users_Dialog_Delete_ConfirmInputs} inputs
22
- * @param {{ locale?: "zh" | "en" }} options
23
- * @returns {LocalizedString}
24
- */
25
- const admin_users_dialog_delete_confirm = /** @type {((inputs?: Admin_Users_Dialog_Delete_ConfirmInputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Dialog_Delete_ConfirmInputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
- if (locale === "en") return en_admin_users_dialog_delete_confirm(inputs)
28
- return zh_admin_users_dialog_delete_confirm(inputs)
29
- });
30
- export { admin_users_dialog_delete_confirm as "admin-users_dialog_delete_confirm" }
@@ -1,30 +0,0 @@
1
- /* eslint-disable */
2
- import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
-
4
- /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
-
6
- /** @typedef {{ username: NonNullable<unknown> }} Admin_Users_Dialog_Delete_DescriptionInputs */
7
-
8
- const zh_admin_users_dialog_delete_description = /** @type {(inputs: Admin_Users_Dialog_Delete_DescriptionInputs) => LocalizedString} */ (i) => {
9
- return /** @type {LocalizedString} */ (`此操作不可撤销。将删除用户 <strong>${i?.username}</strong> 及其所有关联数据。请输入用户名 <strong>${i?.username}</strong> 以确认。`)
10
- };
11
-
12
- const en_admin_users_dialog_delete_description = /** @type {(inputs: Admin_Users_Dialog_Delete_DescriptionInputs) => LocalizedString} */ (i) => {
13
- return /** @type {LocalizedString} */ (`This action cannot be undone. This will delete user <strong>${i?.username}</strong> and all associated data. Please enter <strong>${i?.username}</strong> to confirm.`)
14
- };
15
-
16
- /**
17
- * | output |
18
- * | --- |
19
- * | "This action cannot be undone. This will delete user <strong>{username}</strong> and all associated data. Please enter <strong>{username}</strong> to confirm." |
20
- *
21
- * @param {Admin_Users_Dialog_Delete_DescriptionInputs} inputs
22
- * @param {{ locale?: "zh" | "en" }} options
23
- * @returns {LocalizedString}
24
- */
25
- const admin_users_dialog_delete_description = /** @type {((inputs: Admin_Users_Dialog_Delete_DescriptionInputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Dialog_Delete_DescriptionInputs, { locale?: "zh" | "en" }, {}>} */ ((inputs, options = {}) => {
26
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
- if (locale === "en") return en_admin_users_dialog_delete_description(inputs)
28
- return zh_admin_users_dialog_delete_description(inputs)
29
- });
30
- export { admin_users_dialog_delete_description as "admin-users_dialog_delete_description" }
@@ -1,30 +0,0 @@
1
- /* eslint-disable */
2
- import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
-
4
- /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
-
6
- /** @typedef {{}} Admin_Users_Dialog_Delete_PlaceholderInputs */
7
-
8
- const zh_admin_users_dialog_delete_placeholder = /** @type {(inputs: Admin_Users_Dialog_Delete_PlaceholderInputs) => LocalizedString} */ () => {
9
- return /** @type {LocalizedString} */ (`输入用户名确认`)
10
- };
11
-
12
- const en_admin_users_dialog_delete_placeholder = /** @type {(inputs: Admin_Users_Dialog_Delete_PlaceholderInputs) => LocalizedString} */ () => {
13
- return /** @type {LocalizedString} */ (`Enter username to confirm`)
14
- };
15
-
16
- /**
17
- * | output |
18
- * | --- |
19
- * | "Enter username to confirm" |
20
- *
21
- * @param {Admin_Users_Dialog_Delete_PlaceholderInputs} inputs
22
- * @param {{ locale?: "zh" | "en" }} options
23
- * @returns {LocalizedString}
24
- */
25
- const admin_users_dialog_delete_placeholder = /** @type {((inputs?: Admin_Users_Dialog_Delete_PlaceholderInputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Dialog_Delete_PlaceholderInputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
- if (locale === "en") return en_admin_users_dialog_delete_placeholder(inputs)
28
- return zh_admin_users_dialog_delete_placeholder(inputs)
29
- });
30
- export { admin_users_dialog_delete_placeholder as "admin-users_dialog_delete_placeholder" }
@@ -1,30 +0,0 @@
1
- /* eslint-disable */
2
- import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
-
4
- /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
-
6
- /** @typedef {{}} Admin_Users_Dialog_Delete_TitleInputs */
7
-
8
- const zh_admin_users_dialog_delete_title = /** @type {(inputs: Admin_Users_Dialog_Delete_TitleInputs) => LocalizedString} */ () => {
9
- return /** @type {LocalizedString} */ (`确认删除用户`)
10
- };
11
-
12
- const en_admin_users_dialog_delete_title = /** @type {(inputs: Admin_Users_Dialog_Delete_TitleInputs) => LocalizedString} */ () => {
13
- return /** @type {LocalizedString} */ (`Confirm Delete User`)
14
- };
15
-
16
- /**
17
- * | output |
18
- * | --- |
19
- * | "Confirm Delete User" |
20
- *
21
- * @param {Admin_Users_Dialog_Delete_TitleInputs} inputs
22
- * @param {{ locale?: "zh" | "en" }} options
23
- * @returns {LocalizedString}
24
- */
25
- const admin_users_dialog_delete_title = /** @type {((inputs?: Admin_Users_Dialog_Delete_TitleInputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Dialog_Delete_TitleInputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
- if (locale === "en") return en_admin_users_dialog_delete_title(inputs)
28
- return zh_admin_users_dialog_delete_title(inputs)
29
- });
30
- export { admin_users_dialog_delete_title as "admin-users_dialog_delete_title" }
@@ -1,30 +0,0 @@
1
- /* eslint-disable */
2
- import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
-
4
- /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
-
6
- /** @typedef {{}} Admin_Users_Toast_Deletefailed1Inputs */
7
-
8
- const zh_admin_users_toast_deletefailed1 = /** @type {(inputs: Admin_Users_Toast_Deletefailed1Inputs) => LocalizedString} */ () => {
9
- return /** @type {LocalizedString} */ (`删除失败`)
10
- };
11
-
12
- const en_admin_users_toast_deletefailed1 = /** @type {(inputs: Admin_Users_Toast_Deletefailed1Inputs) => LocalizedString} */ () => {
13
- return /** @type {LocalizedString} */ (`Deletion failed`)
14
- };
15
-
16
- /**
17
- * | output |
18
- * | --- |
19
- * | "Deletion failed" |
20
- *
21
- * @param {Admin_Users_Toast_Deletefailed1Inputs} inputs
22
- * @param {{ locale?: "zh" | "en" }} options
23
- * @returns {LocalizedString}
24
- */
25
- const admin_users_toast_deletefailed1 = /** @type {((inputs?: Admin_Users_Toast_Deletefailed1Inputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Toast_Deletefailed1Inputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
- if (locale === "en") return en_admin_users_toast_deletefailed1(inputs)
28
- return zh_admin_users_toast_deletefailed1(inputs)
29
- });
30
- export { admin_users_toast_deletefailed1 as "admin-users_toast_deleteFailed" }
@@ -1,30 +0,0 @@
1
- /* eslint-disable */
2
- import { getLocale, experimentalStaticLocale } from '../runtime.js';
3
-
4
- /** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
5
-
6
- /** @typedef {{}} Admin_Users_Toast_Userdeleted1Inputs */
7
-
8
- const zh_admin_users_toast_userdeleted1 = /** @type {(inputs: Admin_Users_Toast_Userdeleted1Inputs) => LocalizedString} */ () => {
9
- return /** @type {LocalizedString} */ (`用户已删除`)
10
- };
11
-
12
- const en_admin_users_toast_userdeleted1 = /** @type {(inputs: Admin_Users_Toast_Userdeleted1Inputs) => LocalizedString} */ () => {
13
- return /** @type {LocalizedString} */ (`User deleted`)
14
- };
15
-
16
- /**
17
- * | output |
18
- * | --- |
19
- * | "User deleted" |
20
- *
21
- * @param {Admin_Users_Toast_Userdeleted1Inputs} inputs
22
- * @param {{ locale?: "zh" | "en" }} options
23
- * @returns {LocalizedString}
24
- */
25
- const admin_users_toast_userdeleted1 = /** @type {((inputs?: Admin_Users_Toast_Userdeleted1Inputs, options?: { locale?: "zh" | "en" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Admin_Users_Toast_Userdeleted1Inputs, { locale?: "zh" | "en" }, {}>} */ ((inputs = {}, options = {}) => {
26
- const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
27
- if (locale === "en") return en_admin_users_toast_userdeleted1(inputs)
28
- return zh_admin_users_toast_userdeleted1(inputs)
29
- });
30
- export { admin_users_toast_userdeleted1 as "admin-users_toast_userDeleted" }