TicketSidebarAttachmentContent.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, toRef } from 'vue'
  4. import CommonFilePreview from '#shared/components/CommonFilePreview/CommonFilePreview.vue'
  5. import { useAttachments } from '#shared/composables/useAttachments.ts'
  6. import type { Attachment } from '#shared/entities/attachment/types.ts'
  7. import CommonLoader from '#desktop/components/CommonLoader/CommonLoader.vue'
  8. import { useFilePreviewViewer } from '#desktop/composables/useFilePreviewViewer.ts'
  9. import type { TicketSidebarContentProps } from '#desktop/pages/ticket/types/sidebar.ts'
  10. import TicketSidebarContent from '../TicketSidebarContent.vue'
  11. interface Props extends TicketSidebarContentProps {
  12. ticketAttachments: Attachment[]
  13. loading: boolean
  14. }
  15. const props = defineProps<Props>()
  16. const { attachments: attachmentsWithUrls } = useAttachments({
  17. attachments: toRef(props, 'ticketAttachments'),
  18. })
  19. const { showPreview } = useFilePreviewViewer(
  20. computed(() => attachmentsWithUrls.value),
  21. )
  22. </script>
  23. <template>
  24. <TicketSidebarContent :title="sidebarPlugin.title" :icon="sidebarPlugin.icon">
  25. <CommonLoader :loading="loading">
  26. <div
  27. v-if="ticketAttachments && ticketAttachments.length > 0"
  28. class="flex flex-col rounded-lg bg-blue-200 p-1 text-gray-100 dark:bg-gray-700 dark:text-neutral-400"
  29. >
  30. <CommonFilePreview
  31. v-for="attachment of attachmentsWithUrls"
  32. :key="attachment.internalId"
  33. :download-url="attachment.downloadUrl"
  34. :preview-url="attachment.preview"
  35. :file="attachment"
  36. :no-preview="!$c.ui_ticket_zoom_attachments_preview"
  37. no-remove
  38. @preview="($event, type) => showPreview(type, attachment)"
  39. />
  40. </div>
  41. <CommonLabel v-else>
  42. {{ $t('No attached files') }}
  43. </CommonLabel>
  44. </CommonLoader>
  45. </TicketSidebarContent>
  46. </template>