strapi-plugin-comments 1.0.1 → 2.0.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 (142) hide show
  1. package/.circleci/config.yml +2 -2
  2. package/.nvmrc +1 -1
  3. package/README.md +71 -95
  4. package/admin/src/components/ConfirmationDialog/index.js +56 -0
  5. package/admin/src/components/DiscussionStatus/index.js +33 -0
  6. package/admin/src/components/DiscussionThread/index.js +58 -0
  7. package/admin/src/components/DiscussionThreadItem/index.js +87 -0
  8. package/admin/src/components/DiscussionThreadItem/styles.js +87 -0
  9. package/admin/src/components/DiscussionThreadItemActions/index.js +176 -0
  10. package/admin/src/components/DiscussionThreadItemActions/styles.js +22 -0
  11. package/admin/src/components/DiscussionThreadItemMeta/index.js +31 -0
  12. package/admin/src/components/DiscussionThreadItemWarnings/index.js +137 -0
  13. package/admin/src/components/DiscussionThreadItemWarnings/styles.js +7 -0
  14. package/admin/src/components/EntityDetails/index.js +53 -0
  15. package/admin/src/{containers → components}/Initializer/index.js +4 -4
  16. package/admin/src/components/LoadingIndicatorOverlay/index.js +15 -0
  17. package/admin/src/components/LoadingIndicatorOverlay/styles.js +20 -0
  18. package/admin/src/components/Nav/index.js +45 -0
  19. package/admin/src/components/PluginIcon/index.js +12 -0
  20. package/admin/src/components/ReportsReviewModal/index.js +45 -0
  21. package/admin/src/components/ReportsReviewTable/index.js +142 -0
  22. package/admin/src/components/TableFilters/index.js +53 -0
  23. package/admin/src/components/TablePagination/index.js +35 -0
  24. package/admin/src/components/icons/comments.js +9 -0
  25. package/admin/src/index.js +56 -42
  26. package/admin/src/pages/App/index.js +32 -0
  27. package/admin/src/pages/ComingSoonPage/index.js +25 -0
  28. package/admin/src/pages/Details/index.js +109 -0
  29. package/admin/src/pages/Details/utils/api.js +41 -0
  30. package/admin/src/pages/Discover/index.js +185 -0
  31. package/admin/src/pages/Discover/utils/api.js +23 -0
  32. package/admin/src/pages/Discover/utils/filtersSchema.js +9 -0
  33. package/admin/src/permissions.js +13 -33
  34. package/admin/src/pluginId.js +2 -4
  35. package/admin/src/translations/en.json +72 -33
  36. package/admin/src/translations/fr.json +1 -0
  37. package/admin/src/utils/axiosInstance.js +35 -0
  38. package/admin/src/utils/constants.js +28 -0
  39. package/admin/src/utils/getApiUrl.js +5 -0
  40. package/admin/src/utils/getMessage.js +14 -0
  41. package/admin/src/utils/getRelatedGroups.js +5 -0
  42. package/admin/src/utils/getUrl.js +5 -0
  43. package/admin/src/utils/handleAPIError.js +15 -0
  44. package/admin/src/utils/index.js +6 -0
  45. package/codecov.yml +2 -1
  46. package/content-types/comment.js +97 -0
  47. package/content-types/index.js +11 -0
  48. package/content-types/report.js +54 -0
  49. package/package.json +12 -26
  50. package/server/bootstrap.js +5 -0
  51. package/server/config/index.js +6 -0
  52. package/server/controllers/admin.js +150 -0
  53. package/server/controllers/client.js +109 -0
  54. package/server/controllers/index.js +9 -0
  55. package/{controllers → server/controllers}/utils/__tests__/functions.test.js +0 -0
  56. package/{controllers → server/controllers}/utils/functions.js +1 -1
  57. package/server/destroy.js +5 -0
  58. package/server/index.js +22 -0
  59. package/server/register.js +5 -0
  60. package/server/routes/admin.js +92 -0
  61. package/server/routes/client.js +52 -0
  62. package/server/routes/index.js +15 -0
  63. package/server/services/admin.js +180 -0
  64. package/server/services/client.js +227 -0
  65. package/server/services/common.js +191 -0
  66. package/server/services/index.js +11 -0
  67. package/{services → server/services}/utils/__tests__/functions.test.js +7 -9
  68. package/{services → server/services}/utils/functions.js +19 -8
  69. package/server/utils/constants.js +16 -0
  70. package/{services → server}/utils/error.js +0 -0
  71. package/server/utils/functions.js +19 -0
  72. package/strapi-admin.js +3 -0
  73. package/strapi-server.js +9 -0
  74. package/admin/src/assets/images/icon-cross-blue.svg +0 -1
  75. package/admin/src/assets/images/icon_remove.svg +0 -19
  76. package/admin/src/assets/images/logo.svg +0 -5
  77. package/admin/src/components/AbuseReportsPopUp/ItemPreviewContainer.js +0 -8
  78. package/admin/src/components/AbuseReportsPopUp/ModalFooter.js +0 -31
  79. package/admin/src/components/AbuseReportsPopUp/TableContainer.js +0 -63
  80. package/admin/src/components/AbuseReportsPopUp/index.js +0 -148
  81. package/admin/src/components/Container/index.js +0 -7
  82. package/admin/src/components/EmptyView/index.js +0 -25
  83. package/admin/src/components/Filters/index.js +0 -151
  84. package/admin/src/components/Filters/index.styled.js +0 -82
  85. package/admin/src/components/Filters/utils.js +0 -21
  86. package/admin/src/components/Item/CardItem.js +0 -30
  87. package/admin/src/components/Item/CardWrapper.js +0 -10
  88. package/admin/src/components/Item/index.js +0 -92
  89. package/admin/src/components/ItemDetails/CardItem.js +0 -33
  90. package/admin/src/components/ItemDetails/CardLevelCounter.js +0 -46
  91. package/admin/src/components/ItemDetails/CardLevelCounterLink.js +0 -24
  92. package/admin/src/components/ItemDetails/CardLevelWrapper.js +0 -22
  93. package/admin/src/components/ItemDetails/CardWrapper.js +0 -52
  94. package/admin/src/components/ItemDetails/index.js +0 -151
  95. package/admin/src/components/ItemFooter/CardItemAuthor.js +0 -10
  96. package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
  97. package/admin/src/components/ItemFooter/Wrapper.js +0 -20
  98. package/admin/src/components/ItemFooter/index.js +0 -87
  99. package/admin/src/components/ItemHeader/CardHeaderBlocked.js +0 -24
  100. package/admin/src/components/ItemHeader/CardHeaderIndicator.js +0 -30
  101. package/admin/src/components/ItemHeader/CardHeaderIndicatorBlue.js +0 -11
  102. package/admin/src/components/ItemHeader/CardHeaderIndicatorRed.js +0 -11
  103. package/admin/src/components/ItemHeader/CardHeaderIndicatorsContainer.js +0 -18
  104. package/admin/src/components/ItemHeader/CardHeaderReports.js +0 -40
  105. package/admin/src/components/ItemHeader/Wrapper.js +0 -16
  106. package/admin/src/components/ItemHeader/index.js +0 -80
  107. package/admin/src/components/ItemModeration/Wrapper.js +0 -19
  108. package/admin/src/components/ItemModeration/index.js +0 -47
  109. package/admin/src/components/List/Container.js +0 -20
  110. package/admin/src/components/List/index.js +0 -21
  111. package/admin/src/components/Search/index.js +0 -83
  112. package/admin/src/containers/App/Wrapper.js +0 -14
  113. package/admin/src/containers/App/index.js +0 -47
  114. package/admin/src/containers/DataManagerProvider/actions.js +0 -11
  115. package/admin/src/containers/DataManagerProvider/index.js +0 -280
  116. package/admin/src/containers/DataManagerProvider/init.js +0 -5
  117. package/admin/src/containers/DataManagerProvider/reducer.js +0 -59
  118. package/admin/src/containers/DetailsView/Wrapper.js +0 -18
  119. package/admin/src/containers/DetailsView/index.js +0 -100
  120. package/admin/src/containers/ListView/FadedWrapper.js +0 -42
  121. package/admin/src/containers/ListView/Footer.js +0 -53
  122. package/admin/src/containers/ListView/Wrapper.js +0 -17
  123. package/admin/src/containers/ListView/components.js +0 -138
  124. package/admin/src/containers/ListView/index.js +0 -45
  125. package/admin/src/containers/Panel/actions.js +0 -5
  126. package/admin/src/containers/Panel/index.js +0 -191
  127. package/admin/src/containers/Panel/index.styled.js +0 -6
  128. package/admin/src/containers/Panel/reducer.js +0 -44
  129. package/admin/src/contexts/DataManagerContext.js +0 -5
  130. package/admin/src/hooks/useDataManager.js +0 -6
  131. package/admin/src/lifecycles.js +0 -3
  132. package/admin/src/translations/index.js +0 -7
  133. package/admin/src/utils/getTrad.js +0 -5
  134. package/admin/src/utils/getTradId.js +0 -5
  135. package/config/functions/bootstrap.js +0 -48
  136. package/config/routes.json +0 -124
  137. package/controllers/comments.js +0 -215
  138. package/models/comment.js +0 -8
  139. package/models/comment.settings.json +0 -90
  140. package/models/report.js +0 -8
  141. package/models/report.settings.json +0 -41
  142. package/services/comments.js +0 -478
