facebook.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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', 'desktop'],
  15. label: __('Reply'),
  16. name: type,
  17. icon: 'reply',
  18. view: {
  19. agent: ['change'],
  20. },
  21. perform(ticket, article, { openReplyForm }) {
  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. openReplyForm(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', 'desktop'],
  38. value: 'facebook feed comment',
  39. label: __('Facebook'),
  40. buttonLabel: __('Add comment'),
  41. icon: 'facebook',
  42. view: {
  43. agent: ['change'],
  44. },
  45. fields: {},
  46. internal: false,
  47. contentType: 'text/plain',
  48. }
  49. return [type]
  50. },
  51. }
  52. export default actionPlugin