Files
syops/frontend/src/features/kb/views/KbWorkspaceView.vue
T

553 lines
30 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
/**
* features/kb/views/KbWorkspaceView.vue
* 知识库作业面视图壳:模板与弹窗布局,业务逻辑见 useKbWorkspace。
*/
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, Info, RefreshCw, Search, Trash2, Upload } from 'lucide-vue-next';
import KbWorkspaceOverlays from '../components/KbWorkspaceOverlays.vue';
import { useKbWorkspace } from '../composables/useKbWorkspace';
const props = defineProps<{
embedded?: boolean;
}>();
/** 作业面状态与操作:模板统一通过 kb.xxx 访问,含 fileInputRef / pathUploadInputRef */
const kb = useKbWorkspace({ embedded: props.embedded });
</script>
<template>
<div :class="!kb.embedded ? 'page-shell min-h-screen' : 'text-secondary'">
<div :class="!kb.embedded ? 'mx-auto max-w-7xl page-shell-mobile py-6' : ''">
<div class="card mb-6 flex flex-col gap-4 p-6 md:flex-row md:items-center md:justify-between">
<div class="flex items-start gap-4">
<button
v-if="!kb.embedded || (kb.embedded && kb.viewMode === 'group_detail')"
@click="kb.embedded ? kb.backToGroupOverview() : kb.router.push('/workspace')"
class="kb-ws-icon-btn"
:title="kb.embedded ? kb.t('kbWorkspace.actions.backToOverview') : kb.t('kbWorkspace.actions.backToWorkspace')"
>
<ArrowLeft class="h-5 w-5" />
</button>
<div>
<div class="flex items-center gap-3">
<div class="flex h-12 w-12 items-center justify-center rounded-2xl bg-brand-50 text-brand-600 ">
<BookOpen class="h-6 w-6" />
</div>
<div>
<h1 class="text-2xl font-bold text-primary">
{{ kb.viewMode === 'group_overview' ? kb.t('kbWorkspace.header.groupOverviewTitle') : kb.t('kbWorkspace.header.workspaceTitle') }}
</h1>
<p class="mt-1 text-sm text-muted">
{{ kb.viewMode === 'group_overview' ? kb.t('kbWorkspace.header.groupOverviewSubtitle') : kb.t('kbWorkspace.header.workspaceSubtitle') }}
</p>
</div>
</div>
</div>
</div>
<div class="flex flex-wrap items-center gap-3">
<button
@click="kb.refreshCurrentView"
class="btn-secondary"
>
<RefreshCw class="h-4 w-4" />
{{ kb.viewMode === 'group_overview' ? kb.t('kbWorkspace.actions.refreshGroups') : kb.t('kbWorkspace.actions.refreshDocuments') }}
</button>
</div>
</div>
<template v-if="kb.viewMode === 'group_overview'">
<section class="kb-ws-section">
<div class="mb-4 flex items-center justify-between">
<h2 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.overview.title') }}</h2>
<span class="text-xs text-muted">`/api/kb/groups`</span>
</div>
<div v-if="kb.isLoading" class="py-10 text-center text-sm text-muted">{{ kb.t('kbWorkspace.overview.loadingGroups') }}</div>
<div v-else-if="kb.groups.length === 0" class="kb-ws-empty py-10 text-center text-sm text-muted">
{{ kb.t('kbWorkspace.overview.emptyGroups') }}
</div>
<div v-else class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3 auto-rows-fr">
<div
v-for="group in kb.groups"
:key="group.id"
@click="kb.openGroupDetail(group.id)"
class="kb-ws-card--interactive"
>
<div class="w-full text-left">
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<div class="text-xl font-bold leading-tight text-primary break-words">{{ group.name }}</div>
<div class="mt-1 text-sm text-muted">{{ group.description || kb.t('kbWorkspace.overview.noDescription') }}</div>
</div>
<div class="rounded-full bg-surface-soft px-2.5 py-1 text-xs font-medium text-secondary whitespace-nowrap">
{{ kb.t('kbWorkspace.overview.documentCount', { count: group.document_count ?? 0 }) }}
</div>
</div>
<div class="mt-4 text-xs text-muted">{{ kb.t('kbWorkspace.overview.updatedAt') }}{{ kb.formatDateTime(group.updated_at) }}</div>
</div>
</div>
</div>
</section>
</template>
<template v-else>
<div class="kb-ws-stat-grid">
<div
v-for="item in kb.groupSummaryItems"
:key="item.label"
class="kb-ws-stat-tile "
:class="[
item.wide ? 'col-span-2 xl:col-span-2' : '',
item.clickable
? 'cursor-pointer hover:bg-rose-50 hover:bg-rose-50'
: '',
]"
@click="item.clickable && item.failureType ? kb.openFailureModal(item.failureType) : undefined"
>
<div
class="text-base font-semibold text-primary break-words"
:style="item.wide ? '-webkit-line-clamp: 2; -webkit-box-orient: vertical; display: -webkit-box; overflow: hidden;' : undefined"
>
{{ item.value }}
</div>
<div class="mt-1 text-xs text-muted">{{ item.label }}</div>
</div>
</div>
<div class="grid grid-cols-1 gap-6 lg:grid-cols-[320px_minmax(0,1fr)]">
<input
:ref="(el) => { kb.fileInputRef = el as HTMLInputElement | null }"
type="file"
multiple
class="hidden"
@change="kb.handleFileSelected"
/>
<input
:ref="(el) => { kb.pathUploadInputRef = el as HTMLInputElement | null }"
type="file"
multiple
webkitdirectory
directory
class="hidden"
@change="kb.handlePathFilesSelected"
/>
<section class="kb-ws-section">
<div class="mb-4 flex items-center justify-between">
<h2 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.sidebar.groupsTitle') }}</h2>
</div>
<div v-if="kb.isLoading" class="py-10 text-center text-sm text-muted">{{ kb.t('kbWorkspace.sidebar.loadingGroups') }}</div>
<div v-else-if="kb.groups.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
{{ kb.t('kbWorkspace.sidebar.emptyGroups') }}
</div>
<div v-else class="space-y-3">
<button
v-for="group in kb.groups"
:key="group.id"
@click="kb.selectedGroupId = group.id"
class="kb-ws-group-list-btn"
:class="{ 'kb-ws-group-list-btn--active': kb.selectedGroupId === group.id }"
>
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<div class="truncate font-semibold">{{ group.name }}</div>
<div class="mt-1 text-sm opacity-80">{{ group.description || kb.t('kbWorkspace.sidebar.noDescription') }}</div>
</div>
<span class="rounded-full bg-surface/70 px-2 py-1 text-xs ">
{{ group.document_count ?? 0 }}
</span>
</div>
</button>
</div>
</section>
<section class="space-y-6">
<div class="kb-ws-section">
<div class="mb-4 space-y-3">
<div class="flex flex-wrap items-center justify-between gap-3">
<div class="flex items-center gap-2">
<h2 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.documents.title') }}</h2>
<div class="group relative">
<button
type="button"
class="inline-flex h-6 w-6 items-center justify-center rounded-full border border-default text-muted transition-colors hover:border-brand-300 hover:text-brand-500 hover:border-brand-300 hover:text-brand-600"
>
<Info class="h-3.5 w-3.5" />
</button>
<div class="pointer-events-none absolute left-0 top-8 z-10 hidden w-80 rounded-2xl border border-default bg-surface px-4 py-3 text-sm text-muted shadow-xl group-hover:block">
{{ kb.t('kbWorkspace.documents.infoTip') }}
</div>
</div>
</div>
<div class="flex flex-wrap items-center gap-3">
<button
v-if="kb.selectedGroupId"
@click="kb.openPathUploadModal"
:disabled="kb.pathUploadRunning"
class="inline-flex items-center gap-2 rounded-2xl border border-brand-200 px-4 py-2.5 text-sm font-medium text-brand-700 transition-colors hover:bg-brand-50 disabled:cursor-not-allowed disabled:opacity-60 border-brand-200 hover:bg-brand-50"
>
<Upload class="h-4 w-4" />
{{ kb.t('kbWorkspace.documents.uploadPath') }}
</button>
<button
v-if="kb.selectedGroupId"
@click="kb.triggerMultiUpload"
:disabled="kb.isSubmitting"
class="btn-primary"
>
<Upload class="h-4 w-4" />
{{ kb.t('kbWorkspace.documents.uploadFile') }}
</button>
</div>
</div>
<div class="flex flex-wrap items-center gap-3">
<button
v-if="kb.isKbAdmin && kb.selectedGroupId"
@click="kb.handleBatchClean"
:disabled="kb.batchSubmitting || kb.selectedDocuments.length === 0"
class="inline-flex items-center gap-2 rounded-2xl border border-amber-200 px-4 py-2.5 text-sm font-medium text-amber-700 transition-colors hover:bg-amber-50 disabled:cursor-not-allowed disabled:opacity-60"
>
<RefreshCw class="h-4 w-4" />
{{ kb.batchActionLabel('clean', kb.batchSubmitting, kb.selectedDocuments.length) }}
</button>
<button
v-if="kb.isKbAdmin && kb.selectedGroupId"
@click="kb.handleBatchSync"
:disabled="kb.batchSubmitting || kb.selectedDocuments.length === 0"
class="inline-flex items-center gap-2 rounded-2xl border border-emerald-200 px-4 py-2.5 text-sm font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200"
>
<RefreshCw class="h-4 w-4" />
{{ kb.batchActionLabel('sync', kb.batchSubmitting, kb.selectedDocuments.length) }}
</button>
<button
v-if="kb.selectedGroupId"
@click="kb.handleBatchDelete"
:disabled="kb.batchSubmitting || kb.selectedDocuments.length === 0"
class="inline-flex items-center gap-2 rounded-2xl border border-rose-200 px-4 py-2.5 text-sm font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
>
<Trash2 class="h-4 w-4" />
{{ kb.batchActionLabel('delete', kb.batchSubmitting, kb.selectedDocuments.length) }}
</button>
<button
v-if="kb.selectedGroupId"
@click="kb.openPathUploadHistoryModal()"
class="btn-secondary"
>
<FileText class="h-4 w-4" />
{{ kb.t('kbWorkspace.documents.historyBatches') }}
</button>
</div>
<div v-if="kb.selectedGroupId" class="flex flex-wrap items-center gap-3">
<label class="relative w-full max-w-md">
<Search class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted" />
<input
v-model.trim="kb.documentKeyword"
type="text"
class="w-full rounded-2xl border border-default bg-surface py-2.5 pl-10 pr-4 text-sm text-primary outline-none transition-colors focus:border-brand-300"
:placeholder="kb.t('kbWorkspace.documents.searchPlaceholder')"
/>
</label>
<button
v-if="kb.documentKeyword"
type="button"
@click="kb.documentKeyword = ''"
class="inline-flex items-center rounded-xl border border-default px-3 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
>
{{ kb.t('kbWorkspace.documents.clearSearch') }}
</button>
</div>
</div>
<p
v-if="kb.feedback"
class="mb-4 text-sm"
:class="kb.feedbackType === 'error' ? 'text-rose-500' : 'text-emerald-600'"
>
{{ kb.feedback }}
</p>
<div
v-if="kb.pathUploadTask.total"
class="mb-4 rounded-2xl border border-default bg-surface-soft p-4"
>
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<div class="text-sm font-semibold text-primary">
{{ kb.t('kbWorkspace.pathUpload.progressTitle') }}
<span
class="ml-2 inline-flex items-center rounded-full border px-2.5 py-1 text-xs"
:class="kb.pathUploadRunning
? 'border-amber-200 bg-amber-50 text-amber-700 border-amber-200'
: 'border-emerald-200 bg-emerald-50 text-emerald-700 border-emerald-200 '"
>
{{ kb.pathUploadRunning ? kb.t('kbWorkspace.pathUpload.uploading') : kb.t('kbWorkspace.pathUpload.completed') }}
</span>
</div>
<div class="mt-1 text-sm text-muted">
{{ kb.t('kbWorkspace.pathUpload.batchHint', { batchSize: kb.pathUploadTask.batchSize, seconds: kb.PATH_UPLOAD_BATCH_INTERVAL_MS / 1000 }) }}
</div>
</div>
<div class="grid grid-cols-2 gap-2 text-sm text-secondary md:grid-cols-4">
<div>{{ kb.t('kbWorkspace.pathUpload.total', { count: kb.pathUploadSummary.total }) }}</div>
<div>{{ kb.t('kbWorkspace.pathUpload.pending', { count: kb.pathUploadSummary.pending }) }}</div>
<div>{{ kb.t('kbWorkspace.pathUpload.uploaded', { count: kb.pathUploadSummary.uploaded }) }}</div>
<div>{{ kb.t('kbWorkspace.pathUpload.failed', { count: kb.pathUploadSummary.failed }) }}</div>
</div>
</div>
<div v-if="kb.pathUploadTask.currentFile" class="mt-3 text-sm text-brand-600 ">
{{ kb.t('kbWorkspace.pathUpload.currentFile', { name: kb.pathUploadTask.currentFile }) }}
</div>
<div class="mt-4 space-y-2">
<div class="flex flex-wrap items-center justify-between gap-2">
<button
type="button"
@click="kb.showPathUploadDetails = !kb.showPathUploadDetails"
class="inline-flex items-center gap-2 text-sm font-medium text-secondary transition-colors hover:text-brand-600 hover:text-brand-600"
>
<span>{{ kb.t('kbWorkspace.pathUpload.details') }}</span>
<ChevronDown v-if="!kb.showPathUploadDetails" class="h-4 w-4" />
<ChevronUp v-else class="h-4 w-4" />
</button>
<div class="flex items-center gap-2">
<button
@click="kb.openPathUploadHistoryModal(kb.latestPathUploadJob?.id || null)"
class="inline-flex items-center rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
>
{{ kb.t('kbWorkspace.pathUpload.viewHistory') }}
</button>
<button
v-if="kb.latestPathUploadJob && kb.hasRetryablePathUploadFailure(kb.latestPathUploadJob) && !kb.pathUploadRunning"
@click="kb.handleRetryFailedPathUpload(kb.latestPathUploadJob)"
:disabled="kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:all`"
class="inline-flex items-center rounded-xl border border-rose-200 px-3 py-1.5 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
>
{{ kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:all` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.pathUpload.retryFailedFiles') }}
</button>
</div>
</div>
<div v-if="kb.showPathUploadDetails" class="max-h-72 space-y-2 overflow-y-auto pr-1">
<div
v-for="item in kb.recentPathUploadItems"
:key="item.key"
class="flex flex-wrap items-start justify-between gap-3 rounded-xl border border-default bg-surface px-3 py-3 text-sm"
>
<div class="min-w-0 flex-1">
<div class="truncate font-medium text-primary">{{ item.title }}</div>
<div class="mt-1 truncate text-xs text-muted">{{ item.displayPath }}</div>
<div v-if="item.error" class="mt-1 text-xs text-rose-500">{{ kb.t('kbWorkspace.common.failureReason', { reason: item.error }) }}</div>
</div>
<div class="flex items-center gap-2">
<span
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
:class="kb.getPathUploadItemDisplayState(item).className"
>
{{ kb.getPathUploadItemDisplayState(item).label }}
</span>
<button
v-if="item.retryable && kb.latestPathUploadJob && !kb.pathUploadRunning"
@click="kb.handleRetryFailedPathUpload(kb.latestPathUploadJob, [item.displayPath])"
:disabled="kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:${item.displayPath}`"
class="inline-flex items-center rounded-xl border border-rose-200 px-2.5 py-1 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
>
{{ kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:${item.displayPath}` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.common.retry') }}
</button>
<button
v-if="kb.latestPathUploadJob && !kb.pathUploadRunning"
@click="kb.handleDeletePathUploadItem(kb.latestPathUploadJob, item)"
class="inline-flex items-center rounded-xl border border-default px-2.5 py-1 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
>
{{ kb.t('kbWorkspace.common.delete') }}
</button>
</div>
</div>
</div>
</div>
</div>
<div
v-if="kb.selectedGroupId"
class="mb-4 flex flex-wrap items-center justify-between gap-3 rounded-2xl bg-surface-soft px-4 py-3 "
>
<div class="flex flex-wrap items-center gap-2">
<button
@click="kb.toggleSelectAllFiltered"
class="inline-flex items-center gap-2 rounded-full border border-default bg-surface px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
>
{{ kb.isAllFilteredSelected ? kb.t('kbWorkspace.pathUpload.deselectAllFiltered') : kb.t('kbWorkspace.pathUpload.selectAllFiltered') }}
</button>
<button
v-for="tab in kb.stageFilterTabs"
:key="tab.key"
@click="kb.documentStageFilter = tab.key"
class="inline-flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium transition-colors"
:class="kb.documentStageFilter === tab.key
? 'border-brand-200 bg-brand-50 text-brand-700 border-brand-200 '
: 'border-default bg-surface text-secondary hover:bg-surface-soft hover-surface-soft'"
>
<span>{{ tab.label }}</span>
<span class="rounded-full bg-surface-soft px-2 py-0.5 text-xs ">{{ tab.count }}</span>
</button>
</div>
<div class="flex flex-wrap items-center gap-3 text-sm text-muted">
<label class="inline-flex items-center gap-2">
<span>{{ kb.t('kbWorkspace.common.perPage') }}</span>
<select
v-model.number="kb.documentListPageSize"
class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-secondary outline-none transition-colors focus:border-brand-300"
>
<option v-for="size in kb.DOCUMENT_PAGE_SIZE_OPTIONS" :key="size" :value="size">{{ size }}</option>
</select>
<span>{{ kb.t('kbWorkspace.common.countUnit') }}</span>
</label>
<span>{{ kb.t('kbWorkspace.documents.selectedCount', { selected: kb.selectedDocuments.length, total: kb.filteredDocuments.length }) }}</span>
<span v-if="kb.filteredDocuments.length > 0">{{ kb.t('kbWorkspace.documents.showingRange', { start: kb.pagedDocumentRange.start, end: kb.pagedDocumentRange.end }) }}</span>
</div>
</div>
<div v-if="!kb.selectedGroupId" class="rounded-2xl border border-dashed border-default px-4 py-12 text-center text-sm text-muted ">
{{ kb.t('kbWorkspace.documents.selectGroup') }}
</div>
<div v-else-if="kb.isDocumentsLoading" class="rounded-2xl border border-dashed border-default px-4 py-12 text-center text-sm text-muted ">
{{ kb.t('kbWorkspace.documents.loadingDocuments') }}
</div>
<div v-else-if="kb.filteredDocuments.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-12 text-center text-sm text-muted ">
{{ kb.documentEmptyMessage(kb.documents.length, !!kb.documentKeyword) }}
</div>
<div v-else class="space-y-3">
<div
v-for="doc in kb.pagedFilteredDocuments"
:key="doc.id"
class="rounded-2xl border px-4 py-4 transition-colors"
:class="kb.selectedDocumentId === doc.id
? 'border-brand-200 bg-brand-50/50 border-brand-200'
: 'border-default'"
>
<div class="flex items-start justify-between gap-3">
<div class="flex min-w-0 flex-1 gap-3">
<label class="mt-1 inline-flex shrink-0 cursor-pointer items-center">
<input
type="checkbox"
class="h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
:checked="kb.selectedDocumentIds.includes(doc.id)"
@change="kb.toggleDocumentSelection(doc.id)"
/>
</label>
<div class="min-w-0 flex-1">
<button
@click="kb.openMarkdownEditor(doc)"
class="block max-w-full truncate text-left font-semibold text-primary transition-colors hover:text-brand-600 hover:text-brand-600"
>
{{ kb.getDocumentDisplayTitle(doc) }}
</button>
<button
type="button"
@click="kb.openSourceInfo(doc)"
class="mt-1 block max-w-full text-left text-sm text-muted transition-colors hover:text-brand-600 hover:text-brand-600"
>
{{ kb.getDocumentDisplayDescription(doc) }}
</button>
<div class="mt-2 text-xs text-muted">
<span>{{ kb.t('kbWorkspace.documents.versionCount', { count: doc.version_count ?? 0 }) }}</span>
<span v-if="doc.latest_version">
<span>{{ kb.t('kbWorkspace.documents.currentVersion', { version: doc.latest_version.version_no }) }}</span>
<button
type="button"
@click="kb.openSourceInfo(doc)"
class="inline text-xs text-muted underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600"
>
{{ doc.latest_version.source_file_name }}
</button>
</span>
</div>
</div>
</div>
<div class="flex items-center gap-2">
<button
@click="kb.openDocumentDetail(doc.id)"
class="inline-flex items-center gap-1 rounded-xl border border-violet-200 px-3 py-2 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
>
<FileText class="h-3.5 w-3.5" />
{{ kb.t('kbWorkspace.documents.viewRecord') }}
</button>
<button
@click="kb.triggerUploadForDocument(doc.id)"
class="inline-flex items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 border-brand-200 hover:bg-brand-50"
>
<Upload class="h-3.5 w-3.5" />
{{ kb.t('kbWorkspace.documents.uploadVersion') }}
</button>
<button
v-if="kb.isKbAdmin"
@click="kb.handleSyncDocument(doc.id)"
:disabled="kb.syncingDocumentId === doc.id || !doc.latest_version"
class="inline-flex items-center gap-1 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200"
>
<RefreshCw class="h-3.5 w-3.5" />
{{ kb.syncingDocumentId === doc.id ? kb.t('kbWorkspace.documents.syncingDify') : kb.t('kbWorkspace.documents.syncDify') }}
</button>
<button
@click="kb.handleDeleteDocument(doc)"
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 border-rose-200 hover:bg-rose-50"
>
<Trash2 class="h-3.5 w-3.5" />
{{ kb.t('kbWorkspace.common.delete') }}
</button>
</div>
</div>
<div class="mt-4 flex items-end justify-between gap-3 border-t border-default pt-3 ">
<div class="space-y-1">
<div class="text-xs text-muted">
{{ kb.t('kbWorkspace.documents.updatedAt', { time: kb.formatDateTime(doc.updated_at) }) }}
</div>
<div
v-if="kb.getDocumentWorkflowState(doc).primaryError"
class="max-w-xl text-xs text-rose-500"
>
{{ kb.t('kbWorkspace.common.failureReason', { reason: kb.getDocumentWorkflowState(doc).primaryError }) }}
</div>
</div>
<div class="flex flex-wrap items-center justify-end gap-2">
<div
v-for="badge in kb.getWorkflowBadges(doc)"
:key="`${doc.id}-${badge.label}`"
class="inline-flex items-center rounded-full border px-3 py-1 text-sm font-semibold"
:class="badge.className"
>
{{ badge.label }}:{{ badge.value }}
</div>
</div>
</div>
</div>
<div
v-if="kb.filteredDocuments.length > kb.documentListPageSize"
class="flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-default px-4 py-3 "
>
<div class="text-sm text-muted">
{{ kb.t('kbWorkspace.documents.pageInfo', { page: kb.documentListPage, totalPages: kb.filteredDocumentTotalPages, total: kb.filteredDocuments.length }) }}
</div>
<div class="flex items-center gap-2">
<button
@click="kb.documentListPage = Math.max(1, kb.documentListPage - 1)"
:disabled="kb.documentListPage === 1"
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
>
{{ kb.t('kbWorkspace.common.prevPage') }}
</button>
<button
@click="kb.documentListPage = Math.min(kb.filteredDocumentTotalPages, kb.documentListPage + 1)"
:disabled="kb.documentListPage === kb.filteredDocumentTotalPages"
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
>
{{ kb.t('kbWorkspace.common.nextPage') }}
</button>
</div>
</div>
</div>
</div>
</section>
</div>
</template>
</div>
</div>
<KbWorkspaceOverlays :kb="kb" />
</template>