mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
(feat:settings/docs) confirm on delete
This commit is contained in:
@@ -71,7 +71,8 @@
|
|||||||
"weekly": "Weekly",
|
"weekly": "Weekly",
|
||||||
"monthly": "Monthly"
|
"monthly": "Monthly"
|
||||||
},
|
},
|
||||||
"actions": "Actions"
|
"actions": "Actions",
|
||||||
|
"deleteWarning": "Are you sure you want to delete \"{{name}}\"?"
|
||||||
},
|
},
|
||||||
"apiKeys": {
|
"apiKeys": {
|
||||||
"label": "Chatbots",
|
"label": "Chatbots",
|
||||||
|
|||||||
@@ -71,7 +71,8 @@
|
|||||||
"weekly": "Semanal",
|
"weekly": "Semanal",
|
||||||
"monthly": "Mensual"
|
"monthly": "Mensual"
|
||||||
},
|
},
|
||||||
"actions": "Acciones"
|
"actions": "Acciones",
|
||||||
|
"deleteWarning": "¿Estás seguro de que deseas eliminar \"{{name}}\"?"
|
||||||
},
|
},
|
||||||
"apiKeys": {
|
"apiKeys": {
|
||||||
"label": "Chatbots",
|
"label": "Chatbots",
|
||||||
|
|||||||
@@ -70,7 +70,8 @@
|
|||||||
"weekly": "毎週",
|
"weekly": "毎週",
|
||||||
"monthly": "毎月"
|
"monthly": "毎月"
|
||||||
},
|
},
|
||||||
"actions": "アクション"
|
"actions": "アクション",
|
||||||
|
"deleteWarning": "\"{{name}}\"を削除してもよろしいですか?"
|
||||||
},
|
},
|
||||||
"apiKeys": {
|
"apiKeys": {
|
||||||
"label": "チャットボット",
|
"label": "チャットボット",
|
||||||
|
|||||||
@@ -71,7 +71,8 @@
|
|||||||
"weekly": "Еженедельно",
|
"weekly": "Еженедельно",
|
||||||
"monthly": "Ежемесячно"
|
"monthly": "Ежемесячно"
|
||||||
},
|
},
|
||||||
"actions": "Действия"
|
"actions": "Действия",
|
||||||
|
"deleteWarning": "Вы уверены, что хотите удалить \"{{name}}\"?"
|
||||||
},
|
},
|
||||||
"apiKeys": {
|
"apiKeys": {
|
||||||
"label": "API ключи",
|
"label": "API ключи",
|
||||||
|
|||||||
@@ -71,7 +71,8 @@
|
|||||||
"weekly": "每週",
|
"weekly": "每週",
|
||||||
"monthly": "每月"
|
"monthly": "每月"
|
||||||
},
|
},
|
||||||
"actions": "操作"
|
"actions": "操作",
|
||||||
|
"deleteWarning": "您確定要刪除 \"{{name}}\" 嗎?"
|
||||||
},
|
},
|
||||||
"apiKeys": {
|
"apiKeys": {
|
||||||
"label": "聊天機器人",
|
"label": "聊天機器人",
|
||||||
|
|||||||
@@ -71,7 +71,8 @@
|
|||||||
"weekly": "每周",
|
"weekly": "每周",
|
||||||
"monthly": "每月"
|
"monthly": "每月"
|
||||||
},
|
},
|
||||||
"actions": "操作"
|
"actions": "操作",
|
||||||
|
"deleteWarning": "您确定要删除 \"{{name}}\" 吗?"
|
||||||
},
|
},
|
||||||
"apiKeys": {
|
"apiKeys": {
|
||||||
"label": "聊天机器人",
|
"label": "聊天机器人",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { getDocs, getDocsWithPagination } from '../preferences/preferenceApi';
|
|||||||
import { setSourceDocs } from '../preferences/preferenceSlice';
|
import { setSourceDocs } from '../preferences/preferenceSlice';
|
||||||
import { setPaginatedDocuments } from '../preferences/preferenceSlice';
|
import { setPaginatedDocuments } from '../preferences/preferenceSlice';
|
||||||
import { formatDate } from '../utils/dateTimeUtils';
|
import { formatDate } from '../utils/dateTimeUtils';
|
||||||
|
import ConfirmationModal from '../modals/ConfirmationModal';
|
||||||
|
|
||||||
// Utility function to format numbers
|
// Utility function to format numbers
|
||||||
const formatTokens = (tokens: number): string => {
|
const formatTokens = (tokens: number): string => {
|
||||||
@@ -134,6 +135,26 @@ const Documents: React.FC<DocumentsProps> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [documentToDelete, setDocumentToDelete] = useState<{
|
||||||
|
index: number;
|
||||||
|
document: Doc;
|
||||||
|
} | null>(null);
|
||||||
|
const [deleteModalState, setDeleteModalState] =
|
||||||
|
useState<ActiveState>('INACTIVE');
|
||||||
|
|
||||||
|
const handleDeleteConfirmation = (index: number, document: Doc) => {
|
||||||
|
setDocumentToDelete({ index, document });
|
||||||
|
setDeleteModalState('ACTIVE');
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirmedDelete = () => {
|
||||||
|
if (documentToDelete) {
|
||||||
|
handleDeleteDocument(documentToDelete.index, documentToDelete.document);
|
||||||
|
setDeleteModalState('INACTIVE');
|
||||||
|
setDocumentToDelete(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refreshDocs(undefined, 1, rowsPerPage);
|
refreshDocs(undefined, 1, rowsPerPage);
|
||||||
}, [searchTerm]);
|
}, [searchTerm]);
|
||||||
@@ -182,10 +203,10 @@ const Documents: React.FC<DocumentsProps> = ({
|
|||||||
<div className="flex flex-col flex-grow">
|
<div className="flex flex-col flex-grow">
|
||||||
{' '}
|
{' '}
|
||||||
{/* Removed overflow-auto */}
|
{/* Removed overflow-auto */}
|
||||||
<div className="border rounded-md border-silver dark:border-silver/40">
|
<div className="border rounded-md border-gray-300 dark:border-silver/40 overflow-hidden">
|
||||||
<table className="w-full min-w-[640px] table-auto">
|
<table className="w-full min-w-[640px] table-auto">
|
||||||
<thead>
|
<thead>
|
||||||
<tr className="border-b border-silver dark:border-silver/40">
|
<tr className="border-b border-gray-300 dark:border-silver/40">
|
||||||
<th className="py-3 px-4 text-left text-xs font-medium text-sonic-silver uppercase w-[45%]">
|
<th className="py-3 px-4 text-left text-xs font-medium text-sonic-silver uppercase w-[45%]">
|
||||||
{t('settings.documents.name')}
|
{t('settings.documents.name')}
|
||||||
</th>
|
</th>
|
||||||
@@ -223,34 +244,34 @@ const Documents: React.FC<DocumentsProps> = ({
|
|||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="divide-y divide-silver dark:divide-silver/40">
|
<tbody className="divide-y divide-gray-300 dark:divide-silver/40">
|
||||||
{!currentDocuments?.length ? (
|
{!currentDocuments?.length ? (
|
||||||
<tr>
|
<tr>
|
||||||
<td
|
<td
|
||||||
colSpan={4}
|
colSpan={4}
|
||||||
className="py-4 text-center text-gray-700 dark:text-[#E0E0E0] bg-white dark:bg-transparent"
|
className="py-4 text-center text-gray-700 dark:text-[#E0E0E] bg-transparent"
|
||||||
>
|
>
|
||||||
{t('settings.documents.noData')}
|
{t('settings.documents.noData')}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
) : (
|
) : (
|
||||||
currentDocuments.map((document, index) => (
|
currentDocuments.map((document, index) => (
|
||||||
<tr key={index} className="bg-white dark:bg-transparent">
|
<tr key={index} className="group transition-colors">
|
||||||
<td
|
<td
|
||||||
className="py-4 px-4 text-sm text-gray-700 dark:text-[#E0E0E0] w-[45%] truncate"
|
className="py-4 px-4 text-sm text-gray-700 dark:text-[#E0E0E0] w-[45%] truncate group-hover:bg-gray-50 dark:group-hover:bg-gray-800/50"
|
||||||
title={document.name}
|
title={document.name}
|
||||||
>
|
>
|
||||||
{document.name}
|
{document.name}
|
||||||
</td>
|
</td>
|
||||||
<td className="py-4 px-4 text-center text-sm text-gray-700 dark:text-[#E0E0E0] whitespace-nowrap w-[20%]">
|
<td className="py-4 px-4 text-center text-sm text-gray-700 dark:text-[#E0E0E0] whitespace-nowrap w-[20%] group-hover:bg-gray-50 dark:group-hover:bg-gray-800/50">
|
||||||
{document.date ? formatDate(document.date) : ''}
|
{document.date ? formatDate(document.date) : ''}
|
||||||
</td>
|
</td>
|
||||||
<td className="py-4 px-4 text-center text-sm text-gray-700 dark:text-[#E0E0E0] whitespace-nowrap w-[25%]">
|
<td className="py-4 px-4 text-center text-sm text-gray-700 dark:text-[#E0E0E0] whitespace-nowrap w-[25%] group-hover:bg-gray-50 dark:group-hover:bg-gray-800/50">
|
||||||
{document.tokens
|
{document.tokens
|
||||||
? formatTokens(+document.tokens)
|
? formatTokens(+document.tokens)
|
||||||
: ''}
|
: ''}
|
||||||
</td>
|
</td>
|
||||||
<td className="py-4 px-4 text-right w-[10%]">
|
<td className="py-4 px-4 text-right w-[10%] group-hover:bg-gray-50 dark:group-hover:bg-gray-800/50">
|
||||||
<div className="flex items-center justify-end gap-3">
|
<div className="flex items-center justify-end gap-3">
|
||||||
{!document.syncFrequency && (
|
{!document.syncFrequency && (
|
||||||
<div className="w-8"></div>
|
<div className="w-8"></div>
|
||||||
@@ -269,7 +290,7 @@ const Documents: React.FC<DocumentsProps> = ({
|
|||||||
<button
|
<button
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
handleDeleteDocument(index, document);
|
handleDeleteConfirmation(index, document);
|
||||||
}}
|
}}
|
||||||
className="inline-flex items-center justify-center w-8 h-8 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors flex-shrink-0"
|
className="inline-flex items-center justify-center w-8 h-8 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors flex-shrink-0"
|
||||||
>
|
>
|
||||||
@@ -320,6 +341,22 @@ const Documents: React.FC<DocumentsProps> = ({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{deleteModalState === 'ACTIVE' && documentToDelete && (
|
||||||
|
<ConfirmationModal
|
||||||
|
message={t('settings.documents.deleteWarning', {
|
||||||
|
name: documentToDelete.document.name,
|
||||||
|
})}
|
||||||
|
modalState={deleteModalState}
|
||||||
|
setModalState={setDeleteModalState}
|
||||||
|
handleSubmit={handleConfirmedDelete}
|
||||||
|
handleCancel={() => {
|
||||||
|
setDeleteModalState('INACTIVE');
|
||||||
|
setDocumentToDelete(null);
|
||||||
|
}}
|
||||||
|
submitLabel={t('convTile.delete')}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ function Upload({
|
|||||||
isOnboarding,
|
isOnboarding,
|
||||||
renderTab = null,
|
renderTab = null,
|
||||||
close,
|
close,
|
||||||
onSuccessfulUpload,
|
onSuccessfulUpload = () => undefined,
|
||||||
}: {
|
}: {
|
||||||
receivedFile: File[];
|
receivedFile: File[];
|
||||||
setModalState: (state: ActiveState) => void;
|
setModalState: (state: ActiveState) => void;
|
||||||
isOnboarding: boolean;
|
isOnboarding: boolean;
|
||||||
renderTab: string | null;
|
renderTab: string | null;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
onSuccessfulUpload: () => void;
|
onSuccessfulUpload?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const [docName, setDocName] = useState(receivedFile[0]?.name);
|
const [docName, setDocName] = useState(receivedFile[0]?.name);
|
||||||
const [urlName, setUrlName] = useState('');
|
const [urlName, setUrlName] = useState('');
|
||||||
@@ -220,7 +220,7 @@ function Upload({
|
|||||||
setfiles([]);
|
setfiles([]);
|
||||||
setProgress(undefined);
|
setProgress(undefined);
|
||||||
setModalState('INACTIVE');
|
setModalState('INACTIVE');
|
||||||
onSuccessfulUpload();
|
onSuccessfulUpload?.();
|
||||||
}
|
}
|
||||||
} else if (data.status == 'PROGRESS') {
|
} else if (data.status == 'PROGRESS') {
|
||||||
setProgress(
|
setProgress(
|
||||||
|
|||||||
Reference in New Issue
Block a user