strapi-plugin-comments 2.0.8 β†’ 2.1.0-beta.1

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 (267) hide show
  1. package/README.md +171 -127
  2. package/admin/src/components/ActionButton/styles.d.ts +2 -0
  3. package/admin/src/components/ActionButton/styles.js +13 -8
  4. package/admin/src/components/ConfirmationDialog/index.d.ts +26 -0
  5. package/admin/src/components/ConfirmationDialog/index.js +36 -55
  6. package/admin/src/components/DiscussionStatus/index.d.ts +9 -0
  7. package/admin/src/components/DiscussionStatus/index.js +22 -31
  8. package/admin/src/components/DiscussionThread/index.d.ts +16 -0
  9. package/admin/src/components/DiscussionThread/index.js +39 -56
  10. package/admin/src/components/DiscussionThreadItem/index.d.ts +9 -0
  11. package/admin/src/components/DiscussionThreadItem/index.js +28 -52
  12. package/admin/src/components/DiscussionThreadItem/styles.d.ts +4 -0
  13. package/admin/src/components/DiscussionThreadItem/styles.js +16 -11
  14. package/admin/src/components/DiscussionThreadItemActions/index.d.ts +19 -0
  15. package/admin/src/components/DiscussionThreadItemActions/index.js +121 -158
  16. package/admin/src/components/DiscussionThreadItemActions/styles.d.ts +2 -0
  17. package/admin/src/components/DiscussionThreadItemActions/styles.js +13 -7
  18. package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.d.ts +17 -0
  19. package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +38 -48
  20. package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.d.ts +2 -0
  21. package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.js +12 -6
  22. package/admin/src/components/DiscussionThreadItemFooter/index.d.ts +16 -0
  23. package/admin/src/components/DiscussionThreadItemFooter/index.js +35 -42
  24. package/admin/src/components/DiscussionThreadItemFooter/styles.d.ts +3 -0
  25. package/admin/src/components/DiscussionThreadItemFooter/styles.js +17 -12
  26. package/admin/src/components/DiscussionThreadItemReviewAction/index.d.ts +30 -0
  27. package/admin/src/components/DiscussionThreadItemReviewAction/index.js +77 -91
  28. package/admin/src/components/FormSwitch/index.d.ts +7 -0
  29. package/admin/src/components/FormSwitch/index.js +15 -18
  30. package/admin/src/components/FormSwitch/styles.d.ts +2 -0
  31. package/admin/src/components/FormSwitch/styles.js +14 -8
  32. package/admin/src/components/IconButton/styles.d.ts +2 -0
  33. package/admin/src/components/IconButton/styles.js +16 -9
  34. package/admin/src/components/Initializer/index.d.ts +5 -0
  35. package/admin/src/components/Initializer/index.js +12 -24
  36. package/admin/src/components/LoadingIndicatorOverlay/index.d.ts +3 -0
  37. package/admin/src/components/LoadingIndicatorOverlay/index.js +12 -15
  38. package/admin/src/components/LoadingIndicatorOverlay/styles.d.ts +3 -0
  39. package/admin/src/components/LoadingIndicatorOverlay/styles.js +22 -17
  40. package/admin/src/components/Nav/index.d.ts +7 -0
  41. package/admin/src/components/Nav/index.js +25 -48
  42. package/admin/src/components/PluginIcon/index.d.ts +3 -0
  43. package/admin/src/components/PluginIcon/index.js +10 -12
  44. package/admin/src/components/ReportsReviewModal/index.d.ts +21 -0
  45. package/admin/src/components/ReportsReviewModal/index.js +31 -46
  46. package/admin/src/components/ReportsReviewTable/index.d.ts +21 -0
  47. package/admin/src/components/ReportsReviewTable/index.js +120 -140
  48. package/admin/src/components/StatusBadge/index.d.ts +7 -0
  49. package/admin/src/components/StatusBadge/index.js +12 -17
  50. package/admin/src/components/StatusBadge/styles.d.ts +2 -0
  51. package/admin/src/components/StatusBadge/styles.js +19 -13
  52. package/admin/src/components/TableFilters/index.d.ts +10 -0
  53. package/admin/src/components/TableFilters/index.js +52 -49
  54. package/admin/src/components/TablePagination/index.d.ts +17 -0
  55. package/admin/src/components/TablePagination/index.js +27 -29
  56. package/admin/src/components/icons/comments.d.ts +6 -0
  57. package/admin/src/components/icons/comments.js +11 -8
  58. package/admin/src/components/icons/index.d.ts +6 -0
  59. package/admin/src/components/icons/index.js +15 -6
  60. package/admin/src/components/icons/lock.d.ts +7 -0
  61. package/admin/src/components/icons/lock.js +11 -21
  62. package/admin/src/components/icons/review.d.ts +7 -0
  63. package/admin/src/components/icons/review.js +11 -17
  64. package/admin/src/components/icons/unlock.d.ts +7 -0
  65. package/admin/src/components/icons/unlock.js +11 -19
  66. package/admin/src/hooks/useConfig.d.ts +8 -0
  67. package/admin/src/hooks/useConfig.js +40 -45
  68. package/admin/src/index.d.ts +7 -0
  69. package/admin/src/index.js +98 -92
  70. package/admin/src/pages/App/index.d.ts +4 -0
  71. package/admin/src/pages/App/index.js +43 -67
  72. package/admin/src/pages/App/reducer/actions.d.ts +8 -0
  73. package/admin/src/pages/App/reducer/actions.js +11 -7
  74. package/admin/src/pages/App/reducer/constants.d.ts +4 -0
  75. package/admin/src/pages/App/reducer/constants.js +7 -4
  76. package/admin/src/pages/App/reducer/index.d.ts +9 -0
  77. package/admin/src/pages/App/reducer/index.js +24 -22
  78. package/admin/src/pages/App/reducer/init.d.ts +3 -0
  79. package/admin/src/pages/App/reducer/init.js +6 -4
  80. package/admin/src/pages/App/reducer/selectors.d.ts +6 -0
  81. package/admin/src/pages/App/reducer/selectors.js +17 -34
  82. package/admin/src/pages/App/utils/api.d.ts +2 -0
  83. package/admin/src/pages/App/utils/api.js +14 -11
  84. package/admin/src/pages/ComingSoonPage/index.d.ts +3 -0
  85. package/admin/src/pages/ComingSoonPage/index.js +42 -24
  86. package/admin/src/pages/Details/components/DetailsEntity/index.d.ts +18 -0
  87. package/admin/src/pages/Details/components/DetailsEntity/index.js +49 -77
  88. package/admin/src/pages/Details/components/DetailsFilters/index.d.ts +12 -0
  89. package/admin/src/pages/Details/components/DetailsFilters/index.js +19 -26
  90. package/admin/src/pages/Details/components/DetailsFilters/styles.d.ts +2 -0
  91. package/admin/src/pages/Details/components/DetailsFilters/styles.js +14 -8
  92. package/admin/src/pages/Details/index.d.ts +4 -0
  93. package/admin/src/pages/Details/index.js +94 -133
  94. package/admin/src/pages/Discover/components/DiscoverTableRow/index.d.ts +20 -0
  95. package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +128 -139
  96. package/admin/src/pages/Discover/components/DiscoverTableRow/styles.d.ts +2 -0
  97. package/admin/src/pages/Discover/components/DiscoverTableRow/styles.js +14 -8
  98. package/admin/src/pages/Discover/index.d.ts +4 -0
  99. package/admin/src/pages/Discover/index.js +129 -170
  100. package/admin/src/pages/Discover/utils/api.d.ts +2 -0
  101. package/admin/src/pages/Discover/utils/api.js +15 -13
  102. package/admin/src/pages/Discover/utils/filtersSchema.d.ts +11 -0
  103. package/admin/src/pages/Discover/utils/filtersSchema.js +8 -6
  104. package/admin/src/pages/Settings/components/RestartAlert/styles.d.ts +2 -0
  105. package/admin/src/pages/Settings/components/RestartAlert/styles.js +14 -8
  106. package/admin/src/pages/Settings/index.d.ts +3 -0
  107. package/admin/src/pages/Settings/index.js +225 -391
  108. package/admin/src/pages/Settings/utils/api.d.ts +7 -0
  109. package/admin/src/pages/Settings/utils/api.js +60 -55
  110. package/admin/src/pages/utils/api.d.ts +12 -0
  111. package/admin/src/pages/utils/api.js +58 -53
  112. package/admin/src/permissions.d.ts +28 -0
  113. package/admin/src/permissions.js +31 -17
  114. package/admin/src/pluginId.d.ts +2 -0
  115. package/admin/src/pluginId.js +29 -5
  116. package/admin/src/reducers.d.ts +7 -0
  117. package/admin/src/reducers.js +10 -6
  118. package/admin/src/translations/en.json +131 -130
  119. package/admin/src/translations/fr.json +1 -1
  120. package/admin/src/translations/pt-BR.json +132 -0
  121. package/admin/src/utils/axiosInstance.d.ts +3 -0
  122. package/admin/src/utils/axiosInstance.js +21 -27
  123. package/admin/src/utils/constants.d.ts +25 -0
  124. package/admin/src/utils/constants.js +23 -22
  125. package/admin/src/utils/getApiUrl.d.ts +3 -0
  126. package/admin/src/utils/getApiUrl.js +6 -5
  127. package/admin/src/utils/getMessage.d.ts +4 -0
  128. package/admin/src/utils/getMessage.js +15 -15
  129. package/admin/src/utils/getRelatedGroups.d.ts +4 -0
  130. package/admin/src/utils/getRelatedGroups.js +5 -3
  131. package/admin/src/utils/getUrl.d.ts +3 -0
  132. package/admin/src/utils/getUrl.js +6 -5
  133. package/admin/src/utils/handleAPIError.d.ts +4 -0
  134. package/admin/src/utils/handleAPIError.js +12 -11
  135. package/admin/src/utils/index.d.ts +12 -0
  136. package/admin/src/utils/index.js +29 -11
  137. package/admin/src/utils/parseRegExp.d.ts +6 -0
  138. package/admin/src/utils/parseRegExp.js +6 -5
  139. package/admin/src/utils/renderEntryTitle.d.ts +4 -0
  140. package/admin/src/utils/renderEntryTitle.js +11 -12
  141. package/admin/src/utils/renderInitials.d.ts +3 -0
  142. package/admin/src/utils/renderInitials.js +10 -5
  143. package/admin/src/utils/resolveCommentStatus.d.ts +4 -0
  144. package/admin/src/utils/resolveCommentStatus.js +17 -21
  145. package/admin/src/utils/resolveCommentStatusColor.d.ts +4 -0
  146. package/admin/src/utils/resolveCommentStatusColor.js +19 -19
  147. package/content-types/comment.d.ts +91 -0
  148. package/content-types/comment.js +87 -88
  149. package/content-types/index.d.ts +143 -0
  150. package/content-types/index.js +15 -10
  151. package/content-types/report.d.ts +48 -0
  152. package/content-types/report.js +44 -49
  153. package/package.json +24 -19
  154. package/permissions.d.ts +18 -0
  155. package/permissions.js +12 -13
  156. package/server/bootstrap.d.ts +4 -0
  157. package/server/bootstrap.js +56 -62
  158. package/server/config/index.d.ts +4 -0
  159. package/server/config/index.js +17 -15
  160. package/server/controllers/admin.d.ts +4 -0
  161. package/server/controllers/admin.js +134 -167
  162. package/server/controllers/client.d.ts +4 -0
  163. package/server/controllers/client.js +104 -115
  164. package/server/controllers/index.d.ts +6 -0
  165. package/server/controllers/index.js +12 -8
  166. package/server/controllers/utils/functions.d.ts +7 -0
  167. package/server/controllers/utils/functions.js +22 -17
  168. package/server/controllers/utils/parsers.d.ts +15 -0
  169. package/server/controllers/utils/parsers.js +17 -17
  170. package/server/destroy.d.ts +3 -0
  171. package/server/destroy.js +3 -4
  172. package/server/graphql/index.d.ts +4 -0
  173. package/server/graphql/index.js +27 -25
  174. package/server/graphql/mutations/createAbuseReport.d.ts +11 -0
  175. package/server/graphql/mutations/createAbuseReport.js +22 -24
  176. package/server/graphql/mutations/createComment.d.ts +14 -0
  177. package/server/graphql/mutations/createComment.js +22 -24
  178. package/server/graphql/mutations/index.d.ts +4 -0
  179. package/server/graphql/mutations/index.js +24 -19
  180. package/server/graphql/mutations/removeComment.d.ts +11 -0
  181. package/server/graphql/mutations/removeComment.js +22 -24
  182. package/server/graphql/mutations/updateComment.d.ts +11 -0
  183. package/server/graphql/mutations/updateComment.js +22 -24
  184. package/server/graphql/queries/findAllFlat.d.ts +19 -0
  185. package/server/graphql/queries/findAllFlat.js +31 -30
  186. package/server/graphql/queries/findAllInHierarchy.d.ts +18 -0
  187. package/server/graphql/queries/findAllInHierarchy.js +26 -30
  188. package/server/graphql/queries/index.d.ts +4 -0
  189. package/server/graphql/queries/index.js +20 -17
  190. package/server/graphql/resolvers-config.d.ts +23 -0
  191. package/server/graphql/resolvers-config.js +11 -11
  192. package/server/graphql/types/comment-author.d.ts +4 -0
  193. package/server/graphql/types/comment-author.js +10 -8
  194. package/server/graphql/types/comment-nested.d.ts +4 -0
  195. package/server/graphql/types/comment-nested.js +17 -15
  196. package/server/graphql/types/comment.d.ts +4 -0
  197. package/server/graphql/types/comment.js +16 -14
  198. package/server/graphql/types/create-comment-author.d.ts +4 -0
  199. package/server/graphql/types/create-comment-author.js +10 -8
  200. package/server/graphql/types/create-comment.d.ts +4 -0
  201. package/server/graphql/types/create-comment.js +10 -8
  202. package/server/graphql/types/create-report.d.ts +4 -0
  203. package/server/graphql/types/create-report.js +10 -8
  204. package/server/graphql/types/id.d.ts +4 -0
  205. package/server/graphql/types/id.js +24 -23
  206. package/server/graphql/types/identify-comment-author.d.ts +4 -0
  207. package/server/graphql/types/identify-comment-author.js +7 -5
  208. package/server/graphql/types/index.d.ts +4 -0
  209. package/server/graphql/types/index.js +36 -17
  210. package/server/graphql/types/remove-comment.d.ts +4 -0
  211. package/server/graphql/types/remove-comment.js +9 -7
  212. package/server/graphql/types/report-reason.d.ts +4 -0
  213. package/server/graphql/types/report-reason.js +10 -8
  214. package/server/graphql/types/report.d.ts +4 -0
  215. package/server/graphql/types/report.js +12 -10
  216. package/server/graphql/types/response-find-all.d.ts +4 -0
  217. package/server/graphql/types/response-find-all.js +8 -6
  218. package/server/graphql/types/response-meta.d.ts +4 -0
  219. package/server/graphql/types/response-meta.js +7 -5
  220. package/server/graphql/types/response-pagination.d.ts +4 -0
  221. package/server/graphql/types/response-pagination.js +12 -10
  222. package/server/graphql/types/update-comment.d.ts +4 -0
  223. package/server/graphql/types/update-comment.js +10 -8
  224. package/server/index.d.ts +26 -0
  225. package/server/index.js +24 -21
  226. package/server/register.d.ts +3 -0
  227. package/server/register.js +3 -4
  228. package/server/routes/admin.d.ts +4 -0
  229. package/server/routes/admin.js +103 -109
  230. package/server/routes/client.d.ts +4 -0
  231. package/server/routes/client.js +48 -46
  232. package/server/routes/index.d.ts +11 -0
  233. package/server/routes/index.js +18 -14
  234. package/server/services/admin.d.ts +5 -0
  235. package/server/services/admin.js +126 -158
  236. package/server/services/client.d.ts +5 -0
  237. package/server/services/client.js +135 -151
  238. package/server/services/common.d.ts +5 -0
  239. package/server/services/common.js +165 -194
  240. package/server/services/graphql.d.ts +5 -0
  241. package/server/services/graphql.js +117 -182
  242. package/server/services/index.d.ts +8 -0
  243. package/server/services/index.js +15 -12
  244. package/server/services/utils/functions.d.ts +13 -0
  245. package/server/services/utils/functions.js +100 -109
  246. package/server/utils/constants.d.ts +9 -0
  247. package/server/utils/constants.js +19 -23
  248. package/server/utils/error.d.ts +19 -0
  249. package/server/utils/error.js +23 -18
  250. package/server/utils/functions.d.ts +6 -0
  251. package/server/utils/functions.js +35 -18
  252. package/strapi-admin.d.ts +3 -0
  253. package/strapi-admin.js +8 -3
  254. package/strapi-server.d.ts +177 -0
  255. package/strapi-server.js +43 -46
  256. package/tsconfig.tsbuildinfo +1 -0
  257. package/types/contentTypes.d.ts +44 -0
  258. package/types/contentTypes.js +3 -0
  259. package/.husky/pre-commit +0 -4
  260. package/LICENSE.md +0 -7
  261. package/__mocks__/initSetup.js +0 -108
  262. package/jest.config.js +0 -7
  263. package/server/controllers/utils/__tests__/functions.test.js +0 -43
  264. package/server/controllers/utils/__tests__/parsers.test.js +0 -94
  265. package/server/services/__tests__/common.test.js +0 -399
  266. package/server/services/utils/__tests__/functions.test.js +0 -53
  267. package/server/utils/__tests__/functions.test.js +0 -17
