strapi-plugin-comments 2.0.8 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/README.md +45 -11
  2. package/admin/src/translations/en.json +1 -0
  3. package/admin/src/translations/fr.json +132 -1
  4. package/admin/src/translations/pt-BR.json +132 -0
  5. package/build/README.md +818 -0
  6. package/build/admin/src/components/ActionButton/styles.d.ts +2 -0
  7. package/build/admin/src/components/ActionButton/styles.js +17 -0
  8. package/build/admin/src/components/ConfirmationDialog/index.d.ts +26 -0
  9. package/build/admin/src/components/ConfirmationDialog/index.js +104 -0
  10. package/build/admin/src/components/DiscussionStatus/index.d.ts +9 -0
  11. package/build/admin/src/components/DiscussionStatus/index.js +38 -0
  12. package/build/admin/src/components/DiscussionThread/index.d.ts +16 -0
  13. package/build/admin/src/components/DiscussionThread/index.js +99 -0
  14. package/build/admin/src/components/DiscussionThreadItem/index.d.ts +9 -0
  15. package/build/admin/src/components/DiscussionThreadItem/index.js +72 -0
  16. package/build/admin/src/components/DiscussionThreadItem/styles.d.ts +4 -0
  17. package/build/admin/src/components/DiscussionThreadItem/styles.js +27 -0
  18. package/build/admin/src/components/DiscussionThreadItemActions/index.d.ts +19 -0
  19. package/build/admin/src/components/DiscussionThreadItemActions/index.js +414 -0
  20. package/build/admin/src/components/DiscussionThreadItemActions/styles.d.ts +2 -0
  21. package/build/admin/src/components/DiscussionThreadItemActions/styles.js +17 -0
  22. package/build/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.d.ts +17 -0
  23. package/build/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +103 -0
  24. package/build/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.d.ts +2 -0
  25. package/build/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.js +15 -0
  26. package/build/admin/src/components/DiscussionThreadItemFooter/index.d.ts +16 -0
  27. package/build/admin/src/components/DiscussionThreadItemFooter/index.js +73 -0
  28. package/build/admin/src/components/DiscussionThreadItemFooter/styles.d.ts +3 -0
  29. package/build/admin/src/components/DiscussionThreadItemFooter/styles.js +25 -0
  30. package/build/admin/src/components/DiscussionThreadItemReviewAction/index.d.ts +30 -0
  31. package/build/admin/src/components/DiscussionThreadItemReviewAction/index.js +233 -0
  32. package/build/admin/src/components/FormSwitch/index.d.ts +11 -0
  33. package/build/admin/src/components/FormSwitch/index.js +39 -0
  34. package/build/admin/src/components/FormSwitch/styles.d.ts +2 -0
  35. package/build/admin/src/components/FormSwitch/styles.js +16 -0
  36. package/build/admin/src/components/IconButton/styles.d.ts +2 -0
  37. package/build/admin/src/components/IconButton/styles.js +27 -0
  38. package/build/admin/src/components/Initializer/index.d.ts +3 -0
  39. package/build/admin/src/components/Initializer/index.js +14 -0
  40. package/build/admin/src/components/LoadingIndicatorOverlay/index.d.ts +3 -0
  41. package/build/admin/src/components/LoadingIndicatorOverlay/index.js +18 -0
  42. package/build/admin/src/components/LoadingIndicatorOverlay/styles.d.ts +3 -0
  43. package/build/admin/src/components/LoadingIndicatorOverlay/styles.js +32 -0
  44. package/build/admin/src/components/Nav/index.d.ts +7 -0
  45. package/build/admin/src/components/Nav/index.js +72 -0
  46. package/build/admin/src/components/PluginIcon/index.d.ts +3 -0
  47. package/build/admin/src/components/PluginIcon/index.js +13 -0
  48. package/build/admin/src/components/ReportsReviewModal/index.d.ts +21 -0
  49. package/build/admin/src/components/ReportsReviewModal/index.js +72 -0
  50. package/build/admin/src/components/ReportsReviewTable/index.d.ts +21 -0
  51. package/build/admin/src/components/ReportsReviewTable/index.js +321 -0
  52. package/build/admin/src/components/StatusBadge/index.d.ts +11 -0
  53. package/build/admin/src/components/StatusBadge/index.js +22 -0
  54. package/build/admin/src/components/StatusBadge/styles.d.ts +2 -0
  55. package/build/admin/src/components/StatusBadge/styles.js +25 -0
  56. package/build/admin/src/components/TableFilters/index.d.ts +10 -0
  57. package/build/admin/src/components/TableFilters/index.js +109 -0
  58. package/build/admin/src/components/TablePagination/index.d.ts +15 -0
  59. package/build/admin/src/components/TablePagination/index.js +45 -0
  60. package/build/admin/src/components/icons/comments.d.ts +9 -0
  61. package/build/admin/src/components/icons/comments.js +23 -0
  62. package/build/admin/src/components/icons/index.d.ts +6 -0
  63. package/build/admin/src/components/icons/index.js +21 -0
  64. package/build/admin/src/components/icons/lock.d.ts +11 -0
  65. package/build/admin/src/components/icons/lock.js +29 -0
  66. package/build/admin/src/components/icons/review.d.ts +11 -0
  67. package/build/admin/src/components/icons/review.js +31 -0
  68. package/build/admin/src/components/icons/unlock.d.ts +11 -0
  69. package/build/admin/src/components/icons/unlock.js +29 -0
  70. package/build/admin/src/hooks/useConfig.d.ts +8 -0
  71. package/build/admin/src/hooks/useConfig.js +52 -0
  72. package/build/admin/src/index.d.ts +7 -0
  73. package/build/admin/src/index.js +137 -0
  74. package/build/admin/src/pages/App/index.d.ts +4 -0
  75. package/build/admin/src/pages/App/index.js +90 -0
  76. package/build/admin/src/pages/App/reducer/actions.d.ts +8 -0
  77. package/build/admin/src/pages/App/reducer/actions.js +12 -0
  78. package/build/admin/src/pages/App/reducer/constants.d.ts +4 -0
  79. package/build/admin/src/pages/App/reducer/constants.js +7 -0
  80. package/build/admin/src/pages/App/reducer/index.d.ts +14 -0
  81. package/build/admin/src/pages/App/reducer/index.js +31 -0
  82. package/build/admin/src/pages/App/reducer/init.d.ts +3 -0
  83. package/build/admin/src/pages/App/reducer/init.js +9 -0
  84. package/build/admin/src/pages/App/reducer/selectors.d.ts +6 -0
  85. package/build/admin/src/pages/App/reducer/selectors.js +20 -0
  86. package/build/admin/src/pages/App/utils/api.d.ts +2 -0
  87. package/build/admin/src/pages/App/utils/api.js +16 -0
  88. package/build/admin/src/pages/ComingSoonPage/index.d.ts +3 -0
  89. package/build/admin/src/pages/ComingSoonPage/index.js +78 -0
  90. package/build/admin/src/pages/Details/components/DetailsEntity/index.d.ts +18 -0
  91. package/build/admin/src/pages/Details/components/DetailsEntity/index.js +132 -0
  92. package/build/admin/src/pages/Details/components/DetailsFilters/index.d.ts +12 -0
  93. package/build/admin/src/pages/Details/components/DetailsFilters/index.js +48 -0
  94. package/build/admin/src/pages/Details/components/DetailsFilters/styles.d.ts +2 -0
  95. package/build/admin/src/pages/Details/components/DetailsFilters/styles.js +16 -0
  96. package/build/admin/src/pages/Details/index.d.ts +4 -0
  97. package/build/admin/src/pages/Details/index.js +216 -0
  98. package/build/admin/src/pages/Discover/components/DiscoverTableRow/index.d.ts +20 -0
  99. package/build/admin/src/pages/Discover/components/DiscoverTableRow/index.js +344 -0
  100. package/build/admin/src/pages/Discover/components/DiscoverTableRow/styles.d.ts +2 -0
  101. package/build/admin/src/pages/Discover/components/DiscoverTableRow/styles.js +16 -0
  102. package/build/admin/src/pages/Discover/index.d.ts +4 -0
  103. package/build/admin/src/pages/Discover/index.js +332 -0
  104. package/build/admin/src/pages/Discover/utils/api.d.ts +2 -0
  105. package/build/admin/src/pages/Discover/utils/api.js +23 -0
  106. package/build/admin/src/pages/Discover/utils/filtersSchema.d.ts +11 -0
  107. package/build/admin/src/pages/Discover/utils/filtersSchema.js +11 -0
  108. package/build/admin/src/pages/Settings/components/RestartAlert/styles.d.ts +2 -0
  109. package/build/admin/src/pages/Settings/components/RestartAlert/styles.js +16 -0
  110. package/build/admin/src/pages/Settings/index.d.ts +3 -0
  111. package/build/admin/src/pages/Settings/index.js +712 -0
  112. package/build/admin/src/pages/Settings/utils/api.d.ts +7 -0
  113. package/build/admin/src/pages/Settings/utils/api.js +80 -0
  114. package/build/admin/src/pages/utils/api.d.ts +12 -0
  115. package/build/admin/src/pages/utils/api.js +83 -0
  116. package/build/admin/src/permissions.d.ts +28 -0
  117. package/build/admin/src/permissions.js +65 -0
  118. package/build/admin/src/pluginId.d.ts +2 -0
  119. package/build/admin/src/pluginId.js +50 -0
  120. package/build/admin/src/reducers.d.ts +12 -0
  121. package/build/admin/src/reducers.js +14 -0
  122. package/build/admin/src/translations/en.json +132 -0
  123. package/build/admin/src/translations/fr.json +1 -0
  124. package/build/admin/src/translations/pt-BR.json +132 -0
  125. package/build/admin/src/utils/axiosInstance.d.ts +3 -0
  126. package/build/admin/src/utils/axiosInstance.js +37 -0
  127. package/build/admin/src/utils/constants.d.ts +25 -0
  128. package/build/admin/src/utils/constants.js +30 -0
  129. package/build/admin/src/utils/getApiUrl.d.ts +3 -0
  130. package/build/admin/src/utils/getApiUrl.js +6 -0
  131. package/build/admin/src/utils/getMessage.d.ts +4 -0
  132. package/build/admin/src/utils/getMessage.js +25 -0
  133. package/build/admin/src/utils/getRelatedGroups.d.ts +4 -0
  134. package/build/admin/src/utils/getRelatedGroups.js +6 -0
  135. package/build/admin/src/utils/getUrl.d.ts +3 -0
  136. package/build/admin/src/utils/getUrl.js +6 -0
  137. package/build/admin/src/utils/handleAPIError.d.ts +4 -0
  138. package/build/admin/src/utils/handleAPIError.js +20 -0
  139. package/build/admin/src/utils/index.d.ts +12 -0
  140. package/build/admin/src/utils/index.js +97 -0
  141. package/build/admin/src/utils/parseRegExp.d.ts +6 -0
  142. package/build/admin/src/utils/parseRegExp.js +11 -0
  143. package/build/admin/src/utils/renderEntryTitle.d.ts +4 -0
  144. package/build/admin/src/utils/renderEntryTitle.js +16 -0
  145. package/build/admin/src/utils/renderInitials.d.ts +3 -0
  146. package/build/admin/src/utils/renderInitials.js +11 -0
  147. package/build/admin/src/utils/resolveCommentStatus.d.ts +4 -0
  148. package/build/admin/src/utils/resolveCommentStatus.js +32 -0
  149. package/build/admin/src/utils/resolveCommentStatusColor.d.ts +4 -0
  150. package/build/admin/src/utils/resolveCommentStatusColor.js +22 -0
  151. package/build/content-types/comment.d.ts +91 -0
  152. package/build/content-types/comment.js +92 -0
  153. package/build/content-types/index.d.ts +143 -0
  154. package/build/content-types/index.js +18 -0
  155. package/build/content-types/report.d.ts +48 -0
  156. package/build/content-types/report.js +49 -0
  157. package/build/package.json +94 -0
  158. package/build/permissions.d.ts +18 -0
  159. package/build/permissions.js +18 -0
  160. package/build/server/bootstrap.d.ts +4 -0
  161. package/build/server/bootstrap.js +65 -0
  162. package/build/server/config/index.d.ts +4 -0
  163. package/build/server/config/index.js +19 -0
  164. package/build/server/controllers/admin.d.ts +4 -0
  165. package/build/server/controllers/admin.js +124 -0
  166. package/build/server/controllers/client.d.ts +4 -0
  167. package/build/server/controllers/client.js +111 -0
  168. package/build/server/controllers/index.d.ts +6 -0
  169. package/build/server/controllers/index.js +15 -0
  170. package/build/server/controllers/utils/functions.d.ts +7 -0
  171. package/build/server/controllers/utils/functions.js +24 -0
  172. package/build/server/controllers/utils/parsers.d.ts +15 -0
  173. package/build/server/controllers/utils/parsers.js +25 -0
  174. package/build/server/destroy.d.ts +3 -0
  175. package/build/server/destroy.js +3 -0
  176. package/build/server/graphql/index.d.ts +4 -0
  177. package/build/server/graphql/index.js +37 -0
  178. package/build/server/graphql/mutations/createAbuseReport.d.ts +11 -0
  179. package/build/server/graphql/mutations/createAbuseReport.js +27 -0
  180. package/build/server/graphql/mutations/createComment.d.ts +14 -0
  181. package/build/server/graphql/mutations/createComment.js +26 -0
  182. package/build/server/graphql/mutations/index.d.ts +4 -0
  183. package/build/server/graphql/mutations/index.js +28 -0
  184. package/build/server/graphql/mutations/removeComment.d.ts +11 -0
  185. package/build/server/graphql/mutations/removeComment.js +27 -0
  186. package/build/server/graphql/mutations/updateComment.d.ts +11 -0
  187. package/build/server/graphql/mutations/updateComment.js +27 -0
  188. package/build/server/graphql/queries/findAllFlat.d.ts +19 -0
  189. package/build/server/graphql/queries/findAllFlat.js +47 -0
  190. package/build/server/graphql/queries/findAllInHierarchy.d.ts +18 -0
  191. package/build/server/graphql/queries/findAllInHierarchy.js +38 -0
  192. package/build/server/graphql/queries/index.d.ts +4 -0
  193. package/build/server/graphql/queries/index.js +24 -0
  194. package/build/server/graphql/resolvers-config.d.ts +23 -0
  195. package/build/server/graphql/resolvers-config.js +13 -0
  196. package/build/server/graphql/types/comment-author.d.ts +4 -0
  197. package/build/server/graphql/types/comment-author.js +12 -0
  198. package/build/server/graphql/types/comment-nested.d.ts +4 -0
  199. package/build/server/graphql/types/comment-nested.js +19 -0
  200. package/build/server/graphql/types/comment.d.ts +4 -0
  201. package/build/server/graphql/types/comment.js +18 -0
  202. package/build/server/graphql/types/create-comment-author.d.ts +4 -0
  203. package/build/server/graphql/types/create-comment-author.js +12 -0
  204. package/build/server/graphql/types/create-comment.d.ts +4 -0
  205. package/build/server/graphql/types/create-comment.js +12 -0
  206. package/build/server/graphql/types/create-report.d.ts +4 -0
  207. package/build/server/graphql/types/create-report.js +12 -0
  208. package/build/server/graphql/types/id.d.ts +4 -0
  209. package/build/server/graphql/types/id.js +26 -0
  210. package/build/server/graphql/types/identify-comment-author.d.ts +4 -0
  211. package/build/server/graphql/types/identify-comment-author.js +9 -0
  212. package/build/server/graphql/types/index.d.ts +4 -0
  213. package/build/server/graphql/types/index.js +44 -0
  214. package/build/server/graphql/types/remove-comment.d.ts +4 -0
  215. package/build/server/graphql/types/remove-comment.js +11 -0
  216. package/build/server/graphql/types/report-reason.d.ts +4 -0
  217. package/build/server/graphql/types/report-reason.js +12 -0
  218. package/build/server/graphql/types/report.d.ts +4 -0
  219. package/build/server/graphql/types/report.js +14 -0
  220. package/build/server/graphql/types/response-find-all.d.ts +4 -0
  221. package/build/server/graphql/types/response-find-all.js +10 -0
  222. package/build/server/graphql/types/response-meta.d.ts +4 -0
  223. package/build/server/graphql/types/response-meta.js +9 -0
  224. package/build/server/graphql/types/response-pagination.d.ts +4 -0
  225. package/build/server/graphql/types/response-pagination.js +14 -0
  226. package/build/server/graphql/types/update-comment.d.ts +4 -0
  227. package/build/server/graphql/types/update-comment.js +12 -0
  228. package/build/server/index.d.ts +26 -0
  229. package/build/server/index.js +25 -0
  230. package/build/server/register.d.ts +3 -0
  231. package/build/server/register.js +3 -0
  232. package/build/server/routes/admin.d.ts +4 -0
  233. package/build/server/routes/admin.js +118 -0
  234. package/build/server/routes/client.d.ts +4 -0
  235. package/build/server/routes/client.js +54 -0
  236. package/build/server/routes/index.d.ts +11 -0
  237. package/build/server/routes/index.js +21 -0
  238. package/build/server/services/admin.d.ts +5 -0
  239. package/build/server/services/admin.js +296 -0
  240. package/build/server/services/client.d.ts +5 -0
  241. package/build/server/services/client.js +247 -0
  242. package/build/server/services/common.d.ts +5 -0
  243. package/build/server/services/common.js +266 -0
  244. package/build/server/services/graphql.d.ts +5 -0
  245. package/build/server/services/graphql.js +136 -0
  246. package/build/server/services/index.d.ts +8 -0
  247. package/build/server/services/index.js +16 -0
  248. package/build/server/services/utils/functions.d.ts +13 -0
  249. package/build/server/services/utils/functions.js +141 -0
  250. package/build/server/utils/constants.d.ts +9 -0
  251. package/build/server/utils/constants.js +23 -0
  252. package/build/server/utils/error.d.ts +23 -0
  253. package/build/server/utils/error.js +29 -0
  254. package/build/server/utils/functions.d.ts +14 -0
  255. package/build/server/utils/functions.js +50 -0
  256. package/build/strapi-admin.d.ts +3 -0
  257. package/build/strapi-admin.js +10 -0
  258. package/build/strapi-server.d.ts +177 -0
  259. package/build/strapi-server.js +46 -0
  260. package/build/tsconfig.tsbuildinfo +1 -0
  261. package/build/types/contentTypes.d.ts +46 -0
  262. package/build/types/contentTypes.js +3 -0
  263. package/package.json +3 -3
  264. package/server/controllers/client.js +0 -3
  265. package/server/graphql/queries/findAllFlat.js +6 -2
  266. package/server/services/common.js +2 -2
