ActivityMessage.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { toRef } from 'vue'
  4. import CommonAvatar from '#shared/components/CommonAvatar/CommonAvatar.vue'
  5. import CommonUserAvatar from '#shared/components/CommonUserAvatar/CommonUserAvatar.vue'
  6. import { useActivityMessage } from '#shared/composables/activity-message/useActivityMessage.ts'
  7. import type { OnlineNotification } from '#shared/graphql/types.ts'
  8. import { markup } from '#shared/utils/markup.ts'
  9. interface Props {
  10. activity: OnlineNotification
  11. }
  12. const props = defineProps<Props>()
  13. const { builder, message, link } = useActivityMessage(toRef(props, 'activity'))
  14. defineEmits<{
  15. seen: []
  16. }>()
  17. </script>
  18. <template>
  19. <component
  20. :is="link ? 'CommonLink' : 'div'"
  21. v-if="builder"
  22. class="flex flex-1 border-b border-white/10 py-4"
  23. :link="link"
  24. @click="!activity.seen ? $emit('seen') : undefined"
  25. >
  26. <div class="flex items-center ltr:mr-4 rtl:ml-4">
  27. <CommonUserAvatar
  28. v-if="activity.createdBy"
  29. :entity="activity.createdBy"
  30. no-indicator
  31. />
  32. <CommonAvatar v-else class="bg-red-bright text-white" icon="lock" />
  33. </div>
  34. <div class="flex flex-col">
  35. <!-- eslint-disable vue/no-v-html -->
  36. <div class="text-lg leading-5" v-html="markup(message)" />
  37. <div class="text-gray mt-1 flex">
  38. <CommonDateTime :date-time="activity.createdAt" type="relative" />
  39. </div>
  40. </div>
  41. </component>
  42. </template>