refactor(frontend): 前端重构 V3

This commit is contained in:
sophie committed 2026-06-14 21:41:07 +08:00
1 parent 8d8b40812d
commit ec97ea8787
80 files changed
+6887 -3733

No files matched your search

@@ -0,0 +1,635 @@
<script setup lang="ts">
/**
* features/kb/components/KbWorkspaceOverlays.vue
* 知识库作业面弹窗层:记录/Markdown/来源/失败/路径上传等。
*/
import { Upload, X } from 'lucide-vue-next';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import type { useKbWorkspace } from '../composables/useKbWorkspace';
defineProps<{
kb: ReturnType<typeof useKbWorkspace>;
}>();
</script>
<template>
<div
v-if="kb.showRecordModal"
class="dialog-overlay z-[55] items-center"
>
<div class="dialog-panel max-w-5xl max-h-[90vh] p-6">
<div class="mb-4 flex items-start justify-between gap-4">
<div>
<h3 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.recordModal.title') }}</h3>
<p class="mt-1 text-sm text-muted">
{{ kb.t('kbWorkspace.recordModal.viewing', { name: kb.documentDisplayName(kb.selectedDocument, kb.selectedDocumentId) }) }}
</p>
</div>
<button
@click="kb.closeDocumentDetail"
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
>
<X class="h-5 w-5" />
</button>
</div>
<div v-if="kb.isRecordLoading" class="flex min-h-[360px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
{{ kb.t('kbWorkspace.recordModal.loading') }}
</div>
<div v-else class="space-y-6 overflow-y-auto pr-1">
<div>
<div class="mb-3 flex items-center justify-between">
<h3 class="text-base font-semibold text-primary">{{ kb.t('kbWorkspace.recordModal.versionsTitle') }}</h3>
<span class="text-xs text-muted">{{ kb.t('kbWorkspace.recordModal.versionsCount', { count: kb.selectedDocumentVersions.length }) }}</span>
</div>
<div v-if="kb.selectedDocumentVersions.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
{{ kb.t('kbWorkspace.recordModal.versionsEmpty') }}
</div>
<div v-else class="space-y-3">
<div
v-for="version in kb.selectedDocumentVersions"
:key="version.id"
class="rounded-2xl border border-default px-4 py-4 "
>
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<div class="font-semibold text-primary">
v{{ version.version_no }} · {{ version.source_file_name }}
</div>
<div class="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted">
<span
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
:class="kb.getStatusBadgeClass(version.status)"
>
{{ kb.getStatusLabel(version.status) }}
</span>
<span>{{ kb.t('kbWorkspace.recordModal.sizeBytes', { size: version.source_file_size ?? 0 }) }}</span>
</div>
</div>
<div class="text-sm text-muted">
{{ kb.formatDateTime(version.created_at) }}
</div>
</div>
</div>
</div>
</div>
<div>
<div class="mb-3 flex items-center justify-between">
<h3 class="text-base font-semibold text-primary">{{ kb.t('kbWorkspace.recordModal.syncTitle') }}</h3>
<span class="text-xs text-muted">{{ kb.t('kbWorkspace.recordModal.versionsCount', { count: kb.selectedDocumentSyncRecords.length }) }}</span>
</div>
<div v-if="kb.selectedDocumentSyncRecords.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
{{ kb.t('kbWorkspace.recordModal.syncEmpty') }}
</div>
<div v-else class="space-y-3">
<div
v-for="record in kb.selectedDocumentSyncRecords"
:key="record.id"
class="rounded-2xl border border-default px-4 py-4 "
>
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<div class="font-semibold text-primary">
{{ record.dataset_name || record.dataset_id }} · {{ record.remote_document_name || record.remote_document_id }}
</div>
<div class="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted">
<span
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
:class="kb.getStatusBadgeClass(record.status)"
>
{{ kb.getStatusLabel(record.status) }}
</span>
<span>{{ kb.t('kbWorkspace.recordModal.versionLabel', { id: record.document_version_id }) }}</span>
</div>
</div>
<div class="text-sm text-muted">
{{ kb.formatDateTime(record.updated_at) }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
v-if="kb.showMarkdownModal"
class="dialog-overlay z-[60] items-center"
>
<div class="dialog-panel max-w-5xl max-h-[90vh] p-6">
<div class="mb-4 flex items-start justify-between gap-4">
<div class="min-w-0">
<h3 class="truncate text-lg font-semibold text-primary">{{ kb.markdownModalTitle }}</h3>
<p class="mt-1 text-sm text-muted">
{{ kb.markdownVersionLabel || kb.t('kbWorkspace.markdownModal.readingVersion') }}
<span class="ml-2 rounded-full bg-surface-soft px-2 py-0.5 text-xs text-muted">
{{ kb.markdownKind === 'preview' ? kb.t('kbWorkspace.markdownModal.previewText') : kb.t('kbWorkspace.markdownModal.cleanMarkdown') }}
</span>
</p>
</div>
<button
@click="kb.closeMarkdownModal"
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
>
<X class="h-5 w-5" />
</button>
</div>
<p
v-if="kb.markdownError"
class="mb-4 text-sm text-rose-500"
>
{{ kb.markdownError }}
</p>
<div v-if="kb.isMarkdownLoading" class="flex min-h-[420px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
{{ kb.t('kbWorkspace.markdownModal.loading') }}
</div>
<textarea
v-else
v-model="kb.markdownContent"
spellcheck="false"
class="min-h-[420px] w-full flex-1 rounded-2xl border border-default bg-surface-soft px-4 py-3 font-mono text-sm text-primary outline-none transition-colors focus:border-brand-300 focus:bg-surface"
:placeholder="kb.t('kbWorkspace.markdownModal.placeholder')"
/>
<div class="mt-6 flex justify-end gap-3">
<button
type="button"
@click="kb.closeMarkdownModal"
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 hover-surface-soft"
>
{{ kb.t('kbWorkspace.common.close') }}
</button>
<button
@click="kb.handleSaveMarkdown"
:disabled="kb.isMarkdownLoading || kb.isMarkdownSaving || !kb.markdownDocumentId"
class="inline-flex items-center justify-center rounded-xl bg-brand-600px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
>
{{ kb.isMarkdownSaving ? kb.t('kbWorkspace.markdownModal.saving') : kb.t('kbWorkspace.markdownModal.save') }}
</button>
</div>
</div>
</div>
<div
v-if="kb.showSourceInfoModal"
class="dialog-overlay z-[58] items-center"
>
<div class="dialog-panel max-w-4xl max-h-[90vh] p-6">
<div class="mb-4 flex items-start justify-between gap-4">
<div class="min-w-0">
<h3 class="truncate text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.sourceInfoModal.title') }}</h3>
<p class="mt-1 text-sm text-muted">
{{ kb.t('kbWorkspace.sourceInfoModal.viewing', { name: kb.documentDisplayName(kb.sourceInfoDocument, kb.sourceInfoDocumentId) }) }}
</p>
</div>
<button
@click="kb.closeSourceInfoModal"
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
>
<X class="h-5 w-5" />
</button>
</div>
<div v-if="kb.isSourceInfoLoading" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
{{ kb.t('kbWorkspace.sourceInfoModal.loading') }}
</div>
<div v-else-if="kb.sourceInfoVersions.length === 0" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
{{ kb.t('kbWorkspace.sourceInfoModal.empty') }}
</div>
<div v-else class="space-y-3 overflow-y-auto pr-1">
<div
v-for="version in kb.sourceInfoVersions"
:key="version.id"
class="rounded-2xl border border-default px-4 py-4 "
>
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<div class="flex flex-wrap items-center gap-2">
<button
type="button"
@click="kb.openOriginalSourceFile(version)"
class="font-semibold text-primary underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600"
>
v{{ version.version_no }} · {{ version.source_file_name }}
</button>
<span
v-if="version.is_current"
class="inline-flex items-center rounded-full border border-brand-200 bg-brand-50 px-2.5 py-1 text-xs font-semibold text-brand-700 border-brand-200"
>
{{ kb.t('kbWorkspace.sourceInfoModal.currentVersion') }}
</span>
<span
v-if="kb.openingSourceVersionId === version.id"
class="text-xs text-muted"
>
{{ kb.t('kbWorkspace.sourceInfoModal.opening') }}
</span>
</div>
<div class="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted">
<span
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
:class="kb.getStatusBadgeClass(version.status)"
>
{{ kb.getStatusLabel(version.status) }}
</span>
<span>{{ kb.t('kbWorkspace.sourceInfoModal.fileName', { name: version.source_file_name }) }}</span>
<span>{{ kb.t('kbWorkspace.sourceInfoModal.fileSize', { size: kb.formatFileSize(version.source_file_size) }) }}</span>
<span v-if="version.source_file_ext">{{ kb.t('kbWorkspace.sourceInfoModal.fileType', { ext: version.source_file_ext }) }}</span>
</div>
<div v-if="version.error_message" class="mt-2 text-sm text-rose-500">
{{ kb.t('kbWorkspace.common.failureReason', { reason: version.error_message }) }}
</div>
</div>
<div class="text-sm text-muted">
{{ kb.formatDateTime(version.created_at) }}
</div>
</div>
</div>
</div>
<div class="mt-6 flex justify-end">
<button
type="button"
@click="kb.closeSourceInfoModal"
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 hover-surface-soft"
>
{{ kb.t('kbWorkspace.common.close') }}
</button>
</div>
</div>
</div>
<div
v-if="kb.showFailureModal"
class="dialog-overlay z-[65] items-center"
>
<div class="dialog-panel max-w-6xl max-h-[90vh] p-6">
<div class="mb-4 flex items-start justify-between gap-4">
<div>
<h3 class="text-lg font-semibold text-primary">{{ kb.failureModalTitle }}</h3>
<p class="mt-1 text-sm text-muted">
{{ kb.t('kbWorkspace.failureModal.summary', { count: kb.failureModalItems.length, pageSize: kb.FAILURE_PAGE_SIZE }) }}
</p>
</div>
<button
@click="kb.closeFailureModal"
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
>
<X class="h-5 w-5" />
</button>
</div>
<div v-if="kb.failureModalItems.length === 0" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
{{ kb.t('kbWorkspace.failureModal.empty') }}
</div>
<div v-else class="space-y-4 overflow-y-auto pr-1">
<div
v-for="item in kb.pagedFailureModalItems"
:key="item.key"
class="rounded-2xl border border-default px-4 py-4 "
>
<div class="flex items-start justify-between gap-4">
<div class="min-w-0 flex-1">
<div class="flex flex-wrap items-center gap-2">
<div class="max-w-full truncate text-base font-semibold text-primary">
{{ kb.getDocumentDisplayTitle(item.document) }}
</div>
<span class="inline-flex items-center rounded-full border border-rose-200 bg-rose-50 px-2.5 py-1 text-xs font-semibold text-rose-700 border-rose-200">
{{ item.stageLabel }}
</span>
</div>
<div class="mt-2 text-sm text-muted">
{{ kb.t('kbWorkspace.failureModal.currentVersion') }}
<span v-if="item.document.latest_version">
v{{ item.document.latest_version.version_no }} · {{ item.document.latest_version.source_file_name }}
</span>
<span v-else>{{ kb.t('kbWorkspace.failureModal.noVersion') }}</span>
</div>
<div class="mt-2 text-sm text-rose-500">
{{ kb.t('kbWorkspace.common.failureReason', { reason: item.errorMessage }) }}
</div>
</div>
<div class="shrink-0 text-right text-sm text-muted">
{{ kb.formatDateTime(item.updatedAt) }}
</div>
</div>
<div class="mt-4 flex flex-wrap items-center gap-2">
<button
@click="kb.handleRetryFailedItem(item, 'submit')"
:disabled="kb.retryingFailureKey === `${item.key}-submit`"
class="inline-flex items-center gap-2 rounded-xl border border-sky-200 px-3 py-2 text-xs font-medium text-sky-700 transition-colors hover:bg-sky-50 disabled:cursor-not-allowed disabled:opacity-60"
>
{{ kb.retryingFailureKey === `${item.key}-submit` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.failureModal.resubmit') }}
</button>
<button
v-if="kb.isKbAdmin"
@click="kb.handleRetryFailedItem(item, 'clean')"
:disabled="kb.retryingFailureKey === `${item.key}-clean` || !item.document.latest_version"
class="inline-flex items-center gap-2 rounded-xl border border-amber-200 px-3 py-2 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-50 disabled:cursor-not-allowed disabled:opacity-60 border-amber-200"
>
{{ kb.retryingFailureKey === `${item.key}-clean` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.failureModal.reclean') }}
</button>
<button
v-if="kb.isKbAdmin"
@click="kb.handleRetryFailedItem(item, 'sync')"
:disabled="kb.retryingFailureKey === `${item.key}-sync` || !item.document.latest_version"
class="inline-flex items-center gap-2 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"
>
{{ kb.retryingFailureKey === `${item.key}-sync` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.failureModal.resync') }}
</button>
</div>
</div>
</div>
<div
v-if="kb.failureModalItems.length > kb.FAILURE_PAGE_SIZE"
class="mt-5 flex items-center justify-between gap-3 border-t border-default pt-4 "
>
<div class="text-sm text-muted">
{{ kb.t('kbWorkspace.failureModal.pageInfo', { page: kb.failureModalPage, totalPages: kb.failureModalTotalPages }) }}
</div>
<div class="flex items-center gap-2">
<button
@click="kb.failureModalPage = Math.max(1, kb.failureModalPage - 1)"
:disabled="kb.failureModalPage === 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.failureModalPage = Math.min(kb.failureModalTotalPages, kb.failureModalPage + 1)"
:disabled="kb.failureModalPage === kb.failureModalTotalPages"
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>
<div
v-if="kb.showPathUploadModal"
class="dialog-overlay z-[66] items-center"
>
<div class="dialog-panel max-w-4xl max-h-[90vh] p-6">
<div class="mb-4 flex items-start justify-between gap-4">
<div>
<h3 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.pathUploadModal.title') }}</h3>
<p class="mt-1 text-sm text-muted">
{{ kb.t('kbWorkspace.pathUploadModal.subtitle') }}
</p>
</div>
<button
@click="kb.closePathUploadModal"
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
>
<X class="h-5 w-5" />
</button>
</div>
<div class="space-y-4 overflow-y-auto pr-1">
<div class="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-medium text-primary">{{ kb.t('kbWorkspace.pathUploadModal.localPickerTitle') }}</div>
<div class="mt-1 text-xs text-muted">
{{ kb.t('kbWorkspace.pathUploadModal.localPickerHint') }}
</div>
</div>
<button
@click="kb.triggerPathUploadSelection"
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 border-brand-200 hover:bg-brand-50"
>
<Upload class="h-4 w-4" />
{{ kb.t('kbWorkspace.pathUploadModal.pickFolder') }}
</button>
</div>
</div>
<div>
<label class="label-field block mb-2">{{ kb.t('kbWorkspace.pathUploadModal.pathListLabel') }}</label>
<textarea
v-model="kb.pathUploadDraftText"
rows="5"
class="input-field"
:placeholder="kb.t('kbWorkspace.pathUploadModal.pathListPlaceholder')"
/>
</div>
<div>
<div class="mb-2 flex items-center justify-between gap-3">
<div class="text-sm font-medium text-secondary">
{{ kb.t('kbWorkspace.pathUploadModal.pendingFiles') }}
<span class="ml-2 text-xs text-muted">{{ kb.t('kbWorkspace.recordModal.versionsCount', { count: kb.pathUploadSelectedFiles.length }) }}</span>
</div>
<div class="text-xs text-muted">
{{ kb.t('kbWorkspace.pathUploadModal.selectedRoots', { paths: kb.selectedPathRoots.length ? kb.selectedPathRoots.join('、') : kb.t('kbWorkspace.pathUploadModal.noRoots') }) }}
</div>
</div>
<div v-if="kb.pathUploadSelectedFiles.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
{{ kb.t('kbWorkspace.pathUploadModal.pickFolderFirst') }}
</div>
<div v-else class="max-h-72 space-y-2 overflow-y-auto pr-1">
<div
v-for="item in kb.pathUploadSelectedFiles"
:key="item.key"
class="flex items-start justify-between gap-3 rounded-2xl border border-default px-4 py-3 "
>
<div class="min-w-0 flex-1">
<div class="truncate text-sm font-medium text-primary">{{ item.file.name }}</div>
<div class="mt-1 truncate text-xs text-muted">{{ item.displayPath }}</div>
</div>
<button
@click="kb.removeSelectedPathFile(item.key)"
class="inline-flex items-center rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
>
{{ kb.t('kbWorkspace.common.remove') }}
</button>
</div>
</div>
</div>
</div>
<div class="mt-6 flex justify-end gap-3">
<button
type="button"
@click="kb.closePathUploadModal"
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 hover-surface-soft"
>
{{ kb.t('kbWorkspace.common.cancel') }}
</button>
<button
@click="kb.handleConfirmPathUpload"
class="inline-flex items-center justify-center gap-2 rounded-xl bg-brand-600px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700"
>
<Upload class="h-4 w-4" />
{{ kb.t('kbWorkspace.pathUploadModal.confirmUpload') }}
</button>
</div>
</div>
</div>
<div
v-if="kb.showPathUploadHistoryModal"
class="dialog-overlay z-[67] items-center"
>
<div class="dialog-panel max-w-6xl max-h-[90vh] p-6">
<div class="mb-4 flex items-start justify-between gap-4">
<div>
<h3 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.pathUploadHistoryModal.title') }}</h3>
<p class="mt-1 text-sm text-muted">{{ kb.t('kbWorkspace.pathUploadHistoryModal.subtitle') }}</p>
</div>
<button
@click="kb.closePathUploadHistoryModal"
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
>
<X class="h-5 w-5" />
</button>
</div>
<div v-if="kb.pathUploadHistoryJobs.length === 0" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
{{ kb.t('kbWorkspace.pathUpload.emptyHistory') }}
</div>
<div v-else class="grid min-h-0 flex-1 grid-cols-1 gap-4 lg:grid-cols-[320px_minmax(0,1fr)]">
<div class="space-y-3 overflow-y-auto pr-1">
<button
v-for="job in kb.pathUploadHistoryJobs"
:key="job.id"
@click="kb.selectedPathUploadHistoryJobId = job.id"
class="w-full rounded-2xl border px-4 py-4 text-left transition-colors"
:class="String(kb.selectedPathUploadHistoryJobId || kb.selectedPathUploadHistoryJob?.id) === String(job.id)
? 'border-brand-200 bg-brand-50 border-brand-200 '
: 'border-default bg-surface hover:bg-surface-soft hover-surface-soft'"
>
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<div class="truncate text-sm font-semibold text-primary">{{ kb.t('kbWorkspace.pathUpload.batchLabel', { id: job.id }) }}</div>
<div class="mt-1 text-xs text-muted">{{ kb.formatDateTime(job.created_at) }}</div>
</div>
<span
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
:class="kb.getStatusBadgeClass(job.status)"
>
{{ kb.getStatusLabel(job.status) }}
</span>
</div>
<div class="mt-3 grid grid-cols-2 gap-2 text-xs text-muted">
<div>{{ kb.t('kbWorkspace.pathUpload.total', { count: kb.getPathUploadJobSummary(job).total }) }}</div>
<div>{{ kb.t('kbWorkspace.pathUpload.success', { count: kb.getPathUploadJobSummary(job).success }) }}</div>
<div>{{ kb.t('kbWorkspace.pathUpload.failed', { count: kb.getPathUploadJobSummary(job).failed }) }}</div>
<div>{{ kb.t('kbWorkspace.pathUpload.pendingProcess', { count: kb.getPathUploadJobSummary(job).pending }) }}</div>
</div>
</button>
</div>
<div v-if="kb.selectedPathUploadHistoryJob" class="min-h-0 rounded-2xl border border-default p-4 ">
<div class="flex flex-wrap items-start justify-between gap-3">
<div>
<div class="text-base font-semibold text-primary">{{ kb.t('kbWorkspace.pathUpload.batchLabel', { id: kb.selectedPathUploadHistoryJob.id }) }}</div>
<div class="mt-1 text-sm text-muted">
{{ kb.t('kbWorkspace.pathUpload.createdAt', { time: kb.formatDateTime(kb.selectedPathUploadHistoryJob.created_at) }) }}
<span v-if="kb.selectedPathUploadHistoryJob.finished_at">{{ kb.t('kbWorkspace.pathUpload.finishedAt', { time: kb.formatDateTime(kb.selectedPathUploadHistoryJob.finished_at) }) }}</span>
</div>
<div class="mt-2 text-sm text-muted">{{ kb.selectedPathUploadHistoryJob.message || kb.t('kbWorkspace.pathUpload.noBatchMessage') }}</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.getStatusBadgeClass(kb.selectedPathUploadHistoryJob.status)"
>
{{ kb.getStatusLabel(kb.selectedPathUploadHistoryJob.status) }}
</span>
<button
v-if="kb.selectedPathUploadHistoryItems.length && !kb.pathUploadRunning"
@click="kb.toggleSelectAllPathUploadHistoryItems"
class="inline-flex items-center rounded-xl border border-default px-3 py-2 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
>
{{ kb.isAllPathUploadHistoryItemsSelected ? kb.t('kbWorkspace.pathUpload.deselectAll') : kb.t('kbWorkspace.pathUpload.selectAll') }}
</button>
<button
v-if="!kb.pathUploadRunning"
@click="kb.handleBatchDeletePathUploadItems"
:disabled="!kb.selectedPathUploadHistorySelectedItems.length || kb.deletingPathUploadBatch"
class="inline-flex items-center rounded-xl border border-default px-3 py-2 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
>
{{ kb.pathUploadBatchDeleteLabel(kb.deletingPathUploadBatch, kb.selectedPathUploadHistorySelectedItems.length) }}
</button>
<button
v-if="kb.hasRetryablePathUploadFailure(kb.selectedPathUploadHistoryJob) && !kb.pathUploadRunning"
@click="kb.handleRetryFailedPathUpload(kb.selectedPathUploadHistoryJob)"
:disabled="kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.id}:all`"
class="inline-flex items-center rounded-xl border border-rose-200 px-3 py-2 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.selectedPathUploadHistoryJob.id}:all` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.pathUpload.retryAllFailed') }}
</button>
</div>
</div>
<div class="mt-4 grid grid-cols-2 gap-3 text-sm text-secondary md:grid-cols-4">
<div class="rounded-xl bg-surface-soft px-3 py-2 ">{{ kb.t('kbWorkspace.pathUpload.total', { count: kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).total }) }}</div>
<div class="rounded-xl bg-surface-soft px-3 py-2 ">{{ kb.t('kbWorkspace.pathUpload.success', { count: kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).success }) }}</div>
<div class="rounded-xl bg-surface-soft px-3 py-2 ">{{ kb.t('kbWorkspace.pathUpload.failed', { count: kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).failed }) }}</div>
<div class="rounded-xl bg-surface-soft px-3 py-2 ">{{ kb.t('kbWorkspace.pathUpload.pendingProcess', { count: kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).pending }) }}</div>
</div>
<div class="mt-4 max-h-[50vh] space-y-2 overflow-y-auto pr-1">
<div
v-for="item in kb.selectedPathUploadHistoryItems"
:key="item.key"
class="flex flex-wrap items-start justify-between gap-3 rounded-2xl border border-default px-4 py-3 "
>
<label class="flex items-center pt-1">
<input
type="checkbox"
:checked="kb.selectedPathUploadHistoryItemKeys.includes(item.key)"
@change="kb.togglePathUploadHistoryItemSelection(item.key)"
class="h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
/>
</label>
<div class="min-w-0 flex-1">
<div class="truncate text-sm 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.pathUploadRunning"
@click="kb.handleRetryFailedPathUpload(kb.selectedPathUploadHistoryJob, [item.displayPath])"
:disabled="kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.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.selectedPathUploadHistoryJob.id}:${item.displayPath}` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.common.retry') }}
</button>
<button
v-if="!kb.pathUploadRunning"
@click="kb.handleDeletePathUploadItem(kb.selectedPathUploadHistoryJob, 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>
</div>
<DeleteConfirmDialog
v-model="kb.showDeleteConfirmDialog"
:message="kb.deleteConfirmMessage"
@confirm="kb.handleDeleteConfirm"
@cancel="kb.closeDeleteConfirmDialog"
/>
</template>