@@ -0,0 +1,414 @@
1
+ "use strict";
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
11
+ ) {
12
+ desc = {
13
+ enumerable: true,
14
+ get: function () {
15
+ return m[k];
16
+ },
17
+ };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }
21
+ : function (o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ });
25
+ var __setModuleDefault =
26
+ (this && this.__setModuleDefault) ||
27
+ (Object.create
28
+ ? function (o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }
31
+ : function (o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar =
35
+ (this && this.__importStar) ||
36
+ function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null)
40
+ for (var k in mod)
41
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
42
+ __createBinding(result, mod, k);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ var __importDefault =
47
+ (this && this.__importDefault) ||
48
+ function (mod) {
49
+ return mod && mod.__esModule ? mod : { default: mod };
50
+ };
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ const react_1 = __importStar(require("react"));
53
+ const prop_types_1 = __importDefault(require("prop-types"));
54
+ const react_query_1 = require("react-query");
55
+ const react_router_dom_1 = require("react-router-dom");
56
+ const lodash_1 = require("lodash");
57
+ const Flex_1 = require("@strapi/design-system/Flex");
58
+ const IconButton_1 = require("@strapi/design-system/IconButton");
59
+ const helper_plugin_1 = require("@strapi/helper-plugin");
60
+ const icons_1 = require("@strapi/icons");
61
+ const utils_1 = require("../../utils");
62
+ const styles_1 = require("./styles");
63
+ const ConfirmationDialog_1 = __importDefault(require("../ConfirmationDialog"));
64
+ const api_1 = require("../../pages/utils/api");
65
+ const pluginId_1 = require("../../pluginId");
66
+ const icons_2 = require("../icons");
67
+ const DiscussionThreadItemApprovalFlowActions_1 = __importDefault(
68
+ require("../DiscussionThreadItemApprovalFlowActions")
69
+ );
70
+ const StatusBadge_1 = __importDefault(require("../StatusBadge"));
71
+ const styles_2 = require("../IconButton/styles");
72
+ const styles_3 = require("../ActionButton/styles");
73
+ const DiscussionThreadItemReviewAction_1 = __importDefault(
74
+ require("../DiscussionThreadItemReviewAction")
75
+ );
76
+ const DiscussionThreadItemActions = ({
77
+ allowedActions: { canModerate, canAccessReports, canReviewReports },
78
+ ...item
79
+ }) => {
80
+ const {
81
+ id,
82
+ blocked,
83
+ removed,
84
+ blockedThread,
85
+ gotThread,
86
+ threadItemsCount,
87
+ threadFirstItemId,
88
+ pinned,
89
+ preview,
90
+ reports = [],
91
+ approvalStatus,
92
+ } = item;
93
+ const [blockConfirmationVisible, setBlockConfirmationVisible] = (0,
94
+ react_1.useState)(false);
95
+ const [blockThreadConfirmationVisible, setBlockThreadConfirmationVisible] =
96
+ (0, react_1.useState)(false);
97
+ const [blockButtonsDisabled, setBlockButtonsDisabled] = (0, react_1.useState)(
98
+ blockedThread
99
+ );
100
+ const { push } = (0, react_router_dom_1.useHistory)();
101
+ const toggleNotification = (0, helper_plugin_1.useNotification)();
102
+ const queryClient = (0, react_query_1.useQueryClient)();
103
+ const { lockApp, unlockApp } = (0, helper_plugin_1.useOverlayBlocker)();
104
+ const onSuccess =
105
+ (message, stateAction = () => {}) =>
106
+ async () => {
107
+ await queryClient.invalidateQueries("get-details-data");
108
+ toggleNotification({
109
+ type: "success",
110
+ message: `${pluginId_1.pluginId}.${message}`,
111
+ });
112
+ stateAction(false);
113
+ unlockApp();
114
+ };
115
+ const onError = (err) => {
116
+ (0, utils_1.handleAPIError)(err, toggleNotification);
117
+ };
118
+ const blockItemMutation = (0, react_query_1.useMutation)(api_1.blockItem, {
119
+ onSuccess: onSuccess(
120
+ "page.details.actions.comment.block.confirmation.success",
121
+ setBlockConfirmationVisible
122
+ ),
123
+ onError,
124
+ refetchActive: false,
125
+ });
126
+ const unblockItemMutation = (0, react_query_1.useMutation)(
127
+ api_1.unblockItem,
128
+ {
129
+ onSuccess: onSuccess(
130
+ "page.details.actions.comment.unblock.confirmation.success"
131
+ ),
132
+ onError,
133
+ refetchActive: false,
134
+ }
135
+ );
136
+ const blockItemThreadMutation = (0, react_query_1.useMutation)(
137
+ api_1.blockItemThread,
138
+ {
139
+ onSuccess: onSuccess(
140
+ "page.details.actions.thread.block.confirmation.success",
141
+ setBlockThreadConfirmationVisible
142
+ ),
143
+ onError,
144
+ refetchActive: false,
145
+ }
146
+ );
147
+ const unblockItemThreadMutation = (0, react_query_1.useMutation)(
148
+ api_1.unblockItemThread,
149
+ {
150
+ onSuccess: onSuccess(
151
+ "page.details.actions.thread.unblock.confirmation.success"
152
+ ),
153
+ onError,
154
+ refetchActive: false,
155
+ }
156
+ );
157
+ const gotApprovalFlow = !(0, lodash_1.isNil)(approvalStatus);
158
+ const needsApproval = gotApprovalFlow && approvalStatus === "PENDING";
159
+ const isBlocked = blocked || blockedThread;
160
+ const isRejected = gotApprovalFlow && approvalStatus === "REJECTED";
161
+ const openReports = reports?.filter((_) => !_.resolved);
162
+ const hasReports = !(0, lodash_1.isEmpty)(openReports);
163
+ const reviewFlowEnabled =
164
+ (canAccessReports || canReviewReports) && hasReports;
165
+ const hasActiveThread =
166
+ gotThread && !(removed || preview || pinned || blockedThread);
167
+ const isStatusBadgeVisible = isBlocked || reviewFlowEnabled;
168
+ const renderStatus = (props) => {
169
+ const status = (0, utils_1.resolveCommentStatus)({
170
+ ...props,
171
+ reviewFlowEnabled,
172
+ });
173
+ const color = (0, utils_1.resolveCommentStatusColor)(status);
174
+ return react_1.default.createElement(
175
+ StatusBadge_1.default,
176
+ {
177
+ backgroundColor: `${color}100`,
178
+ textColor: `${color}700`,
179
+ color: color,
180
+ },
181
+ (0, utils_1.getMessage)(
182
+ {
183
+ id: `page.common.item.status.${status}`,
184
+ props: {
185
+ count: openReports.length,
186
+ },
187
+ },
188
+ status
189
+ )
190
+ );
191
+ };
192
+ const handleBlockClick = () => setBlockConfirmationVisible(true);
193
+ const handleBlockConfirm = async () => {
194
+ if (canModerate) {
195
+ lockApp();
196
+ blockItemMutation.mutate(id);
197
+ }
198
+ };
199
+ const handleBlockCancel = () => {
200
+ setBlockConfirmationVisible(false);
201
+ };
202
+ const handleUnblockClick = async () => {
203
+ if (canModerate) {
204
+ lockApp();
205
+ unblockItemMutation.mutate(id);
206
+ }
207
+ };
208
+ const handleBlockThreadClick = () => setBlockThreadConfirmationVisible(true);
209
+ const handleBlockThreadConfirm = async () => {
210
+ if (canModerate) {
211
+ lockApp();
212
+ blockItemThreadMutation.mutate(id);
213
+ }
214
+ };
215
+ const handleBlockThreadCancel = () => {
216
+ setBlockThreadConfirmationVisible(false);
217
+ };
218
+ const handleUnblockThreadClick = async () => {
219
+ if (canModerate) {
220
+ lockApp();
221
+ unblockItemThreadMutation.mutate(id);
222
+ }
223
+ };
224
+ const handleDrilldownClick = () => {
225
+ if (hasActiveThread) {
226
+ push((0, utils_1.getUrl)(`discover/${threadFirstItemId}`));
227
+ }
228
+ };
229
+ const handleBlockActionClick = async (mutation, onCallback) => {
230
+ lockApp();
231
+ await mutation.mutateAsync(id);
232
+ onCallback();
233
+ };
234
+ const handleBlockButtonsStateChange = (disabled) =>
235
+ setBlockButtonsDisabled(disabled);
236
+ const anyGroupButtonsVisible =
237
+ needsApproval || reviewFlowEnabled || !blockedThread;
238
+ const isLoading =
239
+ unblockItemMutation.isLoading ||
240
+ blockItemMutation.isLoading ||
241
+ blockItemThreadMutation.isLoading ||
242
+ unblockItemThreadMutation.isLoading;
243
+ if (removed || isRejected || !canModerate) {
244
+ return react_1.default.createElement(
245
+ styles_1.DiscussionThreadItemActionsWrapper,
246
+ { as: Flex_1.Flex, direction: "row" },
247
+ renderStatus(item)
248
+ );
249
+ }
250
+ return react_1.default.createElement(
251
+ react_1.default.Fragment,
252
+ null,
253
+ react_1.default.createElement(
254
+ styles_1.DiscussionThreadItemActionsWrapper,
255
+ { as: Flex_1.Flex, direction: "row" },
256
+ isStatusBadgeVisible && renderStatus(item),
257
+ !blockedThread &&
258
+ (gotThread || pinned) &&
259
+ react_1.default.createElement(
260
+ styles_3.ActionButton,
261
+ {
262
+ onClick: handleBlockThreadClick,
263
+ startIcon: react_1.default.createElement(icons_2.LockIcon, null),
264
+ loading: blockItemThreadMutation.isLoading,
265
+ variant: "danger",
266
+ },
267
+ (0, utils_1.getMessage)(
268
+ "page.details.actions.thread.block",
269
+ "Block thread"
270
+ )
271
+ ),
272
+ blockedThread &&
273
+ (gotThread || pinned) &&
274
+ react_1.default.createElement(
275
+ styles_3.ActionButton,
276
+ {
277
+ onClick: handleUnblockThreadClick,
278
+ startIcon: react_1.default.createElement(icons_2.UnlockIcon, null),
279
+ loading: unblockItemThreadMutation.isLoading,
280
+ variant: "success",
281
+ },
282
+ (0, utils_1.getMessage)(
283
+ "page.details.actions.thread.unblock",
284
+ "Unblock thread"
285
+ )
286
+ ),
287
+ anyGroupButtonsVisible &&
288
+ react_1.default.createElement(
289
+ styles_2.IconButtonGroupStyled,
290
+ { isSingle: true, withMargin: true },
291
+ !blockedThread &&
292
+ !(blocked || needsApproval) &&
293
+ react_1.default.createElement(IconButton_1.IconButton, {
294
+ onClick: handleBlockClick,
295
+ loading: blockItemMutation.isLoading,
296
+ icon: react_1.default.createElement(icons_2.LockIcon, null),
297
+ label: (0, utils_1.getMessage)(
298
+ "page.details.actions.comment.block",
299
+ "Block"
300
+ ),
301
+ }),
302
+ !blockedThread &&
303
+ blocked &&
304
+ react_1.default.createElement(IconButton_1.IconButton, {
305
+ onClick: handleUnblockClick,
306
+ loading: unblockItemMutation.isLoading,
307
+ icon: react_1.default.createElement(icons_2.UnlockIcon, null),
308
+ label: (0, utils_1.getMessage)(
309
+ "page.details.actions.comment.unblock",
310
+ "Unblock"
311
+ ),
312
+ }),
313
+ needsApproval &&
314
+ react_1.default.createElement(
315
+ DiscussionThreadItemApprovalFlowActions_1.default,
316
+ {
317
+ id: id,
318
+ allowedActions: { canModerate },
319
+ queryToInvalidate: "get-details-data",
320
+ }
321
+ ),
322
+ react_1.default.createElement(
323
+ DiscussionThreadItemReviewAction_1.default,
324
+ {
325
+ item: item,
326
+ queryToInvalidate: "get-details-data",
327
+ areBlockButtonsDisabled: blockButtonsDisabled,
328
+ isLoading: isLoading,
329
+ allowedActions: {
330
+ canModerate,
331
+ canAccessReports,
332
+ canReviewReports,
333
+ },
334
+ blockItemMutation: blockItemMutation,
335
+ blockItemThreadMutation: blockItemThreadMutation,
336
+ onBlockButtonsStateChange: handleBlockButtonsStateChange,
337
+ onBlockActionClick: handleBlockActionClick,
338
+ }
339
+ )
340
+ ),
341
+ hasActiveThread &&
342
+ react_1.default.createElement(
343
+ styles_2.IconButtonGroupStyled,
344
+ { isSingle: true, withMargin: true },
345
+ react_1.default.createElement(IconButton_1.IconButton, {
346
+ onClick: handleDrilldownClick,
347
+ icon: react_1.default.createElement(icons_1.Eye, null),
348
+ label: (0, utils_1.getMessage)(
349
+ "page.details.panel.discussion.nav.drilldown",
350
+ "Drilldown thread"
351
+ ),
352
+ style:
353
+ blocked && !blockedThread
354
+ ? { marginTop: "1px", marginRight: ".5rem" }
355
+ : {},
356
+ })
357
+ )
358
+ ),
359
+ !blocked &&
360
+ react_1.default.createElement(
361
+ ConfirmationDialog_1.default,
362
+ {
363
+ isVisible: blockConfirmationVisible,
364
+ isActionAsync: blockItemMutation.isLoading,
365
+ header: (0, utils_1.getMessage)(
366
+ "page.details.actions.comment.block.confirmation.header"
367
+ ),
368
+ labelConfirm: (0, utils_1.getMessage)(
369
+ "page.details.actions.comment.block.confirmation.button.confirm"
370
+ ),
371
+ iconConfirm: react_1.default.createElement(icons_2.LockIcon, null),
372
+ onConfirm: handleBlockConfirm,
373
+ onCancel: handleBlockCancel,
374
+ },
375
+ (0, utils_1.getMessage)(
376
+ "page.details.actions.comment.block.confirmation.description"
377
+ )
378
+ ),
379
+ !blockedThread &&
380
+ react_1.default.createElement(
381
+ ConfirmationDialog_1.default,
382
+ {
383
+ isVisible: blockThreadConfirmationVisible,
384
+ isActionAsync: blockItemThreadMutation.isLoading,
385
+ header: (0, utils_1.getMessage)(
386
+ "page.details.actions.thread.block.confirmation.header"
387
+ ),
388
+ labelConfirm: (0, utils_1.getMessage)(
389
+ "page.details.actions.thread.block.confirmation.button.confirm"
390
+ ),
391
+ iconConfirm: react_1.default.createElement(icons_2.LockIcon, null),
392
+ onConfirm: handleBlockThreadConfirm,
393
+ onCancel: handleBlockThreadCancel,
394
+ },
395
+ (0, utils_1.getMessage)(
396
+ "page.details.actions.thread.block.confirmation.description"
397
+ )
398
+ )
399
+ );
400
+ };
401
+ DiscussionThreadItemActions.propTypes = {
402
+ isRoot: prop_types_1.default.bool,
403
+ blocked: prop_types_1.default.bool.isRequired,
404
+ blockedThread: prop_types_1.default.bool.isRequired,
405
+ approvalStatus: prop_types_1.default.oneOfType([
406
+ prop_types_1.default.nullable,
407
+ prop_types_1.default.oneOf(["PENDING", "APPROVED", "REJECTED"]),
408
+ ]),
409
+ allowedActions: prop_types_1.default.shape({
410
+ canModerate: prop_types_1.default.bool,
411
+ }),
412
+ };
413
+ exports.default = DiscussionThreadItemActions;
414
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export declare const DiscussionThreadItemActionsWrapper: any;
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.DiscussionThreadItemActionsWrapper = void 0;
9
+ const styled_components_1 = __importDefault(require("styled-components"));
10
+ const Box_1 = require("@strapi/design-system/Box");
11
+ exports.DiscussionThreadItemActionsWrapper = (0, styled_components_1.default)(
12
+ Box_1.Box
13
+ )`
14
+ margin-left: 1rem;
15
+ align-items: flex-start;
16
+ `;
17
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1,17 @@
1
+ declare const DiscussionThreadItemApprovalFlowActions: {
2
+ ({ id, allowedActions: { canModerate }, queryToInvalidate, }: {
3
+ id: any;
4
+ allowedActions: {
5
+ canModerate: any;
6
+ };
7
+ queryToInvalidate: any;
8
+ }): any;
9
+ propTypes: {
10
+ id: any;
11
+ queryToInvalidate: any;
12
+ allowedActions: any;
13
+ wrapped: any;
14
+ };
15
+ };
16
+ export default DiscussionThreadItemApprovalFlowActions;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const react_1 = __importDefault(require("react"));
9
+ const prop_types_1 = __importDefault(require("prop-types"));
10
+ const react_query_1 = require("react-query");
11
+ const IconButton_1 = require("@strapi/design-system/IconButton");
12
+ const icons_1 = require("@strapi/icons");
13
+ const helper_plugin_1 = require("@strapi/helper-plugin");
14
+ const utils_1 = require("../../utils");
15
+ const api_1 = require("../../pages/utils/api");
16
+ const pluginId_1 = require("../../pluginId");
17
+ const DiscussionThreadItemApprovalFlowActions = ({
18
+ id,
19
+ allowedActions: { canModerate },
20
+ queryToInvalidate,
21
+ }) => {
22
+ const toggleNotification = (0, helper_plugin_1.useNotification)();
23
+ const queryClient = (0, react_query_1.useQueryClient)();
24
+ const { lockApp, unlockApp } = (0, helper_plugin_1.useOverlayBlocker)();
25
+ const onSuccess = (message) => async () => {
26
+ if (queryToInvalidate) {
27
+ await queryClient.invalidateQueries(queryToInvalidate);
28
+ }
29
+ toggleNotification({
30
+ type: "success",
31
+ message: `${pluginId_1.pluginId}.${message}`,
32
+ });
33
+ unlockApp();
34
+ };
35
+ const onError = (err) => {
36
+ (0, utils_1.handleAPIError)(err, toggleNotification);
37
+ };
38
+ const approveItemMutation = (0, react_query_1.useMutation)(
39
+ api_1.approveItem,
40
+ {
41
+ onSuccess: onSuccess(
42
+ "page.details.actions.comment.approve.confirmation.success"
43
+ ),
44
+ onError,
45
+ refetchActive: false,
46
+ }
47
+ );
48
+ const rejectItemMutation = (0, react_query_1.useMutation)(api_1.rejectItem, {
49
+ onSuccess: onSuccess(
50
+ "page.details.actions.comment.reject.confirmation.success"
51
+ ),
52
+ onError,
53
+ refetchActive: false,
54
+ });
55
+ const handleApproveClick = () => {
56
+ if (canModerate) {
57
+ lockApp();
58
+ approveItemMutation.mutate(id);
59
+ }
60
+ };
61
+ const handleRejectClick = () => {
62
+ if (canModerate) {
63
+ lockApp();
64
+ rejectItemMutation.mutate(id);
65
+ }
66
+ };
67
+ if (canModerate) {
68
+ return react_1.default.createElement(
69
+ react_1.default.Fragment,
70
+ null,
71
+ react_1.default.createElement(IconButton_1.IconButton, {
72
+ icon: react_1.default.createElement(icons_1.Check, null),
73
+ label: (0, utils_1.getMessage)(
74
+ "page.details.actions.comment.approve",
75
+ "Approve"
76
+ ),
77
+ onClick: handleApproveClick,
78
+ }),
79
+ react_1.default.createElement(IconButton_1.IconButton, {
80
+ icon: react_1.default.createElement(icons_1.Cross, null),
81
+ label: (0, utils_1.getMessage)(
82
+ "page.details.actions.comment.reject",
83
+ "Reject"
84
+ ),
85
+ onClick: handleRejectClick,
86
+ })
87
+ );
88
+ }
89
+ return null;
90
+ };
91
+ DiscussionThreadItemApprovalFlowActions.propTypes = {
92
+ id: prop_types_1.default.oneOfType([
93
+ prop_types_1.default.string,
94
+ prop_types_1.default.number,
95
+ ]).isRequired,
96
+ queryToInvalidate: prop_types_1.default.string,
97
+ allowedActions: prop_types_1.default.shape({
98
+ canModerate: prop_types_1.default.bool,
99
+ }),
100
+ wrapped: prop_types_1.default.bool,
101
+ };
102
+ exports.default = DiscussionThreadItemApprovalFlowActions;
103
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export declare const DiscussionThreadItemActionsGroupWrapper: any;
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.DiscussionThreadItemActionsGroupWrapper = void 0;
9
+ const styled_components_1 = __importDefault(require("styled-components"));
10
+ const IconButton_1 = require("@strapi/design-system/IconButton");
11
+ exports.DiscussionThreadItemActionsGroupWrapper = (0,
12
+ styled_components_1.default)(IconButton_1.IconButtonGroup)`
13
+ margin-left: 0.5rem;
14
+ `;
15
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1,16 @@
1
+ declare const DiscussionThreadItemFooter: {
2
+ ({ children, author, createdAt, updatedAt, }: {
3
+ children: any;
4
+ author: any;
5
+ createdAt: any;
6
+ updatedAt: any;
7
+ }): any;
8
+ propTypes: {
9
+ author: any;
10
+ createdAt: any;
11
+ updatedAt: any;
12
+ children: any;
13
+ };
14
+ };
15
+ export default DiscussionThreadItemFooter;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const react_1 = __importDefault(require("react"));
9
+ const prop_types_1 = __importDefault(require("prop-types"));
10
+ const react_intl_1 = require("react-intl");
11
+ const Avatar_1 = require("@strapi/design-system/Avatar");
12
+ const Box_1 = require("@strapi/design-system/Box");
13
+ const Typography_1 = require("@strapi/design-system/Typography");
14
+ const utils_1 = require("../../utils");
15
+ const styles_1 = require("./styles");
16
+ const DiscussionThreadItemFooter = ({
17
+ children,
18
+ author,
19
+ createdAt,
20
+ updatedAt,
21
+ }) => {
22
+ const { formatDate } = (0, react_intl_1.useIntl)();
23
+ const dateTime = formatDate(updatedAt || createdAt, {
24
+ dateStyle: "medium",
25
+ timeStyle: "short",
26
+ });
27
+ const { name, avatar } = author;
28
+ return react_1.default.createElement(
29
+ styles_1.DiscussionThreadItemFooterStyled,
30
+ { as: Box_1.Box, paddingTop: 2, direction: "row" },
31
+ react_1.default.createElement(
32
+ styles_1.DiscussionThreadItemFooterMeta,
33
+ { size: 3, horizontal: true },
34
+ avatar
35
+ ? react_1.default.createElement(Avatar_1.Avatar, {
36
+ src: avatar,
37
+ alt: name,
38
+ })
39
+ : react_1.default.createElement(
40
+ Avatar_1.Initials,
41
+ null,
42
+ (0, utils_1.renderInitials)(name)
43
+ ),
44
+ react_1.default.createElement(
45
+ Typography_1.Typography,
46
+ { variant: "pi", fontWeight: "bold", textColor: "neutral800" },
47
+ name
48
+ ),
49
+ react_1.default.createElement(
50
+ Typography_1.Typography,
51
+ { variant: "pi", textColor: "neutral600" },
52
+ dateTime
53
+ )
54
+ ),
55
+ children
56
+ );
57
+ };
58
+ DiscussionThreadItemFooter.propTypes = {
59
+ author: prop_types_1.default.shape({
60
+ id: prop_types_1.default.oneOfType(
61
+ prop_types_1.default.string,
62
+ prop_types_1.default.number
63
+ ).isRequired,
64
+ name: prop_types_1.default.string.isRequired,
65
+ email: prop_types_1.default.string,
66
+ avatar: prop_types_1.default.string,
67
+ }).isRequired,
68
+ createdAt: prop_types_1.default.string.isRequired,
69
+ updatedAt: prop_types_1.default.string,
70
+ children: prop_types_1.default.array,
71
+ };
72
+ exports.default = DiscussionThreadItemFooter;
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ export declare const DiscussionThreadItemFooterStyled: any;
2
+ export declare const DiscussionThreadItemFooterMeta: any;
3
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.DiscussionThreadItemFooterMeta =
9
+ exports.DiscussionThreadItemFooterStyled = void 0;
10
+ const styled_components_1 = __importDefault(require("styled-components"));
11
+ const Flex_1 = require("@strapi/design-system/Flex");
12
+ const Stack_1 = require("@strapi/design-system/Stack");
13
+ exports.DiscussionThreadItemFooterStyled = (0, styled_components_1.default)(
14
+ Flex_1.Flex
15
+ )`
16
+ width: 100%;
17
+ `;
18
+ exports.DiscussionThreadItemFooterMeta = (0, styled_components_1.default)(
19
+ Stack_1.Stack
20
+ )`
21
+ * + * {
22
+ margin-left: 8px;
23
+ }
24
+ `;
25
+ //# sourceMappingURL=styles.js.map