feat: add clear history button with confirmation on ArticleHistory page

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
master
oabrivard 3 months ago
parent 7f7d584314
commit 37bc849f92

@ -14,4 +14,7 @@ export const articleHistoryApi = {
getProvenance: (synthesisId: string): Promise<ArticleHistoryEntry[]> =>
api.get<ArticleHistoryEntry[]>(`/syntheses/${synthesisId}/provenance`),
clearAll: (): Promise<{ deleted: number }> =>
api.delete<{ deleted: number }>('/article-history'),
};

@ -348,6 +348,9 @@ const fr = {
'articleHistory.provenance': 'Provenance',
'articleHistory.provenanceEmpty': 'Aucune donnee de provenance disponible pour cette synthese.',
'articleHistory.provenanceDescription': 'Articles candidats traites lors de la generation de cette synthese.',
'articleHistory.clearAll': 'Effacer l\'historique',
'articleHistory.clearConfirm': 'Etes-vous sur de vouloir effacer tout l\'historique des articles ? Cette action est irreversible.',
'articleHistory.cleared': 'Historique efface',
// LLM Logs
'llmLogs.title': 'Logs des appels IA',

@ -55,6 +55,7 @@ const ArticleHistory: Component = () => {
const [filterStatus, setFilterStatus] = createSignal('');
const [filterSourceType, setFilterSourceType] = createSignal('');
const [page, setPage] = createSignal(0);
const [confirming, setConfirming] = createSignal(false);
const totalPages = () => Math.max(1, Math.ceil(total() / PAGE_SIZE));
@ -88,6 +89,22 @@ const ArticleHistory: Component = () => {
// Skip the initial run which is handled by onMount
});
const handleClear = async () => {
if (!confirming()) {
setConfirming(true);
setTimeout(() => setConfirming(false), 3000);
return;
}
try {
await articleHistoryApi.clearAll();
setConfirming(false);
setPage(0);
fetchHistory();
} catch (err) {
console.error('Failed to clear history', err);
}
};
const handleFilterChange = () => {
setPage(0);
fetchHistory();
@ -101,10 +118,20 @@ const ArticleHistory: Component = () => {
return (
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
{/* Page header */}
<div class="mb-6">
<div class="mb-6 flex items-center justify-between">
<h1 class="text-3xl font-bold text-gray-900">
{t('articleHistory.title')}
</h1>
<button
onClick={handleClear}
class={`px-3 py-1.5 text-sm rounded-md border ${
confirming()
? 'bg-red-600 text-white border-red-600'
: 'bg-white text-red-600 border-red-300 hover:bg-red-50'
}`}
>
{confirming() ? 'Confirmer' : t('articleHistory.clearAll')}
</button>
</div>
{/* Filters */}

Loading…
Cancel
Save