Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
167 lines
5.4 KiB
Vue
167 lines
5.4 KiB
Vue
<script setup>
|
|
import { computed, onMounted, ref, nextTick } from 'vue';
|
|
import { useMapGetter, useStore } from 'dashboard/composables/store';
|
|
import { useRoute } from 'vue-router';
|
|
import { FEATURE_FLAGS } from 'dashboard/featureFlags';
|
|
import { useAccount } from 'dashboard/composables/useAccount';
|
|
|
|
import DeleteDialog from 'dashboard/components-next/captain/pageComponents/DeleteDialog.vue';
|
|
import DocumentCard from 'dashboard/components-next/captain/assistant/DocumentCard.vue';
|
|
import PageLayout from 'dashboard/components-next/captain/PageLayout.vue';
|
|
import CaptainPaywall from 'dashboard/components-next/captain/pageComponents/Paywall.vue';
|
|
import RelatedResponses from 'dashboard/components-next/captain/pageComponents/document/RelatedResponses.vue';
|
|
import CreateDocumentDialog from 'dashboard/components-next/captain/pageComponents/document/CreateDocumentDialog.vue';
|
|
import DocumentPageEmptyState from 'dashboard/components-next/captain/pageComponents/emptyStates/DocumentPageEmptyState.vue';
|
|
import FeatureSpotlightPopover from 'dashboard/components-next/feature-spotlight/FeatureSpotlightPopover.vue';
|
|
import LimitBanner from 'dashboard/components-next/captain/pageComponents/document/LimitBanner.vue';
|
|
|
|
const route = useRoute();
|
|
const store = useStore();
|
|
|
|
const { isOnChatwootCloud } = useAccount();
|
|
const uiFlags = useMapGetter('captainDocuments/getUIFlags');
|
|
const documents = useMapGetter('captainDocuments/getRecords');
|
|
const isFetching = computed(() => uiFlags.value.fetchingList);
|
|
const documentsMeta = useMapGetter('captainDocuments/getMeta');
|
|
|
|
const selectedAssistantId = computed(() => Number(route.params.assistantId));
|
|
|
|
const selectedDocument = ref(null);
|
|
const deleteDocumentDialog = ref(null);
|
|
|
|
const handleDelete = () => {
|
|
deleteDocumentDialog.value.dialogRef.open();
|
|
};
|
|
|
|
const showRelatedResponses = ref(false);
|
|
const showCreateDialog = ref(false);
|
|
const createDocumentDialog = ref(null);
|
|
const relationQuestionDialog = ref(null);
|
|
|
|
const handleShowRelatedDocument = () => {
|
|
showRelatedResponses.value = true;
|
|
nextTick(() => relationQuestionDialog.value.dialogRef.open());
|
|
};
|
|
const handleCreateDocument = () => {
|
|
showCreateDialog.value = true;
|
|
nextTick(() => createDocumentDialog.value.dialogRef.open());
|
|
};
|
|
|
|
const handleRelatedResponseClose = () => {
|
|
showRelatedResponses.value = false;
|
|
};
|
|
|
|
const handleCreateDialogClose = () => {
|
|
showCreateDialog.value = false;
|
|
};
|
|
|
|
const handleAction = ({ action, id }) => {
|
|
selectedDocument.value = documents.value.find(
|
|
captainDocument => id === captainDocument.id
|
|
);
|
|
|
|
nextTick(() => {
|
|
if (action === 'delete') {
|
|
handleDelete();
|
|
} else if (action === 'viewRelatedQuestions') {
|
|
handleShowRelatedDocument();
|
|
}
|
|
});
|
|
};
|
|
|
|
const fetchDocuments = (page = 1) => {
|
|
const filterParams = { page };
|
|
|
|
if (selectedAssistantId.value) {
|
|
filterParams.assistantId = selectedAssistantId.value;
|
|
}
|
|
store.dispatch('captainDocuments/get', filterParams);
|
|
};
|
|
|
|
const onPageChange = page => fetchDocuments(page);
|
|
|
|
const onDeleteSuccess = () => {
|
|
if (documents.value?.length === 0 && documentsMeta.value?.page > 1) {
|
|
onPageChange(documentsMeta.value.page - 1);
|
|
}
|
|
};
|
|
|
|
onMounted(() => {
|
|
fetchDocuments();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<PageLayout
|
|
:header-title="$t('CAPTAIN.DOCUMENTS.HEADER')"
|
|
:button-label="$t('CAPTAIN.DOCUMENTS.ADD_NEW')"
|
|
:button-policy="['administrator']"
|
|
:total-count="documentsMeta.totalCount"
|
|
:current-page="documentsMeta.page"
|
|
:show-pagination-footer="!isFetching && !!documents.length"
|
|
:is-fetching="isFetching"
|
|
:is-empty="!documents.length"
|
|
:show-know-more="false"
|
|
:feature-flag="FEATURE_FLAGS.CAPTAIN"
|
|
@update:current-page="onPageChange"
|
|
@click="handleCreateDocument"
|
|
>
|
|
<template #knowMore>
|
|
<FeatureSpotlightPopover
|
|
:button-label="$t('CAPTAIN.HEADER_KNOW_MORE')"
|
|
:title="$t('CAPTAIN.DOCUMENTS.EMPTY_STATE.FEATURE_SPOTLIGHT.TITLE')"
|
|
:note="$t('CAPTAIN.DOCUMENTS.EMPTY_STATE.FEATURE_SPOTLIGHT.NOTE')"
|
|
:hide-actions="!isOnChatwootCloud"
|
|
fallback-thumbnail="/assets/images/dashboard/captain/document-popover-light.svg"
|
|
fallback-thumbnail-dark="/assets/images/dashboard/captain/document-popover-dark.svg"
|
|
learn-more-url="https://chwt.app/captain-document"
|
|
/>
|
|
</template>
|
|
|
|
<template #emptyState>
|
|
<DocumentPageEmptyState @click="handleCreateDocument" />
|
|
</template>
|
|
|
|
<template #paywall>
|
|
<CaptainPaywall />
|
|
</template>
|
|
|
|
<template #body>
|
|
<LimitBanner class="mb-5" />
|
|
|
|
<div class="flex flex-col gap-4">
|
|
<DocumentCard
|
|
v-for="doc in documents"
|
|
:id="doc.id"
|
|
:key="doc.id"
|
|
:name="doc.name || doc.external_link"
|
|
:external-link="doc.external_link"
|
|
:assistant="doc.assistant"
|
|
:created-at="doc.created_at"
|
|
@action="handleAction"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<RelatedResponses
|
|
v-if="showRelatedResponses"
|
|
ref="relationQuestionDialog"
|
|
:captain-document="selectedDocument"
|
|
@close="handleRelatedResponseClose"
|
|
/>
|
|
<CreateDocumentDialog
|
|
v-if="showCreateDialog"
|
|
ref="createDocumentDialog"
|
|
:assistant-id="selectedAssistantId"
|
|
@close="handleCreateDialogClose"
|
|
/>
|
|
<DeleteDialog
|
|
v-if="selectedDocument"
|
|
ref="deleteDocumentDialog"
|
|
:entity="selectedDocument"
|
|
type="Documents"
|
|
@delete-success="onDeleteSuccess"
|
|
/>
|
|
</PageLayout>
|
|
</template>
|