CommonTicketLabel.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import type { TicketById } from '#shared/entities/ticket/types.ts'
  5. import { EnumTicketStateColorCode } from '#shared/graphql/types.ts'
  6. import CommonTicketStateIndicatorIcon from '#desktop/components/CommonTicketStateIndicatorIcon/CommonTicketStateIndicatorIcon.vue'
  7. interface Props {
  8. ticket?: Partial<TicketById> | null
  9. unauthorized?: boolean
  10. classes?: {
  11. indicator?: string
  12. label?: string
  13. }
  14. }
  15. const props = defineProps<Props>()
  16. const ticketId = computed(() => `ticket-${props.ticket?.internalId}`)
  17. const ticketState = computed(() => {
  18. return props.ticket?.state?.name || ''
  19. })
  20. const ticketColorCode = computed(() => {
  21. return props.ticket?.stateColorCode || EnumTicketStateColorCode.Open
  22. })
  23. </script>
  24. <template>
  25. <div v-if="unauthorized" class="flex grow items-center gap-2">
  26. <CommonIcon class="shrink-0 text-red-500" size="tiny" name="x-lg" />
  27. <CommonLabel class="text-black dark:text-white">{{
  28. $t('Access denied')
  29. }}</CommonLabel>
  30. </div>
  31. <CommonLink
  32. v-else
  33. class="flex grow items-start gap-2 break-words rounded-md hover:no-underline focus-visible:rounded-md focus-visible:outline-none group-hover/tab:bg-blue-600 group-hover/tab:dark:bg-blue-900"
  34. style="word-break: break-word"
  35. :link="`/tickets/${ticket?.internalId}`"
  36. internal
  37. >
  38. <CommonTicketStateIndicatorIcon
  39. class="ms-0.5 mt-1 shrink-0"
  40. :class="classes?.indicator || ''"
  41. :color-code="ticketColorCode"
  42. :label="ticketState"
  43. :aria-labelledby="ticketId"
  44. icon-size="tiny"
  45. />
  46. <CommonLabel
  47. :id="ticketId"
  48. class="mt-0.5 text-blue-800"
  49. :class="classes?.label"
  50. >
  51. {{ ticket?.title }}
  52. </CommonLabel>
  53. </CommonLink>
  54. </template>