ActivityMessage.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. /* eslint-disable vue/no-v-html */
  4. import { computed } from 'vue'
  5. import log from '@shared/utils/log'
  6. import type { ActivityMessageMetaObject } from '@shared/graphql/types'
  7. import { userDisplayName } from '@shared/entities/user/utils/getUserDisplayName'
  8. import { markup } from '@shared/utils/markup'
  9. import CommonUserAvatar from '../CommonUserAvatar/CommonUserAvatar.vue'
  10. import type { AvatarUser } from '../CommonUserAvatar'
  11. import { activityMessageBuilder } from './builders'
  12. export interface Props {
  13. typeName: string
  14. objectName: string
  15. metaObject: ActivityMessageMetaObject
  16. createdAt: string
  17. createdBy: AvatarUser
  18. }
  19. const props = defineProps<Props>()
  20. const builder = computed(() => activityMessageBuilder[props.objectName])
  21. if (!builder.value) {
  22. log.error(`Object missing ${props.objectName}.`)
  23. }
  24. const message = builder.value?.messageText(
  25. props.typeName,
  26. userDisplayName(props.createdBy),
  27. props.metaObject,
  28. )
  29. if (builder.value && !message) {
  30. log.error(
  31. `Unknow action for (${props.objectName}/${props.typeName}), extend activityMessages() of model.`,
  32. )
  33. }
  34. </script>
  35. <template>
  36. <CommonLink
  37. v-if="builder"
  38. class="flex flex-1 border-b border-white/10 py-4"
  39. :link="builder.path(metaObject)"
  40. >
  41. <div class="flex items-center ltr:mr-4 rtl:ml-4">
  42. <CommonUserAvatar :entity="createdBy" />
  43. </div>
  44. <div class="flex flex-col">
  45. <div class="text-lg leading-5" v-html="markup(message)" />
  46. <div class="mt-1 flex text-gray">
  47. <CommonDateTime :date-time="createdAt" type="relative" />
  48. </div>
  49. </div>
  50. </CommonLink>
  51. </template>