package/README.md CHANGED
@@ -30,7 +30,6 @@
30
30
  <img style="width: 100%; height: auto;" src="public/assets/preview.png" alt="UI preview" />
31
31
  </div>
32
32
 
33
-
34
33
  A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and much more.
35
34
 
36
35
  ## ✨ Features
@@ -55,7 +54,7 @@ A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provid
55
54
  yarn add strapi-plugin-comments@latest
56
55
  ```
57
56
 
58
- After successful installation you've to build a fresh package that includes plugin UI. To archive that simply use:
57
+ After successful installation you've to build a fresh package that includes plugin UI. To archive that simply use:
59
58
 
60
59
  ```bash
61
60
  yarn build
@@ -72,11 +71,35 @@ The **Comments** plugin should appear in the **Plugins** section of Strapi sideb
72
71
 
73
72
  Enjoy πŸŽ‰
74
73
 
74
+ ### Working in development mode
75
+
76
+ 1. Clone repository
77
+
78
+ ```
79
+ git clone git@github.com:VirtusLab-Open-Source/strapi-plugin-comments.git
80
+ ```
81
+
82
+ 2. Create a soft link in your strapi project to plugin build folder
83
+
84
+ ```sh
85
+ ln -s <your path>/strapi-plugin-comments/build <your path>/strapi-project/src/plugins/comments
86
+ ```
87
+
88
+ 3. Run develop or build command
89
+
90
+ ```ts
91
+ // Watch for file changes
92
+ yarn develop
93
+ // or run build without nodemon
94
+ yarn build:dev
95
+ ```
96
+
75
97
  ## πŸ– Requirements
