action.async.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import { FETCH_CONFIG } from './helper.js'
  2. export const getHtmlDocContent = (user, apiUrl, idWorkspace, idContent) =>
  3. fetch(`${apiUrl}/workspaces/${idWorkspace}/html-documents/${idContent}`, {
  4. headers: {
  5. 'Authorization': 'Basic ' + user.auth,
  6. ...FETCH_CONFIG.headers
  7. },
  8. method: 'GET'
  9. })
  10. export const getHtmlDocComment = (user, apiUrl, idWorkspace, idContent) =>
  11. fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/comments`, {
  12. headers: {
  13. 'Authorization': 'Basic ' + user.auth,
  14. ...FETCH_CONFIG.headers
  15. },
  16. method: 'GET'
  17. })
  18. export const getHtmlDocRevision = (user, apiUrl, idWorkspace, idContent) =>
  19. fetch(`${apiUrl}/workspaces/${idWorkspace}/html-documents/${idContent}/revisions`, {
  20. headers: {
  21. 'Authorization': 'Basic ' + user.auth,
  22. ...FETCH_CONFIG.headers
  23. },
  24. method: 'GET'
  25. })
  26. export const postHtmlDocNewComment = (user, apiUrl, idWorkspace, idContent, newComment) =>
  27. fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/comments`, {
  28. headers: {
  29. 'Authorization': 'Basic ' + user.auth,
  30. ...FETCH_CONFIG.headers
  31. },
  32. method: 'POST',
  33. body: JSON.stringify({
  34. raw_content: newComment
  35. })
  36. })
  37. export const putHtmlDocContent = (user, apiUrl, idWorkspace, idContent, label, newContent) =>
  38. fetch(`${apiUrl}/workspaces/${idWorkspace}/html-documents/${idContent}`, {
  39. headers: {
  40. 'Authorization': 'Basic ' + user.auth,
  41. ...FETCH_CONFIG.headers
  42. },
  43. method: 'PUT',
  44. body: JSON.stringify({
  45. label: label,
  46. raw_content: newContent
  47. })
  48. })
  49. export const putHtmlDocStatus = (user, apiUrl, idWorkspace, idContent, newStatus) =>
  50. fetch(`${apiUrl}/workspaces/${idWorkspace}/html-documents/${idContent}/status`, {
  51. headers: {
  52. 'Authorization': 'Basic ' + user.auth,
  53. ...FETCH_CONFIG.headers
  54. },
  55. method: 'PUT',
  56. body: JSON.stringify({
  57. status: newStatus
  58. })
  59. })
  60. export const postHtmlDocContent = (user, apiUrl, idWorkspace, idFolder, contentType, newContentName) =>
  61. fetch(`${apiUrl}/workspaces/${idWorkspace}/contents`, {
  62. headers: {
  63. 'Authorization': 'Basic ' + user.auth,
  64. ...FETCH_CONFIG.headers
  65. },
  66. method: 'POST',
  67. body: JSON.stringify({
  68. parent_id: idFolder,
  69. content_type: contentType,
  70. label: newContentName
  71. })
  72. })
  73. export const putHtmlDocIsArchived = (user, apiUrl, idWorkspace, idContent) => {
  74. return fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/archive`, {
  75. headers: {
  76. 'Authorization': 'Basic ' + user.auth,
  77. ...FETCH_CONFIG.headers
  78. },
  79. method: 'PUT'
  80. })
  81. }
  82. export const putHtmlDocIsDeleted = (user, apiUrl, idWorkspace, idContent) => {
  83. return fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/delete`, {
  84. headers: {
  85. 'Authorization': 'Basic ' + user.auth,
  86. ...FETCH_CONFIG.headers
  87. },
  88. method: 'PUT'
  89. })
  90. }
  91. export const putHtmlDocRestoreArchived = (user, apiUrl, idWorkspace, idContent) => {
  92. return fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/unarchive`, {
  93. headers: {
  94. 'Authorization': 'Basic ' + user.auth,
  95. ...FETCH_CONFIG.headers
  96. },
  97. method: 'PUT'
  98. })
  99. }
  100. export const putHtmlDocRestoreDeleted = (user, apiUrl, idWorkspace, idContent) => {
  101. return fetch(`${apiUrl}/workspaces/${idWorkspace}/contents/${idContent}/undelete`, {
  102. headers: {
  103. 'Authorization': 'Basic ' + user.auth,
  104. ...FETCH_CONFIG.headers
  105. },
  106. method: 'PUT'
  107. })
  108. }
  109. export const putHtmlDocRead = (user, apiUrl, idWorkspace, idContent) => {
  110. return fetch(`${apiUrl}/users/${user.user_id}/workspaces/${idWorkspace}/contents/${idContent}/read`, {
  111. headers: {
  112. 'Authorization': 'Basic ' + user.auth,
  113. ...FETCH_CONFIG.headers
  114. },
  115. method: 'PUT'
  116. })
  117. }