TopBarHeader.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import { useCopyToClipboard } from '#shared/composables/useCopyToClipboard.ts'
  5. import { useTicketView } from '#shared/entities/ticket/composables/useTicketView.ts'
  6. import CommonBreadcrumb from '#desktop/components/CommonBreadcrumb/CommonBreadcrumb.vue'
  7. import HighlightMenu from '#desktop/pages/ticket/components/TicketDetailView/TicketDetailTopBar/TopBarHeader/HighlightMenu.vue'
  8. import TicketInformation from '#desktop/pages/ticket/components/TicketDetailView/TicketDetailTopBar/TopBarHeader/TicketInformation.vue'
  9. import { useTicketInformation } from '#desktop/pages/ticket/composables/useTicketInformation.ts'
  10. import { useTicketNumber } from '#desktop/pages/ticket/composables/useTicketNumber.ts'
  11. interface Props {
  12. hideDetails: boolean
  13. }
  14. const props = defineProps<Props>()
  15. const { ticket } = useTicketInformation()
  16. const { isTicketAgent, isTicketEditable } = useTicketView(ticket)
  17. const { copyToClipboard } = useCopyToClipboard()
  18. const { ticketNumber, ticketNumberWithTicketHook } = useTicketNumber(ticket)
  19. const items = computed(() => [
  20. // :TODO Adjust navigations currently two h1 are present
  21. {
  22. label: 'Tickets',
  23. to: { name: 'ticket-list' },
  24. },
  25. {
  26. label: ticketNumberWithTicketHook.value || '',
  27. noOptionLabelTranslation: true,
  28. to: { name: 'ticket-list' },
  29. },
  30. ])
  31. const detailViewActiveClasses = computed(() => {
  32. if (props.hideDetails)
  33. return [
  34. 'ticket-detail-grid-compact gap-x-2 grid-cols-[1fr_max-content] items-center p-2 px-10',
  35. ]
  36. return [' ticket-detail-grid-full grid-cols-2 gap-y-2.5']
  37. })
  38. </script>
  39. <template>
  40. <header
  41. class="-:p-3 -:relative z-10 grid border-b border-neutral-100 bg-neutral-50 dark:border-gray-900 dark:bg-gray-500"
  42. :class="detailViewActiveClasses"
  43. >
  44. <CommonBreadcrumb
  45. v-if="!hideDetails"
  46. emphasize-last-item
  47. size="small"
  48. :style="{ gridTemplate: 'breadcrumbs' }"
  49. :items="items"
  50. class="flex"
  51. >
  52. <template #trailing>
  53. <CommonIcon
  54. v-if="ticketNumber"
  55. v-tooltip="$t('Copy ticket number')"
  56. :aria-label="$t('Copy ticket number')"
  57. role="button"
  58. name="files"
  59. size="xs"
  60. class="cursor-pointer text-blue-800 ltr:ml-2 rtl:mr-2"
  61. @click="copyToClipboard(ticketNumberWithTicketHook)"
  62. />
  63. </template>
  64. </CommonBreadcrumb>
  65. <HighlightMenu
  66. v-if="isTicketAgent && isTicketEditable"
  67. class="justify-self-end"
  68. :style="{ gridTemplate: 'actions' }"
  69. />
  70. <TicketInformation
  71. :hide-details="hideDetails"
  72. :style="{ gridArea: hideDetails ? 'breadcrumbs' : 'info' }"
  73. :class="{ 'mx-10': !hideDetails }"
  74. />
  75. </header>
  76. </template>
  77. <style scoped>
  78. .ticket-detail-grid-full {
  79. grid-template-areas:
  80. 'breadcrumbs actions'
  81. 'info info';
  82. }
  83. .ticket-detail-grid-compact {
  84. grid-template-areas: 'breadcrumbs actions';
  85. }
  86. </style>