76
98
 
77
99
  Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under [Installation Requirements](https://docs.strapi.io/developer-docs/latest/getting-started/introduction.html).
78
100
 
79
101
  **Minimum environment requirements**
102
+
80
103
  - Node.js `>=14.x.x`
81
104
  - NPM `>=7.x.x`
82
105
 
@@ -84,7 +107,7 @@ In our minimum support we're following [official Node.js releases timelines](htt
84
107
 
85
108
  **Supported Strapi versions**:
86
109
 
87
- - Strapi v4.1.0 (recently tested)
110
+ - Strapi v4.1.2 (recently tested)
88
111
  - Strapi v4.x
89
112
 
90
113
  > This plugin is designed for **Strapi v4** and is not working with v3.x. To get version for **Strapi v3** install version [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/strapi-v3).
@@ -97,88 +120,95 @@ In our minimum support we're following [official Node.js releases timelines](htt
97
120
 
98
121
  Version `2.0.3` introduce the intuitive **Settings** page which you can easly access via `Strapi Settings -> Section: Comments Plugin -> Configuration`. On dedicated page you will be able to setup all crucial properties which drives the plugin and customize each individual collection for which **Comments plugin** should be enabled.
99
122
 
100
- > *Note*
123
+ > _Note_
101
124
  > Default configuration for your plugin is fetched from `config/plugins.js` or directly from the plugin itself. If you would like to customize the default state to which you might revert, please follow the next section.
102
125
 
103
126
  ### In `v2.0.2` and older + default configuration state for `v2.0.3` and newest
104
127
 
105
128
  To setup amend default plugin configuration we recommend to put following snippet as part of `config/plugins.js` or `config/<env>/plugins.js` file. If the file does not exist yet, you have to create it manually. If you've got already configurations for other plugins stores by this way, use just the `comments` part within exising `plugins` item.
106
129
 
107
-
108
130
  ```js
109
- module.exports = ({ env }) => ({
110
- //...
111
- comments: {
112
- enabled: true,
113
- config: {
114
- badWords: false,
115
- moderatorRoles: ["Authenticated"],
116
- approvalFlow: ['api::page.page'],
117
- entryLabel: {
118
- '*': ['Title', 'title', 'Name', 'name', 'Subject', 'subject'],
119
- 'api::page.page': ['MyField'],
120
- },
121
- reportReasons: {
122
- 'MY_CUSTOM_REASON': 'MY_CUSTOM_REASON',
123
- },
124
- gql: {
125
- // ...
126
- },
127
- },
128
- },
129
- //...
130
- });
131
+ module.exports = ({ env }) => ({
132
+ //...
133
+ comments: {
134
+ enabled: true,
135
+ config: {
136
+ badWords: false,
137
+ moderatorRoles: ["Authenticated"],
138
+ approvalFlow: ["api::page.page"],
139
+ entryLabel: {
140
+ "*": ["Title", "title", "Name", "name", "Subject", "subject"],
141
+ "api::page.page": ["MyField"],
142
+ },
143
+ reportReasons: {
144
+ MY_CUSTOM_REASON: "MY_CUSTOM_REASON",
145
+ },
146
+ gql: {
147
+ // ...
148
+ },
149
+ },
150
+ },
151
+ //...
152
+ });
131
153
  ```
132
154
 
133
155
  ### Properties
134
- - `badWords` - Enabled support for [bad words filtering](https://www.npmjs.com/package/bad-words). Can be turned off or overwritten using [options reference](https://www.npmjs.com/package/bad-words#constructor). Default value: `true`.
156
+
157
+ - `badWords` - Enabled support for [bad words filtering](https://www.npmjs.com/package/bad-words). Can be turned off or overwritten using [options reference](https://www.npmjs.com/package/bad-words#constructor). Default value: `true`.
135
158
  - `moderatorRoles` - Optional list of names of roles. Users with those roles will be notified by email when a new abuse report is created. This feature requires a built-in [Strapi email plugin](https://docs.strapi.io/developer-docs/latest/plugins/email.html) configured.
136
- - `approvalFlow` - list of Content Types which are supporting approval flow. Values must be in format like `'api::<collection name>.<content type name>'`. For not included, posted comments are going to be immediately visible.
159
+ - `approvalFlow` - list of Content Types which are supporting approval flow. Values must be in format like `'api::<collection name>.<content type name>'`. For not included, posted comments are going to be immediately visible.
137
160
  - `entryLabel` - ordered list of property names per Content Type to generate related entity label. Keys must be in format like `'api::<collection name>.<content type name>'`. Default formatting set as `*`.
138
161
  - `reportReasons` - set of enums you would like to use for issuing abuse reports. Provided by default `'BAD_LANGUAGE'`, `'DISCRIMINATION'` and `'OTHER'`.
139
162
  - `gql` - specific configuration for GraphQL. See [Additional GQL Configuration](#additional-gql-configuration)
140
163
 
141
164
  ## Additional GQL Configuration
165
+
142
166
  All you need to do is to install and enable `@strapi/plugin-graphql` for you instance based on the **[official Strapi v4 docs](https://docs.strapi.io/developer-docs/latest/plugins/graphql.html#configurations)** and decide if you would like to call it by anyone (open for world) or only by authenticated users (Strapi users).
143
167
 
144
168
  > **Important!**
145
169
  > If you're using `config/plugins.js` to configure your plugins , please put `comments` property before `graphql`. Otherwise types are not going to be properly added to GraphQL Schema. That's because of dynamic types which base on plugin configuration which are added on `boostrap` stage, not `register`. This is not valid if you're using `graphql` plugin without any custom configuration, so most of cases in real.
146
170
 
147
171
  ```json
148
- {
149
- // ...
150
- "gql": {
151
- "auth": true, // Default: false
152
- },
153
- // ...
172
+ {
173
+ // ...
174
+ "gql": {
175
+ "auth": true // Default: false
154
176
  }
177
+ // ...
178
+ }
155
179
  ```
156
180
 
157
181
  ### Properties
182
+
158
183
  - `auth` - does GraphQL Queries should be authenticated or not? Default: `false`
159
184
 
160
185
  ### Queries
161
186
 
162
187
  See [available GQL specification section](#public-graphql-specification).
163
188
 
164
- > If `auth` is set to `true` you must provide relevant authentication headers to all requests like for example:
165
- >
189
+ > If `auth` is set to `true` you must provide relevant authentication headers to all requests like for example:
190
+ >
166
191
  > ```json
167
192
  > {
168
- > "Authorization": "Bearer <your token here>"
193
+ > "Authorization": "Bearer <your token here>"
169
194
  > }
170
195
  > ```
171
196
 
172
197
  ## πŸ‘€ RBAC
198
+
173
199
  Plugin provides granular permissions based on Strapi RBAC functionality.
174
200
 
175
201
  ### Mandatory permissions
202
+
176
203
  For any role different than **Super Admin**, to access the **Comments panel** you must set following permissions:
204
+
177
205
  - _Plugins_ -> _Content-type-builder_ -> _Read_ - gives you ability to fetch Content Type schema
178
206
  - _Plugins_ -> _Comments_ -> _Comments: Read_ - gives you the basic read access to **Comments Panel**
179
207
 
180
208
  ### Optional permissions
209
+
181
210
  Feature / Capability focused permissions:
211
+
182
212
  - _Plugins_ -> _Comments_ -> _Comments: Moderate_ - allows you to block, unblock, approve &amp; reject comments
183
213
  - _Plugins_ -> _Comments_ -> _Reports: Read_ - allows you to see the list of issued abuse reports against comments
184
214
  - _Plugins_ -> _Comments_ -> _Reports: Moderate_ - allows you to review (resolve) issued abuse reports against comments
@@ -187,73 +217,76 @@ Feature / Capability focused permissions:
187
217
 
188
218
  ```json
189
219
  {
190
- "id": 1,
191
- "content": "My comment content",
192
- "blocked": null,
193
- "blockedThread": true,
194
- "blockReason": null,
195
- "authorUser": null,
196
- "removed": null,
197
- "approvalStatus": "APPROVED", // Only in case of enabled approval flow. Default: null
198
- "author": {
199
- "id": "207ccfdc-94ba-45eb-979c-790f6f49c392", // For Strapi users id reflects to the format used by your Strapi
200
- "name": "Joe Doe", // For Strapi users it is equal to 'username' field
201
- "email": "jdoe@sample.com",
202
- "avatar": null,
203
- },
204
- "createdAt": "2020-07-14T20:13:01.649Z",
205
- "updatedAt": "2020-07-14T20:13:01.670Z",
206
- "related": {}, // Related content type entity
207
- "reports": [] // Reports issued against this comment
220
+ "id": 1,
221
+ "content": "My comment content",
222
+ "blocked": null,
223
+ "blockedThread": true,
224
+ "blockReason": null,
225
+ "authorUser": null,
226
+ "removed": null,
227
+ "approvalStatus": "APPROVED", // Only in case of enabled approval flow. Default: null
228
+ "author": {
229
+ "id": "207ccfdc-94ba-45eb-979c-790f6f49c392", // For Strapi users id reflects to the format used by your Strapi
230
+ "name": "Joe Doe", // For Strapi users it is equal to 'username' field
231
+ "email": "jdoe@sample.com",
232
+ "avatar": null
233
+ },
234
+ "createdAt": "2020-07-14T20:13:01.649Z",
235
+ "updatedAt": "2020-07-14T20:13:01.670Z",
236
+ "related": {}, // Related content type entity
237
+ "reports": [] // Reports issued against this comment
208
238
  }
209
239
  ```
210
240
 
211
241
  ## πŸ•ΈοΈ Public REST API specification
212
242
 
213
243
  **Strapi Users vs. Generic authors**
244
+
214
245
  > Keep in mind that if you're using auth / authz your requests to setup proper user contexts it has got higher priority in order to take author data comparing to `author` property provided as part of your payload.
215
246
 
216
247
  ### Get Comments
217
248
 
218
- *GraphQL equivalent: [Public GraphQL API -> Get Comments](#get-comments-1)*
249
+ _GraphQL equivalent: [Public GraphQL API -> Get Comments](#get-comments-1)_
219
250
 
220
251
  `GET <host>/api/comments/api::<collection name>.<content type name>:<entity id>`
221
252
 
222
253
  Return a hierarchical tree structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`.
223
254
 
224
- **Example URL**: `https://localhost:1337/comments/api::page.page:1`
255
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1`
225
256
 
226
257
  **Example response body**
227
258
 
228
259
  ```json
229
260
  [
230
- {
261
+ {
262
+ // -- Comment Model fields ---,
263
+ "children": [
264
+ {
231
265
  // -- Comment Model fields ---,
232
266
  "children": [
233
- {
234
- // -- Comment Model fields ---,
235
- "children": [
236
- // ...
237
- ]
238
- },
239
- // ...
267
+ // ...
240
268
  ]
241
- },
242
- // ...
269
+ }
270
+ // ...
271
+ ]
272
+ }
273
+ // ...
243
274
  ]
244
275
  ```
276
+
245
277
  #### Strapi REST API properties support:
278
+
246
279
  - [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#sorting)
247
280
 
248
281
  ### Get Comments (flat structure)
249
282
 
250
- *GraphQL equivalent: [Public GraphQL API -> Get Comments (flat structure)](#get-comments-flat-structure-1)*
283
+ _GraphQL equivalent: [Public GraphQL API -> Get Comments (flat structure)](#get-comments-flat-structure-1)_
251
284
 
252
285
  `GET <host>/api/comments/api::<collection name>.<content type name>:<entity id>/flat`
253
286
 
254
287
  Return a flat structure of comments for specified instance of Content Type like for example `Page` with `ID: 1`
255
288
 
256
- **Example URL**: `https://localhost:1337/comments/api::page.page:1/flat`
289
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1/flat`
257
290
 
258
291
  **Example response body**
259
292
 
@@ -261,11 +294,11 @@ Return a flat structure of comments for specified instance of Content Type like
261
294
  {
262
295
  "data": [
263
296
  {
264
- // -- Comment Model fields ---
297
+ // -- Comment Model fields ---
265
298
  },
266
299
  {
267
- // -- Comment Model fields ---
268
- },
300
+ // -- Comment Model fields ---
301
+ }
269
302
  // ...
270
303
  ],
271
304
  "meta": {
@@ -277,48 +310,51 @@ Return a flat structure of comments for specified instance of Content Type like
277
310
  ```
278
311
 
279
312
  **Possible response codes**
313
+
280
314
  - `200` - Successful. Response with list of comments (can be empty)
281
315
  - `400` - Bad Request. Requested list for not valid / not existing Content Type
282
316
 
283
317
  #### Strapi REST API properties support:
318
+
284
319
  - [filtering](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/filtering-locale-publication.html#filtering)
285
320
  - [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#sorting)
286
321
  - [pagination](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/sort-pagination.html#pagination)
287
322
 
288
323
  ### Post a Comment
289
324
 
290
- *GraphQL equivalent: [Public GraphQL API -> Post a Comments](#post-a-comment-1)*
325
+ _GraphQL equivalent: [Public GraphQL API -> Post a Comments](#post-a-comment-1)_
291
326
 
292
327
  `POST <host>/api/comments/api::<collection name>.<content type name>:<entity id>`
293
328
 
294
329
  Posts a Comment related to specified instance of Content Type like for example `Page` with `ID: 1`
295
330
 
296
- **Example URL**: `https://localhost:1337/comments/api::page.page:1`
331
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1`
297
332
 
298
333
  **Example request body**
299
334
 
300
- *Generic (non Strapi User)*
335
+ _Generic (non Strapi User)_
336
+
301
337
  ```json
302
338
  {
303
339
  "author": {
304
- "id": "<any ID like value>",
305
- "name": "Joe Doe",
306
- "email": "jdoe@sample.com",
307
- "avatar": "<any image url>"
340
+ "id": "<any ID like value>",
341
+ "name": "Joe Doe",
342
+ "email": "jdoe@sample.com",
343
+ "avatar": "<any image url>"
308
344
  },
309
- "content": "My sample response",
310
- "threadOf": 2, // id of comment we would like to start / continue the thread (Optional)
345
+ "content": "My sample response",
346
+ "threadOf": 2 // id of comment we would like to start / continue the thread (Optional)
311
347
  }
312
348
  ```
313
349
 
314
- *Strapi user*
350
+ _Strapi user_
315
351
 
316
352
  > Author is taken directly from the request context
317
353
 
318
354
  ```json
319
355
  {
320
- "content": "My sample response",
321
- "threadOf": 2, // id of comment we would like to start / continue the thread (Optional)
356
+ "content": "My sample response",
357
+ "threadOf": 2 // id of comment we would like to start / continue the thread (Optional)
322
358
  }
323
359
  ```
324
360
 
@@ -326,43 +362,45 @@ Posts a Comment related to specified instance of Content Type like for example `
326
362
 
327
363
  ```json
328
364
  {
329
- // -- Comment Model fields ---
365
+ // -- Comment Model fields ---
330
366
  }
331
367
  ```
332
368
 
333
369
  **Possible response codes**
370
+
334
371
  - `200` - Successful. Response with created Comment Model
335
372
  - `400` - Bad Request. Missing field values or bad words check fails. Error message will provide relevant reason.
336
373
 
337
374
  ### Update Comment
338
375
 
339
- *GraphQL equivalent: [Public GraphQL API -> Update Comments](#update-comment-1)*
376
+ _GraphQL equivalent: [Public GraphQL API -> Update Comments](#update-comment-1)_
340
377
 
341
378
  `PUT <host>/api/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>`
342
379
 
343
380
  Updates a specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1`
344
381
 
345
- **Example URL**: `https://localhost:1337/comments/api::page.page:1/comment/2`
382
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1/comment/2`
346
383
 
347
384
  **Example request body**
348
385
 
349
- *Generic (non Strapi User)*
386
+ _Generic (non Strapi User)_
387
+
350
388
  ```json
351
389
  {
352
390
  "author": {
353
- "id": "<any ID like value>"
391
+ "id": "<any ID like value>"
354
392
  },
355
- "content": "My sample response"
393
+ "content": "My sample response"
356
394
  }
357
395
  ```
358
396
 
359
- *Strapi user*
397
+ _Strapi user_
360
398
 
361
399
  > Author is taken directly from the request context
362
400
 
363
401
  ```json
364
402
  {
365
- "content": "My sample response"
403
+ "content": "My sample response"
366
404
  }
367
405
  ```
368
406
 
@@ -370,82 +408,86 @@ Updates a specified Comment content based on it `commentId` and related to speci
370
408
 
371
409
  ```json
372
410
  {
373
- // -- Comment Model fields ---
411
+ // -- Comment Model fields ---
374
412
  }
375
413
  ```
376
414
 
377
415
  **Possible response codes**
416
+
378
417
  - `200` - Successful. Response with updated Comment Model
379
418
  - `400` - Bad Request. Missing field values or bad words check fails. Error message will provide relevant reason.
380
419
  - `409` - Conflict. Occurs when trying to update a non existing or not own comment. Possible cause might be that `authorId` or `authorUser` mismatch with existing comment.
381
420
 
382
421
  ### Delete Comment
383
422
 
384
- *GraphQL equivalent: [Public GraphQL API -> Delete Comment](#delete-comment-1)*
423
+ _GraphQL equivalent: [Public GraphQL API -> Delete Comment](#delete-comment-1)_
385
424
 
386
425
  `DELETE <host>/api/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>?authorId=<authorId>`
387
426
 
388
427
  Deletes a specified Comment based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1`.
389
428
 
390
- **Example URL**: `https://localhost:1337/comments/api::page.page:1/comment/1?authorId=1`
429
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1/comment/1?authorId=1`
391
430
 
392
431
  **Example response body**
393
432
 
394
433
  ```json
395
434
  {
396
- // -- Empty Response ---
435
+ // -- Empty Response ---
397
436
  }
398
437
  ```
399
438
 
400
439
  **Possible response codes**
440
+
401
441
  - `200` - Successful with blank Response.
402
442
  - `409` - Conflict. Occurs when trying to delete a non existing comment.
403
443
 
404
-
405
444
  ### Issue Abuse Report against specified Comment
406
445
 
407
- *GraphQL equivalent: [Public GraphQL API -> Issue Abuse Report against specified Comment](#issue-abuse-report-against-specified-comment-1)*
446
+ _GraphQL equivalent: [Public GraphQL API -> Issue Abuse Report against specified Comment](#issue-abuse-report-against-specified-comment-1)_
408
447
 
409
448
  `POST <host>/api/comments/api::<collection name>.<content type name>:<entity id>/comment/<commentId>/report-abuse`
410
449
 
411
450
  Reports abuse in specified Comment content based on it `commentId` and related to specified instance of Content Type like for example `Page` with `ID: 1` and requests moderator attention.
412
451
 
413
- **Example URL**: `https://localhost:1337/comments/api::page.page:1/comment/2/report-abuse`
452
+ **Example URL**: `https://localhost:1337/api/comments/api::page.page:1/comment/2/report-abuse`
414
453
 
415
454
  **Example request body**
416
455
 
417
456
  ```json
418
457
  {
419
- "reason": "<reason enum>",
420
- "content": "This comment is not relevant"
458
+ "reason": "<reason enum>",
459
+ "content": "This comment is not relevant"
421
460
  }
422
461
  ```
423
462
 
424
- *Available reason enums:* `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See [configuration section](#configuration).)
463
+ _Available reason enums:_ `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See [configuration section](#configuration).)
425
464
 
426
465
  **Example response body**
427
466
 
428
467
  ```json
429
468
  {
430
- // -- Comment Abuse Report fields ---
469
+ // -- Comment Abuse Report fields ---
431
470
  }
432
471
  ```
433
472
 
434
473
  **Possible response codes**
474
+
435
475
  - `200` - Successful. Response with reported abuse.
436
476
  - `409` - Conflict. Occurs when trying to report an abuse to a non existing comment.
437
477
 
438
478
  ## πŸ•ΈοΈ Public GraphQL specification
439
479
 
440
480
  **Strapi Users vs. Generic authors**
481
+
441
482
  > Keep in mind that if you're using auth / authz your requests to setup proper user contexts it has got higher priority in order to take author data comparing to `author` property provided as part of your payload.
442
483
 
443
484
  **Testing**
485
+
444
486
  > To test all queries and understand the schemas use GraphQL Playground exposed by `@strapi/plugin-graphql` on `http://localhost:1337/graphql`
445
487
 
446
488
  ### Get Comments
447
489
 
448
- *REST API equivalent: [Public REST API -> Get Comments](#get-comments)*
490
+ _REST API equivalent: [Public REST API -> Get Comments](#get-comments)_
449
491
 
450
492
  **Example request**
451
493
 
@@ -455,17 +497,17 @@ query {
455
497
  relation: "api::page.page:1"
456
498
  filters: { content: { contains: "Test" } }
457
499
  ) {
458
- id
459
- content
460
- blocked
461
- threadOf {
462
- id
463
- }
464
- author {
465
- id
466
- name
467
- }
500
+ id
501
+ content
502
+ blocked
503
+ threadOf {
504
+ id
468
505
  }
506
+ author {
507
+ id
508
+ name
509
+ }
510
+ }
469
511
  }
470
512
  ```
471
513
 
@@ -476,7 +518,7 @@ query {
476
518
  "data": {
477
519
  "findAllFlat": [
478
520
  {
479
- "id": 3,
521
+ "id": 3,
480
522
  "content": "Test",
481
523
  "blocked": false,
482
524
  "threadOf": null,
@@ -491,11 +533,12 @@ query {
491
533
  ```
492
534
 
493
535
  #### Strapi GraphQL API properties support:
536
+
494
537
  - [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#sorting)
495
538
 
496
539
  ### Get Comments (flat structure)
497
540
 
498
- *REST API equivalent: [Public REST API -> Get Comments (flat structure)](#get-comments-flat-structure)*
541
+ _REST API equivalent: [Public REST API -> Get Comments (flat structure)](#get-comments-flat-structure)_
499
542
 
500
543
  **Example request**
501
544
 
@@ -534,7 +577,7 @@ query {
534
577
  {
535
578
  "id": 6,
536
579
  "content": "Text to search for"
537
- },
580
+ }
538
581
  // ...
539
582
  ],
540
583
  "threadOf": null,
@@ -542,7 +585,7 @@ query {
542
585
  "id": "123456",
543
586
  "name": "Joe Doe"
544
587
  }
545
- },
588
+ }
546
589
  // ...
547
590
  ]
548
591
  }
@@ -550,13 +593,14 @@ query {
550
593
  ```
551
594
 
552
595
  #### Strapi GraphQL API properties support:
596
+
553
597
  - [filtering](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#filters)
554
598
  - [sorting](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#sorting)
555
599
  - [pagination](https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/graphql-api.html#pagination)
556
600
 
557
601
  ### Post a Comment
558
602
 
559
- *REST API equivalent: [Public REST API -> Post a Comment](#post-a-comment)*
603
+ _REST API equivalent: [Public REST API -> Post a Comment](#post-a-comment)_
560
604
 
561
605
  **Example request**
562
606
 
@@ -605,7 +649,7 @@ mutation createComment {
605
649
 
606
650
  ### Update Comment
607
651
 
608
- *REST API equivalent: [Public REST API -> Update Comment](#update-comment)*
652
+ _REST API equivalent: [Public REST API -> Update Comment](#update-comment)_
609
653
 
610
654
  **Example request**
611
655
 
@@ -658,16 +702,16 @@ mutation updateComment {
658
702
 
659
703
  ### Delete Comment
660
704
 
661
- *REST API equivalent: [Public REST API -> Delete Comment](#delete-comment)*
705
+ _REST API equivalent: [Public REST API -> Delete Comment](#delete-comment)_
662
706
 
663
707
  **Example request**
664
708
 
665
709
  ```graphql
666
710
  mutation removeComment {
667
711
  removeComment(
668
- input: {
669
- id: 33,
670
- relation: "api::page.page:1",
712
+ input: {
713
+ id: 33
714
+ relation: "api::page.page:1"
671
715
  author: { id: "12345678" } # Optional if using auth / authz requests
672
716
  }
673
717
  ) {
@@ -692,7 +736,7 @@ mutation removeComment {
692
736
 
693
737
  ### Issue Abuse Report against specified Comment
694
738
 
695
- *REST API equivalent: [Public REST API -> Issue Abuse Report against specified Comment](#issue-abuse-report-against-specified-comment)*
739
+ _REST API equivalent: [Public REST API -> Issue Abuse Report against specified Comment](#issue-abuse-report-against-specified-comment)_
696
740
 
697
741
  **Example request body**
698
742
 
@@ -720,7 +764,7 @@ mutation createAbuseReport {
720
764
  }
721
765
  ```
722
766
 
723
- *Available reason enums:* `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See [configuration section](#configuration).)
767
+ _Available reason enums:_ `BAD_WORDS`, `OTHER`, `DISCRIMINATION` (want more? See [configuration section](#configuration).)
724
768
 
725
769
  **Example response**
726
770
 
@@ -0,0 +1,2 @@
1
+ export declare const ActionButton: any;
2
+ //# sourceMappingURL=styles.d.ts.map