@allbluecn/admin-app 0.3.8 → 0.5.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.
- package/package.json +3 -3
- package/src/components/admin/developer-log.tsx +2 -2
- package/src/components/dependency/dependency-table.tsx +21 -3
- package/src/components/invitations/invitations-page.tsx +16 -4
- package/src/components/knowledge/public/kp-crud-page.tsx +208 -0
- package/src/components/market/market-app-form.tsx +1 -1
- package/src/components/user/settings-profile.tsx +1 -1
- package/src/components/user/user-create-dialog.tsx +1 -1
- package/src/components/user/user-detail/user-detail-dialogs.tsx +9 -9
- package/src/paraglide/messages/_index.js +8 -8
- package/src/paraglide/messages/admin_invitations_filter_showdisabled1.js +30 -0
- package/src/paraglide/messages/admin_users_action_deactivate.js +30 -0
- package/src/paraglide/messages/admin_users_dialog_deactivate_confirm.js +30 -0
- package/src/paraglide/messages/admin_users_dialog_deactivate_description.js +30 -0
- package/src/paraglide/messages/admin_users_dialog_deactivate_placeholder.js +30 -0
- package/src/paraglide/messages/admin_users_dialog_deactivate_title.js +30 -0
- package/src/paraglide/messages/admin_users_toast_deactivatefailed1.js +30 -0
- package/src/paraglide/messages/admin_users_toast_userdeactivated1.js +30 -0
- package/src/routes/_nav/knowledge-public/bookmarks/route.lazy.tsx +36 -111
- package/src/routes/_nav/knowledge-public/compliance/route.lazy.tsx +29 -105
- package/src/routes/_nav/knowledge-public/legal/route.lazy.tsx +30 -108
- package/src/routes/_nav/monitoring/errors/route.lazy.tsx +1 -1
- package/src/routes/_nav/monitoring/logs/route.lazy.tsx +1 -1
- package/src/routes/_nav/monitoring/metrics/route.lazy.tsx +1 -1
- package/src/routes/_nav/permissions/route.lazy.tsx +1 -1
- package/src/routes/_nav/sso/route.lazy.tsx +1 -1
- package/src/routes/_nav/users/$userId/route.lazy.tsx +10 -10
- package/src/server/knowledge/public/kp-factory.ts +134 -0
- package/src/server/serverFns/dependency/sync.ts +2 -2
- package/src/server/serverFns/knowledge/public/bookmarks/create.ts +23 -25
- package/src/server/serverFns/knowledge/public/bookmarks/delete.ts +2 -14
- package/src/server/serverFns/knowledge/public/bookmarks/detail.ts +2 -11
- package/src/server/serverFns/knowledge/public/bookmarks/list.ts +32 -38
- package/src/server/serverFns/knowledge/public/bookmarks/update.ts +23 -22
- package/src/server/serverFns/knowledge/public/compliance/create.ts +10 -15
- package/src/server/serverFns/knowledge/public/compliance/delete.ts +2 -14
- package/src/server/serverFns/knowledge/public/compliance/detail.ts +2 -11
- package/src/server/serverFns/knowledge/public/compliance/list.ts +24 -31
- package/src/server/serverFns/knowledge/public/compliance/update.ts +22 -22
- package/src/server/serverFns/knowledge/public/legal/create.ts +11 -15
- package/src/server/serverFns/knowledge/public/legal/delete.ts +2 -14
- package/src/server/serverFns/knowledge/public/legal/detail.ts +2 -11
- package/src/server/serverFns/knowledge/public/legal/list.ts +24 -32
- package/src/server/serverFns/knowledge/public/legal/update.ts +20 -22
- package/src/server/serverFns/user/{delete.ts → deactivate.ts} +2 -2
- package/src/paraglide/messages/admin_users_dialog_delete_confirm.js +0 -30
- package/src/paraglide/messages/admin_users_dialog_delete_description.js +0 -30
- package/src/paraglide/messages/admin_users_dialog_delete_placeholder.js +0 -30
- package/src/paraglide/messages/admin_users_dialog_delete_title.js +0 -30
- package/src/paraglide/messages/admin_users_toast_deletefailed1.js +0 -30
- package/src/paraglide/messages/admin_users_toast_userdeleted1.js +0 -30
- package/src/paraglide/messages/common_button_cancel.js +0 -29
- package/src/paraglide/messages/common_dependency_table_pagination_total.js +0 -29
|
@@ -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" }
|
|
@@ -15,14 +15,12 @@
|
|
|
15
15
|
// You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
|
|
18
|
-
import { createLazyFileRoute
|
|
18
|
+
import { createLazyFileRoute } from '@tanstack/react-router'
|
|
19
19
|
import { m } from '@/paraglide/messages.js'
|
|
20
|
-
import {
|
|
20
|
+
import { useState, useTransition } from 'react'
|
|
21
21
|
import {
|
|
22
|
-
PlusIcon,
|
|
23
22
|
PencilIcon,
|
|
24
23
|
Trash2Icon,
|
|
25
|
-
SearchIcon,
|
|
26
24
|
StarIcon,
|
|
27
25
|
RefreshCwIcon,
|
|
28
26
|
ExternalLinkIcon,
|
|
@@ -33,9 +31,8 @@ import {
|
|
|
33
31
|
BookOpen,
|
|
34
32
|
type LucideIcon,
|
|
35
33
|
} from 'lucide-react'
|
|
36
|
-
import {
|
|
34
|
+
import { type AdminColumnDef } from '@/components/data-table/data-table'
|
|
37
35
|
import { Button } from '@/components/ui/button'
|
|
38
|
-
import { Input } from '@/components/ui/input'
|
|
39
36
|
import { Badge } from '@/components/ui/badge'
|
|
40
37
|
import { ConfirmDialog } from '@/components/confirm-dialog'
|
|
41
38
|
import { toast } from '@/components/ui/toast'
|
|
@@ -46,6 +43,7 @@ import {
|
|
|
46
43
|
type BookmarkRow,
|
|
47
44
|
} from '@/components/knowledge/public/bookmark-form-dialog'
|
|
48
45
|
import { adminDeleteBookmarkFn } from '@/server/serverFns/knowledge/public/bookmarks/delete'
|
|
46
|
+
import { KpCrudShell, useKpCrud } from '@/components/knowledge/public/kp-crud-page'
|
|
49
47
|
import { adminSyncAllGithubFn } from '@/server/serverFns/knowledge/public/bookmarks/sync-all-github'
|
|
50
48
|
|
|
51
49
|
const categoryIconMap: Record<string, LucideIcon> = {
|
|
@@ -83,55 +81,17 @@ function BookmarksPage() {
|
|
|
83
81
|
const { items: rawItems, total } = Route.useLoaderData()
|
|
84
82
|
const items = rawItems as BookmarkRow[]
|
|
85
83
|
const { search } = Route.useSearch()
|
|
86
|
-
const navigate = useNavigate()
|
|
87
|
-
const router = useRouter()
|
|
88
84
|
const locale = Route.useRouteContext().locale
|
|
89
|
-
const [searchInput, setSearchInput] = useState(search ?? '')
|
|
90
|
-
const [formOpen, setFormOpen] = useState(false)
|
|
91
|
-
const [editing, setEditing] = useState<BookmarkRow | null>(null)
|
|
92
|
-
const [deleting, setDeleting] = useState<BookmarkRow | null>(null)
|
|
93
|
-
const [deletePending, startDelete] = useTransition()
|
|
94
85
|
const [syncing, startSync] = useTransition()
|
|
95
86
|
const [syncConfirmOpen, setSyncConfirmOpen] = useState(false)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function applySearch() {
|
|
107
|
-
navigate({
|
|
108
|
-
to: '/knowledge-public/bookmarks',
|
|
109
|
-
search: (s) => ({ ...s, search: searchInput.trim() || undefined }),
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function openCreate() {
|
|
114
|
-
setEditing(null)
|
|
115
|
-
setFormOpen(true)
|
|
116
|
-
}
|
|
117
|
-
function openEdit(row: BookmarkRow) {
|
|
118
|
-
setEditing(row)
|
|
119
|
-
setFormOpen(true)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function confirmDelete() {
|
|
123
|
-
if (!deleting) return
|
|
124
|
-
startDelete(async () => {
|
|
125
|
-
try {
|
|
126
|
-
await adminDeleteBookmarkFn({ data: { id: deleting.id } })
|
|
127
|
-
toast.success(m.common_knowledgePublic_bookmarks_deleted())
|
|
128
|
-
setDeleting(null)
|
|
129
|
-
refresh()
|
|
130
|
-
} catch (err) {
|
|
131
|
-
toast.error(err instanceof Error ? err.message : m.common_common_deleteFailed())
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
}
|
|
87
|
+
// S34:状态机与页面 chrome 收敛到共享骨架,页面只保留列定义与域内对话框
|
|
88
|
+
const crud = useKpCrud<BookmarkRow>({
|
|
89
|
+
routePath: '/knowledge-public/bookmarks',
|
|
90
|
+
search,
|
|
91
|
+
deleteFn: (row) => adminDeleteBookmarkFn({ data: { id: row.id } }),
|
|
92
|
+
deleteSuccessToast: m.common_knowledgePublic_bookmarks_deleted(),
|
|
93
|
+
})
|
|
94
|
+
const { openEdit, setDeleting } = crud
|
|
135
95
|
|
|
136
96
|
// 全量强制同步是批量外呼昂贵操作,收进 ConfirmDialog 二次确认(与删除操作同级防护)
|
|
137
97
|
function syncAllGithub() {
|
|
@@ -142,7 +102,7 @@ function BookmarksPage() {
|
|
|
142
102
|
m.common_knowledgePublic_bookmarks_syncComplete({ total: res.total, success: res.success, failed: res.failed }),
|
|
143
103
|
)
|
|
144
104
|
setSyncConfirmOpen(false)
|
|
145
|
-
refresh()
|
|
105
|
+
crud.refresh()
|
|
146
106
|
} catch (err) {
|
|
147
107
|
toast.error(err instanceof Error ? err.message : m.common_knowledgePublic_bookmarks_syncFailed())
|
|
148
108
|
}
|
|
@@ -281,51 +241,29 @@ function BookmarksPage() {
|
|
|
281
241
|
]
|
|
282
242
|
|
|
283
243
|
return (
|
|
284
|
-
<
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
<div className="flex items-center gap-2">
|
|
303
|
-
<div className="relative max-w-sm flex-1">
|
|
304
|
-
<SearchIcon className="absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground" />
|
|
305
|
-
<Input
|
|
306
|
-
value={searchInput}
|
|
307
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSearchInput(e.target.value)}
|
|
308
|
-
onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
309
|
-
if (e.key === 'Enter') applySearch()
|
|
310
|
-
}}
|
|
311
|
-
placeholder={m.common_knowledgePublic_bookmarks_placeholder()}
|
|
312
|
-
className="pl-8"
|
|
313
|
-
/>
|
|
314
|
-
</div>
|
|
315
|
-
<Button variant="outline" onClick={applySearch}>
|
|
316
|
-
{m.common_common_search()}
|
|
244
|
+
<KpCrudShell
|
|
245
|
+
title={m.common_knowledgePublic_bookmarks_title()}
|
|
246
|
+
subtitle={m.common_knowledgePublic_bookmarks_subtitle({ total })}
|
|
247
|
+
createLabel={m.common_common_create()}
|
|
248
|
+
searchPlaceholder={m.common_knowledgePublic_bookmarks_placeholder()}
|
|
249
|
+
total={total}
|
|
250
|
+
items={items}
|
|
251
|
+
columns={columns}
|
|
252
|
+
crud={crud}
|
|
253
|
+
deleteConfirmTitle={m.common_knowledgePublic_bookmarks_deleteConfirmTitle()}
|
|
254
|
+
deleteConfirmDescription={m.common_knowledgePublic_bookmarks_deleteConfirmDesc({
|
|
255
|
+
title: crud.deleting?.title ?? '',
|
|
256
|
+
})}
|
|
257
|
+
headerActions={
|
|
258
|
+
<Button variant="outline" onClick={() => setSyncConfirmOpen(true)} disabled={syncing}>
|
|
259
|
+
<RefreshCwIcon className={`mr-1 size-4 ${syncing ? 'animate-spin' : ''}`} />
|
|
260
|
+
{syncing ? m.common_knowledgePublic_bookmarks_syncing() : m.common_knowledgePublic_bookmarks_syncGithub()}
|
|
317
261
|
</Button>
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
open={formOpen}
|
|
324
|
-
onOpenChange={setFormOpen}
|
|
325
|
-
item={editing}
|
|
326
|
-
onSuccess={refresh}
|
|
327
|
-
/>
|
|
328
|
-
|
|
262
|
+
}
|
|
263
|
+
renderFormDialog={({ open, editing, onOpenChange, onSuccess }) => (
|
|
264
|
+
<BookmarkFormDialog open={open} onOpenChange={onOpenChange} item={editing} onSuccess={onSuccess} />
|
|
265
|
+
)}
|
|
266
|
+
>
|
|
329
267
|
<ConfirmDialog
|
|
330
268
|
open={syncConfirmOpen}
|
|
331
269
|
onOpenChange={setSyncConfirmOpen}
|
|
@@ -337,19 +275,6 @@ function BookmarksPage() {
|
|
|
337
275
|
cancelDisabled={syncing}
|
|
338
276
|
onConfirm={syncAllGithub}
|
|
339
277
|
/>
|
|
340
|
-
|
|
341
|
-
<ConfirmDialog
|
|
342
|
-
open={!!deleting}
|
|
343
|
-
onOpenChange={(o: boolean) => !o && setDeleting(null)}
|
|
344
|
-
title={m.common_knowledgePublic_bookmarks_deleteConfirmTitle()}
|
|
345
|
-
description={m.common_knowledgePublic_bookmarks_deleteConfirmDesc({ title: deleting?.title ?? '' })}
|
|
346
|
-
cancelLabel={m.common_common_cancel()}
|
|
347
|
-
confirmLabel={deletePending ? m.common_common_deleting() : m.common_common_delete()}
|
|
348
|
-
confirmClassName="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
349
|
-
confirmDisabled={deletePending}
|
|
350
|
-
cancelDisabled={deletePending}
|
|
351
|
-
onConfirm={confirmDelete}
|
|
352
|
-
/>
|
|
353
|
-
</div>
|
|
278
|
+
</KpCrudShell>
|
|
354
279
|
)
|
|
355
280
|
}
|
|
@@ -15,16 +15,12 @@
|
|
|
15
15
|
// You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
|
|
18
|
-
import { createLazyFileRoute
|
|
18
|
+
import { createLazyFileRoute } from '@tanstack/react-router'
|
|
19
19
|
import { m } from '@/paraglide/messages.js'
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { DataTable, type AdminColumnDef } from '@/components/data-table/data-table'
|
|
20
|
+
import { PencilIcon, Trash2Icon } from 'lucide-react'
|
|
21
|
+
import { type AdminColumnDef } from '@/components/data-table/data-table'
|
|
23
22
|
import { Button } from '@/components/ui/button'
|
|
24
|
-
import { Input } from '@/components/ui/input'
|
|
25
23
|
import { Badge } from '@/components/ui/badge'
|
|
26
|
-
import { ConfirmDialog } from '@/components/confirm-dialog'
|
|
27
|
-
import { toast } from '@/components/ui/toast'
|
|
28
24
|
import { RoutePending } from '@/components/admin/route-pending'
|
|
29
25
|
import { formatDate } from '@/lib/format-date'
|
|
30
26
|
import {
|
|
@@ -32,6 +28,7 @@ import {
|
|
|
32
28
|
type ComplianceRow,
|
|
33
29
|
} from '@/components/knowledge/public/compliance-form-dialog'
|
|
34
30
|
import { adminDeleteComplianceFn } from '@/server/serverFns/knowledge/public/compliance/delete'
|
|
31
|
+
import { KpCrudShell, useKpCrud } from '@/components/knowledge/public/kp-crud-page'
|
|
35
32
|
|
|
36
33
|
export const Route = createLazyFileRoute('/_nav/knowledge-public/compliance')({
|
|
37
34
|
pendingComponent: RoutePending,
|
|
@@ -44,53 +41,15 @@ function CompliancePage() {
|
|
|
44
41
|
const { items: rawItems, total } = Route.useLoaderData()
|
|
45
42
|
const items = rawItems as ComplianceRow[]
|
|
46
43
|
const { search } = Route.useSearch()
|
|
47
|
-
const navigate = useNavigate()
|
|
48
|
-
const router = useRouter()
|
|
49
44
|
const locale = Route.useRouteContext().locale
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
setSearchInput(search ?? '')
|
|
59
|
-
}, [search])
|
|
60
|
-
|
|
61
|
-
function refresh() {
|
|
62
|
-
router.invalidate()
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function applySearch() {
|
|
66
|
-
navigate({
|
|
67
|
-
to: '/knowledge-public/compliance',
|
|
68
|
-
search: (s) => ({ ...s, search: searchInput.trim() || undefined }),
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function openCreate() {
|
|
73
|
-
setEditing(null)
|
|
74
|
-
setFormOpen(true)
|
|
75
|
-
}
|
|
76
|
-
function openEdit(row: ComplianceRow) {
|
|
77
|
-
setEditing(row)
|
|
78
|
-
setFormOpen(true)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function confirmDelete() {
|
|
82
|
-
if (!deleting) return
|
|
83
|
-
startDelete(async () => {
|
|
84
|
-
try {
|
|
85
|
-
await adminDeleteComplianceFn({ data: { id: deleting.id } })
|
|
86
|
-
toast.success(m.common_knowledgePublic_compliance_deleted())
|
|
87
|
-
setDeleting(null)
|
|
88
|
-
refresh()
|
|
89
|
-
} catch (err) {
|
|
90
|
-
toast.error(err instanceof Error ? err.message : m.common_common_deleteFailed())
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
}
|
|
45
|
+
// S34:状态机与页面 chrome 收敛到共享骨架,页面只保留列定义与域内对话框
|
|
46
|
+
const crud = useKpCrud<ComplianceRow>({
|
|
47
|
+
routePath: '/knowledge-public/compliance',
|
|
48
|
+
search,
|
|
49
|
+
deleteFn: (row) => adminDeleteComplianceFn({ data: { id: row.id } }),
|
|
50
|
+
deleteSuccessToast: m.common_knowledgePublic_compliance_deleted(),
|
|
51
|
+
})
|
|
52
|
+
const { openEdit, setDeleting } = crud
|
|
94
53
|
|
|
95
54
|
const columns: AdminColumnDef<ComplianceRow>[] = [
|
|
96
55
|
{
|
|
@@ -174,57 +133,22 @@ function CompliancePage() {
|
|
|
174
133
|
]
|
|
175
134
|
|
|
176
135
|
return (
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSearchInput(e.target.value)}
|
|
195
|
-
onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
196
|
-
if (e.key === 'Enter') applySearch()
|
|
197
|
-
}}
|
|
198
|
-
placeholder={m.common_knowledgePublic_compliance_placeholder()}
|
|
199
|
-
className="pl-8"
|
|
200
|
-
/>
|
|
201
|
-
</div>
|
|
202
|
-
<Button variant="outline" onClick={applySearch}>
|
|
203
|
-
{m.common_common_search()}
|
|
204
|
-
</Button>
|
|
205
|
-
</div>
|
|
206
|
-
|
|
207
|
-
<DataTable columns={columns} data={items} />
|
|
208
|
-
|
|
209
|
-
<ComplianceFormDialog
|
|
210
|
-
open={formOpen}
|
|
211
|
-
onOpenChange={setFormOpen}
|
|
212
|
-
item={editing}
|
|
213
|
-
onSuccess={refresh}
|
|
214
|
-
/>
|
|
215
|
-
|
|
216
|
-
<ConfirmDialog
|
|
217
|
-
open={!!deleting}
|
|
218
|
-
onOpenChange={(o: boolean) => !o && setDeleting(null)}
|
|
219
|
-
title={m.common_knowledgePublic_compliance_deleteConfirmTitle()}
|
|
220
|
-
description={m.common_knowledgePublic_compliance_deleteConfirmDesc({ title: deleting?.title ?? '' })}
|
|
221
|
-
cancelLabel={m.common_common_cancel()}
|
|
222
|
-
confirmLabel={deletePending ? m.common_common_deleting() : m.common_common_delete()}
|
|
223
|
-
confirmClassName="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
224
|
-
confirmDisabled={deletePending}
|
|
225
|
-
cancelDisabled={deletePending}
|
|
226
|
-
onConfirm={confirmDelete}
|
|
227
|
-
/>
|
|
228
|
-
</div>
|
|
136
|
+
<KpCrudShell
|
|
137
|
+
title={m.common_knowledgePublic_compliance_title()}
|
|
138
|
+
subtitle={m.common_knowledgePublic_compliance_subtitle({ total })}
|
|
139
|
+
createLabel={m.common_common_create()}
|
|
140
|
+
searchPlaceholder={m.common_knowledgePublic_compliance_placeholder()}
|
|
141
|
+
total={total}
|
|
142
|
+
items={items}
|
|
143
|
+
columns={columns}
|
|
144
|
+
crud={crud}
|
|
145
|
+
deleteConfirmTitle={m.common_knowledgePublic_compliance_deleteConfirmTitle()}
|
|
146
|
+
deleteConfirmDescription={m.common_knowledgePublic_compliance_deleteConfirmDesc({
|
|
147
|
+
title: crud.deleting?.title ?? '',
|
|
148
|
+
})}
|
|
149
|
+
renderFormDialog={({ open, editing, onOpenChange, onSuccess }) => (
|
|
150
|
+
<ComplianceFormDialog open={open} onOpenChange={onOpenChange} item={editing} onSuccess={onSuccess} />
|
|
151
|
+
)}
|
|
152
|
+
/>
|
|
229
153
|
)
|
|
230
154
|
}
|
|
@@ -15,20 +15,17 @@
|
|
|
15
15
|
// You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
|
|
18
|
-
import { createLazyFileRoute
|
|
18
|
+
import { createLazyFileRoute } from '@tanstack/react-router'
|
|
19
19
|
import { m } from '@/paraglide/messages.js'
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { DataTable, type AdminColumnDef } from '@/components/data-table/data-table'
|
|
20
|
+
import { PencilIcon, Trash2Icon } from 'lucide-react'
|
|
21
|
+
import { type AdminColumnDef } from '@/components/data-table/data-table'
|
|
23
22
|
import { Button } from '@/components/ui/button'
|
|
24
|
-
import { Input } from '@/components/ui/input'
|
|
25
23
|
import { Badge } from '@/components/ui/badge'
|
|
26
|
-
import { ConfirmDialog } from '@/components/confirm-dialog'
|
|
27
|
-
import { toast } from '@/components/ui/toast'
|
|
28
24
|
import { RoutePending } from '@/components/admin/route-pending'
|
|
29
25
|
import { formatDate } from '@/lib/format-date'
|
|
30
26
|
import { LegalFormDialog, type LegalRow } from '@/components/knowledge/public/legal-form-dialog'
|
|
31
27
|
import { adminDeleteLegalFn } from '@/server/serverFns/knowledge/public/legal/delete'
|
|
28
|
+
import { KpCrudShell, useKpCrud } from '@/components/knowledge/public/kp-crud-page'
|
|
32
29
|
|
|
33
30
|
export const Route = createLazyFileRoute('/_nav/knowledge-public/legal')({
|
|
34
31
|
pendingComponent: RoutePending,
|
|
@@ -41,55 +38,15 @@ function LegalPage() {
|
|
|
41
38
|
const { items: rawItems, total } = Route.useLoaderData()
|
|
42
39
|
const items = rawItems as LegalRow[]
|
|
43
40
|
const { search } = Route.useSearch()
|
|
44
|
-
const navigate = useNavigate()
|
|
45
|
-
const router = useRouter()
|
|
46
41
|
const locale = Route.useRouteContext().locale
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
setSearchInput(search ?? '')
|
|
56
|
-
}, [search])
|
|
57
|
-
|
|
58
|
-
function refresh() {
|
|
59
|
-
router.invalidate()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function applySearch() {
|
|
63
|
-
navigate({
|
|
64
|
-
to: '/knowledge-public/legal',
|
|
65
|
-
search: (s) => ({ ...s, search: searchInput.trim() || undefined }),
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function openCreate() {
|
|
70
|
-
setEditing(null)
|
|
71
|
-
setFormOpen(true)
|
|
72
|
-
}
|
|
73
|
-
function openEdit(row: LegalRow) {
|
|
74
|
-
setEditing(row)
|
|
75
|
-
setFormOpen(true)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function confirmDelete() {
|
|
79
|
-
if (!deleting) return
|
|
80
|
-
startDelete(async () => {
|
|
81
|
-
try {
|
|
82
|
-
await adminDeleteLegalFn({ data: { id: deleting.id } })
|
|
83
|
-
// 传被删条目标题的专用文案;此前 name 参数误传「司法辖区」字段标签,
|
|
84
|
-
// 提示形如「已删除 司法辖区」,与实际删除对象无关
|
|
85
|
-
toast.success(m.common_knowledgePublic_legal_deleted())
|
|
86
|
-
setDeleting(null)
|
|
87
|
-
refresh()
|
|
88
|
-
} catch (err) {
|
|
89
|
-
toast.error(err instanceof Error ? err.message : m.common_common_deleteFailed())
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
}
|
|
42
|
+
// S34:状态机与页面 chrome 收敛到共享骨架,页面只保留列定义与域内对话框
|
|
43
|
+
const crud = useKpCrud<LegalRow>({
|
|
44
|
+
routePath: '/knowledge-public/legal',
|
|
45
|
+
search,
|
|
46
|
+
deleteFn: (row) => adminDeleteLegalFn({ data: { id: row.id } }),
|
|
47
|
+
deleteSuccessToast: m.common_knowledgePublic_legal_deleted(),
|
|
48
|
+
})
|
|
49
|
+
const { openEdit, setDeleting } = crud
|
|
93
50
|
|
|
94
51
|
const columns: AdminColumnDef<LegalRow>[] = [
|
|
95
52
|
{
|
|
@@ -173,57 +130,22 @@ function LegalPage() {
|
|
|
173
130
|
]
|
|
174
131
|
|
|
175
132
|
return (
|
|
176
|
-
<
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSearchInput(e.target.value)}
|
|
194
|
-
onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
195
|
-
if (e.key === 'Enter') applySearch()
|
|
196
|
-
}}
|
|
197
|
-
placeholder={m.common_knowledgePublic_legal_placeholder()}
|
|
198
|
-
className="pl-8"
|
|
199
|
-
/>
|
|
200
|
-
</div>
|
|
201
|
-
<Button variant="outline" onClick={applySearch}>
|
|
202
|
-
{m.common_common_search()}
|
|
203
|
-
</Button>
|
|
204
|
-
</div>
|
|
205
|
-
|
|
206
|
-
<DataTable columns={columns} data={items} />
|
|
207
|
-
|
|
208
|
-
<LegalFormDialog
|
|
209
|
-
open={formOpen}
|
|
210
|
-
onOpenChange={setFormOpen}
|
|
211
|
-
item={editing}
|
|
212
|
-
onSuccess={refresh}
|
|
213
|
-
/>
|
|
214
|
-
|
|
215
|
-
<ConfirmDialog
|
|
216
|
-
open={!!deleting}
|
|
217
|
-
onOpenChange={(o: boolean) => !o && setDeleting(null)}
|
|
218
|
-
title={m.common_knowledgePublic_legal_deleteConfirmTitle()}
|
|
219
|
-
description={m.common_knowledgePublic_legal_deleteConfirmDesc({ title: deleting?.title ?? '' })}
|
|
220
|
-
cancelLabel={m.common_common_cancel()}
|
|
221
|
-
confirmLabel={deletePending ? m.common_common_deleting() : m.common_common_delete()}
|
|
222
|
-
confirmClassName="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
223
|
-
confirmDisabled={deletePending}
|
|
224
|
-
cancelDisabled={deletePending}
|
|
225
|
-
onConfirm={confirmDelete}
|
|
226
|
-
/>
|
|
227
|
-
</div>
|
|
133
|
+
<KpCrudShell
|
|
134
|
+
title={m.common_knowledgePublic_legal_title()}
|
|
135
|
+
subtitle={m.common_knowledgePublic_legal_subtitle({ total })}
|
|
136
|
+
createLabel={m.common_common_create()}
|
|
137
|
+
searchPlaceholder={m.common_knowledgePublic_legal_placeholder()}
|
|
138
|
+
total={total}
|
|
139
|
+
items={items}
|
|
140
|
+
columns={columns}
|
|
141
|
+
crud={crud}
|
|
142
|
+
deleteConfirmTitle={m.common_knowledgePublic_legal_deleteConfirmTitle()}
|
|
143
|
+
deleteConfirmDescription={m.common_knowledgePublic_legal_deleteConfirmDesc({
|
|
144
|
+
title: crud.deleting?.title ?? '',
|
|
145
|
+
})}
|
|
146
|
+
renderFormDialog={({ open, editing, onOpenChange, onSuccess }) => (
|
|
147
|
+
<LegalFormDialog open={open} onOpenChange={onOpenChange} item={editing} onSuccess={onSuccess} />
|
|
148
|
+
)}
|
|
149
|
+
/>
|
|
228
150
|
)
|
|
229
|
-
}
|
|
151
|
+
}
|
|
@@ -76,7 +76,7 @@ function MonitoringErrors() {
|
|
|
76
76
|
onOpenChange={setConfirmResetOpen}
|
|
77
77
|
title={m.common_monitoring_errors_clearConfirm_title()}
|
|
78
78
|
description={m.common_monitoring_errors_clearConfirm_description()}
|
|
79
|
-
cancelLabel={m.
|
|
79
|
+
cancelLabel={m.common_common_cancel()}
|
|
80
80
|
confirmLabel={m.common_button_confirm()}
|
|
81
81
|
confirmVariant="destructive"
|
|
82
82
|
onConfirm={() => void handleReset()}
|
|
@@ -166,7 +166,7 @@ function MonitoringLogs() {
|
|
|
166
166
|
onOpenChange={setConfirmClearOpen}
|
|
167
167
|
title={m.common_monitoring_logs_clearConfirm_title()}
|
|
168
168
|
description={m.common_monitoring_logs_clearConfirm_description()}
|
|
169
|
-
cancelLabel={m.
|
|
169
|
+
cancelLabel={m.common_common_cancel()}
|
|
170
170
|
confirmLabel={m.common_button_confirm()}
|
|
171
171
|
confirmVariant="destructive"
|
|
172
172
|
onConfirm={() => void handleClearOld()}
|
|
@@ -81,7 +81,7 @@ function MonitoringMetrics() {
|
|
|
81
81
|
onOpenChange={setConfirmResetOpen}
|
|
82
82
|
title={m.common_monitoring_metrics_clearConfirm_title()}
|
|
83
83
|
description={m.common_monitoring_metrics_clearConfirm_description()}
|
|
84
|
-
cancelLabel={m.
|
|
84
|
+
cancelLabel={m.common_common_cancel()}
|
|
85
85
|
confirmLabel={m.common_button_confirm()}
|
|
86
86
|
confirmVariant="destructive"
|
|
87
87
|
onConfirm={() => void handleReset()}
|