From 2f3b4ad215a63c5ac14b01909c6f507a4acec1ca Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma <32020192+tds-1@users.noreply.github.com> Date: Tue, 2 Sep 2025 20:31:16 +0700 Subject: [PATCH] feat: add FE changes for captain pdf support for faq generation (#12115) Linked PR https://github.com/chatwoot/chatwoot/pull/12113 ## Linear Link https://linear.app/chatwoot/issue/CW-4515/upload-pdfs-to-captain ## Description This PR adds support for PDF file uploads to the Captain document knowledge base system. The feature enables users to upload PDF files directly to the knowledge base for FAQ generation and document processing, expanding beyond the existing URL-based document ingestion. ## Type of change - [ ] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Unit Tests - Manually via UI ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Muhsin Keloth Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: iamsivin --- .../captain/assistant/DocumentCard.vue | 29 ++-- .../document/CreateDocumentDialog.vue | 10 +- .../pageComponents/document/DocumentForm.vue | 158 +++++++++++++++++- .../components-next/combobox/ComboBox.vue | 8 +- .../dashboard/i18n/locale/en/helpCenter.json | 52 ++++++ .../i18n/locale/en/integrations.json | 17 ++ .../shared/helpers/documentHelper.js | 38 +++++ .../helpers/specs/documentHelper.spec.js | 111 ++++++++++++ 8 files changed, 395 insertions(+), 28 deletions(-) create mode 100644 app/javascript/shared/helpers/documentHelper.js create mode 100644 app/javascript/shared/helpers/specs/documentHelper.spec.js diff --git a/app/javascript/dashboard/components-next/captain/assistant/DocumentCard.vue b/app/javascript/dashboard/components-next/captain/assistant/DocumentCard.vue index d6e546581..bb5f03451 100644 --- a/app/javascript/dashboard/components-next/captain/assistant/DocumentCard.vue +++ b/app/javascript/dashboard/components-next/captain/assistant/DocumentCard.vue @@ -4,6 +4,10 @@ import { useToggle } from '@vueuse/core'; import { useI18n } from 'vue-i18n'; import { dynamicTime } from 'shared/helpers/timeHelper'; import { usePolicy } from 'dashboard/composables/usePolicy'; +import { + isPdfDocument, + formatDocumentLink, +} from 'shared/helpers/documentHelper'; import CardLayout from 'dashboard/components-next/CardLayout.vue'; import DropdownMenu from 'dashboard/components-next/dropdown-menu/DropdownMenu.vue'; @@ -63,6 +67,11 @@ const menuItems = computed(() => { const createdAt = computed(() => dynamicTime(props.createdAt)); +const displayLink = computed(() => formatDocumentLink(props.externalLink)); +const linkIcon = computed(() => + isPdfDocument(props.externalLink) ? 'i-ph-file-pdf' : 'i-ph-link-simple' +); + const handleAction = ({ action, value }) => { toggleDropdown(false); emit('action', { action, value, id: props.id }); @@ -71,14 +80,14 @@ const handleAction = ({ action, value }) => {