facebook.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type {
  3. TicketArticleAction,
  4. TicketArticleActionPlugin,
  5. TicketArticleType,
  6. } from './types.ts'
  7. const actionPlugin: TicketArticleActionPlugin = {
  8. order: 300,
  9. addActions(ticket, article) {
  10. const type = article.type?.name
  11. if (type !== 'facebook feed comment' && type !== 'facebook feed post')
  12. return []
  13. const action: TicketArticleAction = {
  14. apps: ['mobile'],
  15. label: __('Reply'),
  16. name: type,
  17. icon: 'reply',
  18. view: {
  19. agent: ['change'],
  20. },
  21. perform(ticket, article, { openReplyDialog }) {
  22. const articleData = {
  23. // always a comment, doesn't depend on current article type
  24. articleType: 'facebook feed comment',
  25. body: '',
  26. inReplyTo: null,
  27. }
  28. openReplyDialog(articleData)
  29. },
  30. }
  31. return [action]
  32. },
  33. addTypes(ticket) {
  34. const descriptionType = ticket.createArticleType?.name
  35. if (descriptionType !== 'facebook feed post') return []
  36. const type: TicketArticleType = {
  37. apps: ['mobile'],
  38. value: 'facebook feed comment',
  39. label: __('Facebook'),
  40. icon: 'facebook',
  41. view: {
  42. agent: ['change'],
  43. },
  44. fields: {},
  45. internal: false,
  46. contentType: 'text/plain',
  47. }
  48. return [type]
  49. },
  50. }
  51. export default actionPlugin