feat(documents): enhance document page with alert for content extraction details (#249)

This commit is contained in:
Corentin Thomasset
2025-04-22 21:26:48 +02:00
committed by GitHub
parent 38aa1ea7f1
commit 5fe401778d
2 changed files with 11 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ import { queryClient } from '@/modules/shared/query/query-client';
import { DocumentTagPicker } from '@/modules/tags/components/tag-picker.component';
import { CreateTagModal } from '@/modules/tags/pages/tags.page';
import { addTagToDocument, removeTagFromDocument } from '@/modules/tags/tags.services';
import { Alert } from '@/modules/ui/components/alert';
import { Alert, AlertDescription } from '@/modules/ui/components/alert';
import { Button } from '@/modules/ui/components/button';
import { Separator } from '@/modules/ui/components/separator';
import { createToast } from '@/modules/ui/components/sonner';
@@ -231,7 +231,7 @@ export const DocumentPage: Component = () => {
<Separator class="my-3" />
<Tabs defaultValue="info" class="w-full">
<Tabs defaultValue="info" class="w-full" value="content">
<TabsList class="w-full h-8">
<TabsTrigger value="info">Info</TabsTrigger>
<TabsTrigger value="content">Content</TabsTrigger>
@@ -287,6 +287,13 @@ export const DocumentPage: Component = () => {
Edit
</Button>
</div>
<Alert variant="muted" class="my-4 flex items-center gap-2">
<div class="i-tabler-info-circle size-8 flex-shrink-0" />
<AlertDescription>
The content of the document is automatically extracted from the document on upload. It is only used for search and indexing purposes.
</AlertDescription>
</Alert>
</div>
)}
>

View File

@@ -6,6 +6,7 @@ import { and, count, desc, eq, getTableColumns, lt, sql, sum } from 'drizzle-orm
import { omit } from 'lodash-es';
import { isUniqueConstraintError } from '../shared/db/constraints.models';
import { withPagination } from '../shared/db/pagination';
import { omitUndefined } from '../shared/utils';
import { documentsTagsTable, tagsTable } from '../tags/tags.table';
import { createDocumentAlreadyExistsError } from './documents.errors';
import { documentsTable } from './documents.table';
@@ -327,19 +328,9 @@ async function getAllOrganizationTrashDocumentIds({ organizationId, db }: { orga
}
async function updateDocument({ documentId, organizationId, name, content, db }: { documentId: string; organizationId: string; name?: string; content?: string; db: Database }) {
const updateData: Partial<{ name: string; content: string }> = {};
if (name !== undefined) {
updateData.name = name;
}
if (content !== undefined) {
updateData.content = content;
}
const [document] = await db
.update(documentsTable)
.set(updateData)
.set(omitUndefined({ name, content }))
.where(
and(
eq(documentsTable.id, documentId),