mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-19 03:54:19 +00:00
fix: ui bugs
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
|
DialogDescription,
|
||||||
} from '@/components/ui/dialog';
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Sidebar,
|
Sidebar,
|
||||||
@@ -21,7 +22,7 @@ import {
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
// import { httpClient } from '@/app/infra/http/HttpClient';
|
import { httpClient } from '@/app/infra/http/HttpClient';
|
||||||
// import { KnowledgeBase } from '@/app/infra/entities/api';
|
// import { KnowledgeBase } from '@/app/infra/entities/api';
|
||||||
import KBForm from '@/app/home/knowledge/components/kb-form/KBForm';
|
import KBForm from '@/app/home/knowledge/components/kb-form/KBForm';
|
||||||
import KBDoc from '@/app/home/knowledge/components/kb-docs/KBDoc';
|
import KBDoc from '@/app/home/knowledge/components/kb-docs/KBDoc';
|
||||||
@@ -50,7 +51,7 @@ export default function KBDetailDialog({
|
|||||||
const [kbId, setKbId] = useState<string | undefined>(propKbId);
|
const [kbId, setKbId] = useState<string | undefined>(propKbId);
|
||||||
const [activeMenu, setActiveMenu] = useState('metadata');
|
const [activeMenu, setActiveMenu] = useState('metadata');
|
||||||
const [fileId, setFileId] = useState<string | undefined>(undefined);
|
const [fileId, setFileId] = useState<string | undefined>(undefined);
|
||||||
// const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setKbId(propKbId);
|
setKbId(propKbId);
|
||||||
@@ -86,6 +87,13 @@ export default function KBDetailDialog({
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const confirmDelete = () => {
|
||||||
|
httpClient.deleteKnowledgeBase(kbId ?? '').then(() => {
|
||||||
|
onKbDeleted();
|
||||||
|
});
|
||||||
|
setShowDeleteConfirm(false);
|
||||||
|
};
|
||||||
|
|
||||||
if (!kbId) {
|
if (!kbId) {
|
||||||
// new kb
|
// new kb
|
||||||
return (
|
return (
|
||||||
@@ -187,7 +195,7 @@ export default function KBDetailDialog({
|
|||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
onClick={onKbDeleted}
|
onClick={() => setShowDeleteConfirm(true)}
|
||||||
>
|
>
|
||||||
{t('common.delete')}
|
{t('common.delete')}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -208,6 +216,29 @@ export default function KBDetailDialog({
|
|||||||
</SidebarProvider>
|
</SidebarProvider>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
{/* 删除确认对话框 */}
|
||||||
|
<Dialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>{t('common.confirmDelete')}</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
<div className="py-4">
|
||||||
|
{t('knowledge.deleteKnowledgeBaseConfirmation')}
|
||||||
|
</div>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => setShowDeleteConfirm(false)}
|
||||||
|
>
|
||||||
|
{t('common.cancel')}
|
||||||
|
</Button>
|
||||||
|
<Button variant="destructive" onClick={confirmDelete}>
|
||||||
|
{t('common.confirmDelete')}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -463,7 +463,9 @@ class HttpClient {
|
|||||||
uuid: string,
|
uuid: string,
|
||||||
file_id: string,
|
file_id: string,
|
||||||
): Promise<object> {
|
): Promise<object> {
|
||||||
return this.delete(`/api/v1/knowledge/bases/${uuid}/files/${file_id}`);
|
return this.post(`/api/v1/knowledge/bases/${uuid}/files`, {
|
||||||
|
file_id,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public getKnowledgeBaseFiles(
|
public getKnowledgeBaseFiles(
|
||||||
@@ -479,6 +481,10 @@ class HttpClient {
|
|||||||
return this.delete(`/api/v1/knowledge/bases/${uuid}/files/${file_id}`);
|
return this.delete(`/api/v1/knowledge/bases/${uuid}/files/${file_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public deleteKnowledgeBase(uuid: string): Promise<object> {
|
||||||
|
return this.delete(`/api/v1/knowledge/bases/${uuid}`);
|
||||||
|
}
|
||||||
|
|
||||||
// ============ Plugins API ============
|
// ============ Plugins API ============
|
||||||
public getPlugins(): Promise<ApiRespPlugins> {
|
public getPlugins(): Promise<ApiRespPlugins> {
|
||||||
return this.get('/api/v1/plugins');
|
return this.get('/api/v1/plugins');
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ const enUS = {
|
|||||||
documentsTab: {
|
documentsTab: {
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
status: 'Status',
|
status: 'Status',
|
||||||
noResults: 'No results',
|
noResults: 'No documents',
|
||||||
dragAndDrop: 'Drag and drop files here or click to upload',
|
dragAndDrop: 'Drag and drop files here or click to upload',
|
||||||
uploading: 'Uploading...',
|
uploading: 'Uploading...',
|
||||||
supportedFormats:
|
supportedFormats:
|
||||||
@@ -267,6 +267,8 @@ const enUS = {
|
|||||||
fileDeleteSuccess: 'File deleted successfully',
|
fileDeleteSuccess: 'File deleted successfully',
|
||||||
fileDeleteFailed: 'File deletion failed',
|
fileDeleteFailed: 'File deletion failed',
|
||||||
},
|
},
|
||||||
|
deleteKnowledgeBaseConfirmation:
|
||||||
|
'Are you sure you want to delete this knowledge base? All documents in this knowledge base will be deleted.',
|
||||||
},
|
},
|
||||||
register: {
|
register: {
|
||||||
title: 'Initialize LangBot 👋',
|
title: 'Initialize LangBot 👋',
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ const jaJP = {
|
|||||||
documentsTab: {
|
documentsTab: {
|
||||||
name: '名前',
|
name: '名前',
|
||||||
status: 'ステータス',
|
status: 'ステータス',
|
||||||
noResults: '結果がありません',
|
noResults: 'ドキュメントがありません',
|
||||||
dragAndDrop:
|
dragAndDrop:
|
||||||
'ファイルをここにドラッグ&ドロップするか、クリックしてアップロードしてください',
|
'ファイルをここにドラッグ&ドロップするか、クリックしてアップロードしてください',
|
||||||
uploading: 'アップロード中...',
|
uploading: 'アップロード中...',
|
||||||
@@ -265,7 +265,13 @@ const jaJP = {
|
|||||||
uploadSuccess: 'ファイルのアップロードに成功しました!',
|
uploadSuccess: 'ファイルのアップロードに成功しました!',
|
||||||
uploadError: 'ファイルのアップロードに失敗しました。再度お試しください',
|
uploadError: 'ファイルのアップロードに失敗しました。再度お試しください',
|
||||||
uploadingFile: 'ファイルをアップロード中...',
|
uploadingFile: 'ファイルをアップロード中...',
|
||||||
|
actions: 'アクション',
|
||||||
|
delete: 'ドキュメントを削除',
|
||||||
|
fileDeleteSuccess: 'ドキュメントの削除に成功しました',
|
||||||
|
fileDeleteFailed: 'ドキュメントの削除に失敗しました',
|
||||||
},
|
},
|
||||||
|
deleteKnowledgeBaseConfirmation:
|
||||||
|
'本当にこの知識ベースを削除しますか?この知識ベースに紐付けられたドキュメントは削除されます。',
|
||||||
},
|
},
|
||||||
register: {
|
register: {
|
||||||
title: 'LangBot を初期化 👋',
|
title: 'LangBot を初期化 👋',
|
||||||
|
|||||||
@@ -248,14 +248,20 @@ const zhHans = {
|
|||||||
documentsTab: {
|
documentsTab: {
|
||||||
name: '名称',
|
name: '名称',
|
||||||
status: '状态',
|
status: '状态',
|
||||||
noResults: '暂无结果',
|
noResults: '暂无文档',
|
||||||
dragAndDrop: '拖拽文件到此处或点击上传',
|
dragAndDrop: '拖拽文件到此处或点击上传',
|
||||||
uploading: '上传中...',
|
uploading: '上传中...',
|
||||||
supportedFormats: '支持 PDF、Word、TXT、Markdown 等文档格式',
|
supportedFormats: '支持 PDF、Word、TXT、Markdown 等文档格式',
|
||||||
uploadSuccess: '文件上传成功!',
|
uploadSuccess: '文件上传成功!',
|
||||||
uploadError: '文件上传失败,请重试',
|
uploadError: '文件上传失败,请重试',
|
||||||
uploadingFile: '上传文件中...',
|
uploadingFile: '上传文件中...',
|
||||||
|
actions: '操作',
|
||||||
|
delete: '删除文件',
|
||||||
|
fileDeleteSuccess: '文件删除成功',
|
||||||
|
fileDeleteFailed: '文件删除失败',
|
||||||
},
|
},
|
||||||
|
deleteKnowledgeBaseConfirmation:
|
||||||
|
'你确定要删除这个知识库吗?此知识库下的所有文档将被删除。',
|
||||||
},
|
},
|
||||||
register: {
|
register: {
|
||||||
title: '初始化 LangBot 👋',
|
title: '初始化 LangBot 👋',
|
||||||
|
|||||||
Reference in New Issue
Block a user