@@ -1,215 +0,0 @@
1
- 'use strict';
2
-
3
- const { parseParams, throwError } = require('./utils/functions');
4
- const _ = require('lodash');
5
-
6
- /**
7
- * comments.js controller
8
- *
9
- * @description: A set of functions called "actions" of the `comments` plugin.
10
- */
11
-
12
- module.exports = {
13
-
14
- getService() {
15
- return strapi.plugins.comments.services.comments;
16
- },
17
-
18
- /**
19
- * Default action.
20
- *
21
- * @return {Object}
22
- */
23
- async findAll(ctx) {
24
- const { params = {} } = ctx;
25
- const { page } = parseParams(params);
26
- return await strapi.plugins.comments.services.comments.findAll(ctx.query, page);
27
- },
28
-
29
- async findAllFlat(ctx) {
30
- const { params = {}, query } = ctx;
31
- const { relation } = parseParams(params);
32
- try {
33
- return await strapi.plugins.comments.services.comments.findAllFlat(relation, query);
34
- } catch (e) {
35
- throwError(ctx, e);
36
- }
37
- },
38
-
39
- async findAllInHierarchy(ctx) {
40
- const { params = {}, query } = ctx;
41
- const { relation } = parseParams(params);
42
- try {
43
- return await strapi.plugins.comments.services.comments.findAllInHierarchy({
44
- relation,
45
- query,
46
- dropBlockedThreads: true,
47
- });
48
- } catch (e) {
49
- throwError(ctx, e);
50
- }
51
- },
52
-
53
- async post(ctx) {
54
- const { request, state, params = {} } = ctx;
55
- const { user } = state;
56
- const { relation } = parseParams(params);
57
- const { body = {} } = request;
58
- try {
59
- const entity = await strapi.plugins.comments.services.comments.create(body, relation, user);
60
-
61
- if (entity) {
62
- return entity;
63
- }
64
- } catch (e) {
65
- throwError(ctx, e);
66
- }
67
- },
68
-
69
- async put(ctx) {
70
- const { request, state, params = {} } = ctx;
71
- const { body = {} } = request;
72
- const { user } = state;
73
- const { relation, commentId } = parseParams(params);
74
- try {
75
- return await strapi.plugins.comments.services.comments.update(commentId, relation, body, user);
76
- } catch (e) {
77
- throwError(ctx, e);
78
- }
79
- },
80
-
81
- async pointsUp(ctx) {
82
- const { state, params = {} } = ctx;
83
- const { user } = state;
84
- const { relation, commentId } = parseParams(params);
85
- try {
86
- return await strapi.plugins.comments.services.comments.pointsUp(commentId, relation, user);
87
- } catch (e) {
88
- throwError(ctx, e);
89
- }
90
- },
91
-
92
- async reportAbuse(ctx) {
93
- const { request, state, params = {} } = ctx;
94
- const { body = {} } = request;
95
- if (!body.content) {
96
- return ctx.badRequest(null, 'Content field is required');
97
- }
98
- const { user } = state;
99
- const { relation, commentId } = parseParams(params);
100
- try {
101
- return await strapi.plugins.comments.services.comments.reportAbuse(commentId, relation, body, user);
102
- } catch (e) {
103
- throwError(ctx, e);
104
- }
105
- },
106
-
107
- async removeComment(ctx) {
108
- const { params: { relationId, commentId }, query: { authorId } } = ctx;
109
- if (authorId) {
110
- try {
111
- return await this.getService().markAsRemoved(
112
- relationId,
113
- commentId,
114
- authorId,
115
- );
116
- } catch (e) {
117
- if (!e.isBoom) {
118
- throwError(ctx, e);
119
- }
120
- throw e;
121
- }
122
- }
123
- return ctx.badRequest('Not provided authorId');
124
- },
125
-
126
- //
127
- // Moderation
128
- //
129
-
130
- async findOne(ctx) {
131
- const { params = {} } = ctx;
132
- const { id } = parseParams(params);
133
- try {
134
- return await strapi.plugins.comments.services.comments.findOneAndThread(id);
135
- } catch (e) {
136
- throwError(ctx, e);
137
- }
138
- },
139
-
140
- async blockComment(ctx) {
141
- const { params = {} } = ctx;
142
- const { id } = parseParams(params);
143
- try {
144
- return await strapi.plugins.comments.services.comments.blockComment(id);
145
- } catch (e) {
146
- throwError(ctx, e);
147
- }
148
- },
149
-
150
- async blockCommentThread(ctx) {
151
- const { params = {} } = ctx;
152
- const { id } = parseParams(params);
153
- try {
154
- return await strapi.plugins.comments.services.comments.blockCommentThread(id);
155
- } catch (e) {
156
- throwError(ctx, e);
157
- }
158
- },
159
-
160
- async resolveAbuseReport(ctx) {
161
- const { params = {} } = ctx;
162
- const { id, commentId } = parseParams(params);
163
- try {
164
- return await strapi.plugins.comments.services.comments.resolveAbuseReport(id, commentId);
165
- } catch (e) {
166
- throwError(ctx, e);
167
- }
168
- },
169
-
170
- async config(ctx) {
171
- const configRelatedContentTypes = _.get(strapi.config, ['plugins', 'comments', 'relatedContentTypes'], {});
172
- const contentsTypes = this.getContentsTypes();
173
- const relatedContentTypes = Object
174
- .keys(configRelatedContentTypes)
175
- .reduce((acc, currentKey) => {
176
- const current = configRelatedContentTypes[currentKey];
177
- const { key } = contentsTypes.find(content => content.value === currentKey) || {};
178
- return {
179
- ...acc,
180
- [currentKey]: {
181
- ...current,
182
- globalName: _.snakeCase(key)
183
- },
184
- };
185
- },
186
- {},
187
- );
188
- ctx.body = {
189
- relatedContentTypes,
190
- contentsTypes,
191
- };
192
- },
193
-
194
- getContentsTypes() {
195
- return Object.entries(strapi.contentTypes)
196
- .filter(([, contentType]) => (
197
- contentType.associations || []).some(_ => _.plugin === 'comments' && _.collection === 'comment'),
198
- )
199
- .reduce((acc, [, contentType]) => [
200
- ...acc,
201
- { key: contentType.globalName, value: contentType.collectionName }],
202
- [],
203
- );
204
- },
205
-
206
- async contentTypeName(ctx) {
207
- const { params: { contentTypeName } } = ctx;
208
- try {
209
- const result = await strapi.plugins.comments.services.comments.contentTypeName(contentTypeName);
210
- ctx.body = { list: result };
211
- } catch (e) {
212
- throwError(ctx, e);
213
- }
214
- },
215
- };
package/models/comment.js DELETED
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Read the documentation (https://strapi.io/documentation/3.0.0-beta.x/concepts/models.html#life-cycle-callbacks)
5
- * to customize this model
6
- */
7
-
8
- module.exports = {};
@@ -1,90 +0,0 @@
1
- {
2
- "collectionName": "comments",
3
- "info": {
4
- "name": "comment",
5
- "description": ""
6
- },
7
- "options": {
8
- "increments": true,
9
- "timestamps": true,
10
- "isManaged": false,
11
- "comment": ""
12
- },
13
- "attributes": {
14
- "content": {
15
- "type": "text",
16
- "configurable": false,
17
- "required": true
18
- },
19
- "blocked": {
20
- "type": "boolean",
21
- "default": false,
22
- "configurable": false
23
- },
24
- "blockedThread": {
25
- "type": "boolean",
26
- "default": false,
27
- "configurable": false
28
- },
29
- "blockReason": {
30
- "type": "string",
31
- "configurable": false
32
- },
33
- "points": {
34
- "type": "integer",
35
- "default": 0,
36
- "configurable": false
37
- },
38
- "authorUser": {
39
- "model": "user",
40
- "plugin": "users-permissions",
41
- "configurable": false
42
- },
43
- "authorType": {
44
- "type": "string",
45
- "configurable": false
46
- },
47
- "authorId": {
48
- "type": "string",
49
- "configurable": false
50
- },
51
- "authorName": {
52
- "type": "string",
53
- "configurable": false
54
- },
55
- "authorEmail": {
56
- "type": "email",
57
- "configurable": false
58
- },
59
- "authorAvatar": {
60
- "type": "string",
61
- "configurable": false
62
- },
63
- "removed": {
64
- "type": "boolean",
65
- "configurable": false
66
- },
67
- "relatedSlug": {
68
- "type": "string",
69
- "private": true,
70
- "configurable": false
71
- },
72
- "related": {
73
- "collection": "*",
74
- "filter": "field",
75
- "configurable": false
76
- },
77
- "reports": {
78
- "collection": "report",
79
- "plugin": "comments",
80
- "via": "related",
81
- "configurable": false
82
- },
83
- "threadOf": {
84
- "columnName": "threadOf",
85
- "model": "comment",
86
- "plugin": "comments",
87
- "configurable": false
88
- }
89
- }
90
- }
package/models/report.js DELETED
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Read the documentation (https://strapi.io/documentation/3.0.0-beta.x/concepts/models.html#life-cycle-callbacks)
5
- * to customize this model
6
- */
7
-
8
- module.exports = {};
@@ -1,41 +0,0 @@
1
- {
2
- "collectionName": "comments_report",
3
- "info": {
4
- "name": "report",
5
- "description": ""
6
- },
7
- "options": {
8
- "increments": true,
9
- "timestamps": true,
10
- "isManaged": false,
11
- "comment": ""
12
- },
13
- "attributes": {
14
- "content": {
15
- "type": "text",
16
- "configurable": false
17
- },
18
- "reason": {
19
- "type": "enumeration",
20
- "enum": [
21
- "BAD_LANGUAGE",
22
- "DISCRIMINATION",
23
- "OTHER"
24
- ],
25
- "default": "OTHER",
26
- "configurable": false,
27
- "required": true
28
- },
29
- "resolved": {
30
- "type": "boolean",
31
- "default": false,
32
- "configurable": false
33
- },
34
- "related": {
35
- "fieldName": "related",
36
- "model": "comment",
37
- "plugin": "comments",
38
- "configurable": false
39
- }
40
- }
41
- }