feat(wiki): implement folder management features in wiki API

Add new API functions for managing wiki folders, including creating, updating, deleting, and listing folders. Introduce a new WikiFolder interface to represent folder structure and enhance the WikiBrowser component with folder actions. Update internationalization strings for folder-related actions in English, Korean, Russian, and Chinese locales. Refactor existing code to accommodate folder hierarchy and improve user experience in the wiki browser.
This commit is contained in:
wizardchen
2026-06-16 23:48:35 +08:00
committed by lyingbug
parent 83eeec0ddf
commit e76738d054
24 changed files with 1903 additions and 399 deletions
+58 -17
View File
@@ -42,12 +42,27 @@ export interface WikiPageListResponse {
total_pages: number;
}
export interface WikiCategoryPathListResponse {
paths: { path: string[]; count: number }[];
total: number;
page: number;
page_size: number;
total_pages: number;
export interface WikiFolder {
id: string;
tenant_id: number;
knowledge_base_id: string;
parent_id: string;
name: string;
path: string;
depth: number;
sort_order: number;
created_at: string;
updated_at: string;
}
export interface WikiFolderNode extends WikiFolder {
page_count: number;
has_children: boolean;
}
export interface WikiFolderListResponse {
parent_id: string;
folders: WikiFolderNode[];
}
export interface WikiGraphMeta {
@@ -114,18 +129,44 @@ export function listWikiPages(kbId: string, params?: {
return get(`/api/v1/knowledgebase/${kbId}/wiki/pages${qs ? '?' + qs : ''}`);
}
export function listWikiCategories(kbId: string, params: {
page_type: string;
parent_path?: string;
page?: number;
page_size?: number;
}) {
// listWikiFolders returns the direct child folders of parentId ("" = root),
// each enriched with a recursive page_count and a has_children flag so the tree
// can render expand affordances and empty folders without a second request.
// pageTypes scopes the view to a sidebar tab: only folders whose subtree holds
// a page of those types (or are entirely empty) come back, and page_count is
// counted within those types.
export function listWikiFolders(kbId: string, parentId = '', pageTypes = '') {
const query = new URLSearchParams();
query.set('page_type', params.page_type);
if (params.parent_path) query.set('parent_path', params.parent_path);
if (params.page !== undefined) query.set('page', String(params.page));
if (params.page_size !== undefined) query.set('page_size', String(params.page_size));
return get(`/api/v1/knowledgebase/${kbId}/wiki/categories?${query.toString()}`);
if (parentId) query.set('parent_id', parentId);
if (pageTypes) query.set('page_types', pageTypes);
const qs = query.toString();
return get(`/api/v1/knowledgebase/${kbId}/wiki/folders${qs ? '?' + qs : ''}`);
}
// createWikiFolder creates a new empty folder under parentId ("" = root).
export function createWikiFolder(kbId: string, parentId: string, name: string) {
return post(`/api/v1/knowledgebase/${kbId}/wiki/folders`, { parent_id: parentId, name });
}
// updateWikiFolder renames and/or reparents a folder. Pass move_parent: true
// (and parent_id) to reparent; omit it for a pure rename.
export function updateWikiFolder(
kbId: string,
folderId: string,
data: { name?: string; parent_id?: string; move_parent?: boolean },
) {
return put(`/api/v1/knowledgebase/${kbId}/wiki/folders/${folderId}`, data);
}
// deleteWikiFolder removes an empty folder (no pages, no sub-folders).
export function deleteWikiFolder(kbId: string, folderId: string) {
return del(`/api/v1/knowledgebase/${kbId}/wiki/folders/${folderId}`);
}
// moveWikiPage relocates a page into folderId ("" = root). The slug is sent in
// the body because wiki slugs are hierarchical.
export function moveWikiPage(kbId: string, slug: string, folderId: string) {
return put(`/api/v1/knowledgebase/${kbId}/wiki/move-page`, { slug, folder_id: folderId });
}
export function createWikiPage(kbId: string, data: Partial<WikiPage>) {