strapi-plugin-comments 1.0.2 → 2.0.0-beta.3

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 (154) hide show
  1. package/.circleci/config.yml +2 -2
  2. package/README.md +70 -109
  3. package/admin/src/components/ConfirmationDialog/index.js +56 -0
  4. package/admin/src/components/DiscussionStatus/index.js +33 -0
  5. package/admin/src/components/DiscussionThread/index.js +59 -0
  6. package/admin/src/components/DiscussionThreadItem/index.js +87 -0
  7. package/admin/src/components/DiscussionThreadItem/styles.js +88 -0
  8. package/admin/src/components/DiscussionThreadItemActions/index.js +178 -0
  9. package/admin/src/components/DiscussionThreadItemActions/styles.js +22 -0
  10. package/admin/src/components/DiscussionThreadItemMeta/index.js +31 -0
  11. package/admin/src/components/DiscussionThreadItemWarnings/index.js +141 -0
  12. package/admin/src/components/DiscussionThreadItemWarnings/styles.js +7 -0
  13. package/admin/src/components/EntityDetails/index.js +53 -0
  14. package/admin/src/{containers → components}/Initializer/index.js +4 -4
  15. package/admin/src/components/LoadingIndicatorOverlay/index.js +15 -0
  16. package/admin/src/components/LoadingIndicatorOverlay/styles.js +20 -0
  17. package/admin/src/components/Nav/index.js +45 -0
  18. package/admin/src/components/PluginIcon/index.js +12 -0
  19. package/admin/src/components/ReportsReviewModal/index.js +43 -0
  20. package/admin/src/components/ReportsReviewTable/index.js +146 -0
  21. package/admin/src/components/TableFilters/index.js +53 -0
  22. package/admin/src/components/TablePagination/index.js +35 -0
  23. package/admin/src/components/icons/comments.js +9 -0
  24. package/admin/src/components/icons/index.js +6 -0
  25. package/admin/src/components/icons/lock.js +22 -0
  26. package/admin/src/components/icons/review.js +18 -0
  27. package/admin/src/components/icons/unlock.js +20 -0
  28. package/admin/src/index.js +58 -42
  29. package/admin/src/pages/App/index.js +71 -0
  30. package/admin/src/pages/App/reducer/actions.js +8 -0
  31. package/admin/src/pages/App/reducer/constants.js +4 -0
  32. package/admin/src/pages/App/reducer/index.js +26 -0
  33. package/admin/src/pages/App/reducer/init.js +7 -0
  34. package/admin/src/pages/App/reducer/selectors.js +35 -0
  35. package/admin/src/pages/App/utils/api.js +12 -0
  36. package/admin/src/pages/ComingSoonPage/index.js +25 -0
  37. package/admin/src/pages/Details/index.js +109 -0
  38. package/admin/src/pages/Details/utils/api.js +41 -0
  39. package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +196 -0
  40. package/admin/src/pages/Discover/index.js +157 -0
  41. package/admin/src/pages/Discover/utils/api.js +14 -0
  42. package/admin/src/pages/Discover/utils/filtersSchema.js +9 -0
  43. package/admin/src/permissions.js +13 -33
  44. package/admin/src/pluginId.js +2 -4
  45. package/admin/src/reducers.js +8 -0
  46. package/admin/src/translations/en.json +73 -33
  47. package/admin/src/translations/fr.json +1 -0
  48. package/admin/src/utils/axiosInstance.js +35 -0
  49. package/admin/src/utils/constants.js +28 -0
  50. package/admin/src/utils/getApiUrl.js +5 -0
  51. package/admin/src/utils/getMessage.js +21 -0
  52. package/admin/src/utils/getRelatedGroups.js +5 -0
  53. package/admin/src/utils/getUrl.js +5 -0
  54. package/admin/src/utils/handleAPIError.js +15 -0
  55. package/admin/src/utils/index.js +6 -0
  56. package/codecov.yml +2 -1
  57. package/content-types/comment.js +97 -0
  58. package/content-types/index.js +11 -0
  59. package/content-types/report.js +54 -0
  60. package/package.json +11 -25
  61. package/server/bootstrap.js +5 -0
  62. package/server/config/index.js +10 -0
  63. package/server/controllers/admin.js +134 -0
  64. package/server/controllers/client.js +117 -0
  65. package/server/controllers/index.js +9 -0
  66. package/{controllers → server/controllers}/utils/__tests__/functions.test.js +0 -0
  67. package/{controllers → server/controllers}/utils/functions.js +1 -1
  68. package/server/destroy.js +5 -0
  69. package/server/index.js +22 -0
  70. package/server/register.js +5 -0
  71. package/server/routes/admin.js +92 -0
  72. package/server/routes/client.js +52 -0
  73. package/server/routes/index.js +15 -0
  74. package/server/services/admin.js +215 -0
  75. package/server/services/client.js +227 -0
  76. package/server/services/common.js +197 -0
  77. package/server/services/index.js +11 -0
  78. package/{services → server/services}/utils/__tests__/functions.test.js +7 -9
  79. package/{services → server/services}/utils/functions.js +19 -8
  80. package/server/utils/constants.js +16 -0
  81. package/{services → server}/utils/error.js +0 -0
  82. package/server/utils/functions.js +19 -0
  83. package/strapi-admin.js +3 -0
  84. package/strapi-server.js +9 -0
  85. package/admin/src/assets/images/icon-cross-blue.svg +0 -1
  86. package/admin/src/assets/images/icon_remove.svg +0 -19
  87. package/admin/src/assets/images/logo.svg +0 -5
  88. package/admin/src/components/AbuseReportsPopUp/ItemPreviewContainer.js +0 -8
  89. package/admin/src/components/AbuseReportsPopUp/ModalFooter.js +0 -31
  90. package/admin/src/components/AbuseReportsPopUp/TableContainer.js +0 -63
  91. package/admin/src/components/AbuseReportsPopUp/index.js +0 -148
  92. package/admin/src/components/Container/index.js +0 -7
  93. package/admin/src/components/EmptyView/index.js +0 -25
  94. package/admin/src/components/Filters/index.js +0 -151
  95. package/admin/src/components/Filters/index.styled.js +0 -82
  96. package/admin/src/components/Filters/utils.js +0 -21
  97. package/admin/src/components/Item/CardItem.js +0 -30
  98. package/admin/src/components/Item/CardWrapper.js +0 -10
  99. package/admin/src/components/Item/index.js +0 -92
  100. package/admin/src/components/ItemDetails/CardItem.js +0 -33
  101. package/admin/src/components/ItemDetails/CardLevelCounter.js +0 -46
  102. package/admin/src/components/ItemDetails/CardLevelCounterLink.js +0 -24
  103. package/admin/src/components/ItemDetails/CardLevelWrapper.js +0 -22
  104. package/admin/src/components/ItemDetails/CardWrapper.js +0 -52
  105. package/admin/src/components/ItemDetails/index.js +0 -151
  106. package/admin/src/components/ItemFooter/CardItemAuthor.js +0 -10
  107. package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
  108. package/admin/src/components/ItemFooter/Wrapper.js +0 -20
  109. package/admin/src/components/ItemFooter/index.js +0 -87
  110. package/admin/src/components/ItemHeader/CardHeaderBlocked.js +0 -24
  111. package/admin/src/components/ItemHeader/CardHeaderIndicator.js +0 -30
  112. package/admin/src/components/ItemHeader/CardHeaderIndicatorBlue.js +0 -11
  113. package/admin/src/components/ItemHeader/CardHeaderIndicatorRed.js +0 -11
  114. package/admin/src/components/ItemHeader/CardHeaderIndicatorsContainer.js +0 -18
  115. package/admin/src/components/ItemHeader/CardHeaderReports.js +0 -40
  116. package/admin/src/components/ItemHeader/Wrapper.js +0 -16
  117. package/admin/src/components/ItemHeader/index.js +0 -80
  118. package/admin/src/components/ItemModeration/Wrapper.js +0 -19
  119. package/admin/src/components/ItemModeration/index.js +0 -47
  120. package/admin/src/components/List/Container.js +0 -20
  121. package/admin/src/components/List/index.js +0 -21
  122. package/admin/src/components/Search/index.js +0 -83
  123. package/admin/src/containers/App/Wrapper.js +0 -14
  124. package/admin/src/containers/App/index.js +0 -47
  125. package/admin/src/containers/DataManagerProvider/actions.js +0 -11
  126. package/admin/src/containers/DataManagerProvider/index.js +0 -280
  127. package/admin/src/containers/DataManagerProvider/init.js +0 -5
  128. package/admin/src/containers/DataManagerProvider/reducer.js +0 -59
  129. package/admin/src/containers/DetailsView/Wrapper.js +0 -18
  130. package/admin/src/containers/DetailsView/index.js +0 -100
  131. package/admin/src/containers/ListView/FadedWrapper.js +0 -42
  132. package/admin/src/containers/ListView/Footer.js +0 -53
  133. package/admin/src/containers/ListView/Wrapper.js +0 -17
  134. package/admin/src/containers/ListView/components.js +0 -138
  135. package/admin/src/containers/ListView/index.js +0 -45
  136. package/admin/src/containers/Panel/actions.js +0 -5
  137. package/admin/src/containers/Panel/index.js +0 -191
  138. package/admin/src/containers/Panel/index.styled.js +0 -6
  139. package/admin/src/containers/Panel/reducer.js +0 -44
  140. package/admin/src/contexts/DataManagerContext.js +0 -5
  141. package/admin/src/hooks/useDataManager.js +0 -6
  142. package/admin/src/lifecycles.js +0 -3
  143. package/admin/src/translations/index.js +0 -7
  144. package/admin/src/utils/getTrad.js +0 -5
  145. package/admin/src/utils/getTradId.js +0 -5
  146. package/config/functions/bootstrap.js +0 -48
  147. package/config/routes.json +0 -116
  148. package/config/schema.graphql.js +0 -270
  149. package/controllers/comments.js +0 -211
  150. package/models/comment.js +0 -8
  151. package/models/comment.settings.json +0 -98
  152. package/models/report.js +0 -8
  153. package/models/report.settings.json +0 -49
  154. package/services/comments.js +0 -486
@@ -1,35 +1,75 @@
1
1
  {
2
2
  "plugin.name": "Comments",
3
- "components.Search.placeholder": "Search for an entry...",
4
- "list.header.title": "Comments",
5
- "list.header.description": "{count, plural, =0 {All available} one {# new comment} other {# new comments}}",
6
- "list.content.empty": "Nothing found, lift your search criteria and try again",
7
- "list.item.header.blocked": "This comment has been blocked",
8
- "list.item.header.blocked.thread": "This comment and thread have been blocked",
9
- "list.item.header.removed": "This comment and thread have been removed by author",
10
- "list.item.indication.new": "New comment",
11
- "list.item.indication.abuse": "Abuse reported",
12
- "list.item.threads.drilldown": "Drilldown",
13
- "list.item.threads.count": "{count, plural, =0 {There is no threads} one {# thread} other {# threads}}",
14
- "list.item.header.abuse": "{count, plural, =0 {Nothing reported} one {# report waits for review} other {# reports waits for review}}",
15
- "list.item.moderation.button.comment.restore": "Restore comment",
16
- "list.item.moderation.button.comment.hide": "Hide comment",
17
- "list.item.moderation.button.thread.restore": "Restore thread",
18
- "list.item.moderation.button.thread.hide": "Hide thread",
19
- "moderation.header.title": "Moderation",
20
- "moderation.header.description": "Discussion thread",
21
- "moderation.content.empty": "Choose a comment to start moderating",
22
- "popup.reports.header": "Review - Abuse reports",
23
- "popup.reports.item.header.date": "Issue date",
24
- "popup.reports.item.header.reason": "Reason",
25
- "popup.reports.item.header.message": "Message",
26
- "popup.reports.item.reason.other": "Other",
27
- "popup.reports.item.reason.discrimination": "Discrimination",
28
- "popup.reports.item.reason.bad_language": "Bad language used",
29
- "popup.reports.item.button": "Resolve",
30
- "popup.reports.footer.actions": "Moderator actions:",
31
- "popup.reports.empty": "All good, no issues reported",
32
- "notification.comment.visibility": "Comment visibility has been changed",
33
- "notification.thread.visibility": "Comment thread visibility has been changed",
34
- "notification.abuse-report.resolution": "Abuse report has been resolved"
35
- }
3
+ "common.button.back": "Go back",
4
+ "nav.header.moderation": "Moderation",
5
+ "nav.header.settings": "Settings",
6
+ "nav.item.updates": "Updates",
7
+ "nav.item.discover": "Discover",
8
+ "nav.item.reports": "Reports",
9
+ "nav.item.settings": "Settings",
10
+ "page.updates.header": "Recent updates",
11
+ "page.discover.header": "Discover threads",
12
+ "page.discover.header.count": "entries found",
13
+ "page.discover.table.header.message": "Message",
14
+ "page.discover.table.header.thread": "Thread of",
15
+ "page.discover.table.header.entry": "Entry",
16
+ "page.discover.table.header.lastUpdate": "Last update",
17
+ "page.discover.table.header.status": "Status",
18
+ "page.discover.table.header.status.OPEN": "OPEN",
19
+ "page.discover.table.header.status.BLOCKED": "BLOCKED",
20
+ "page.discover.table.header.status.TO_REVIEW": "TO REVIEW ({count, number})",
21
+ "page.discover.table.header.actions": "Status",
22
+ "page.discover.table.action.display": "Display",
23
+ "page.discover.table.action.reports": "Reports",
24
+ "page.discover.table.empty": "You don't have any comments yet.",
25
+ "page.discover.table.empty.search": "No comments match the search.",
26
+ "page.discover.table.filters": "Filtering",
27
+ "page.discover.table.reports.review": "Review reports",
28
+ "page.details.header": "Discussion panel",
29
+ "page.details.header.description": "Drilldown and manage discussion related to the entity",
30
+ "page.details.panel.discussion": "Discussion",
31
+ "page.details.panel.discussion.nav.drilldown": "Drilldown",
32
+ "page.details.panel.discussion.nav.back": "Go top",
33
+ "page.details.panel.discussion.warnings.reports.description": "open reports",
34
+ "page.details.panel.discussion.warnings.reports.review": "Review",
35
+ "page.details.panel.discussion.warnings.reports.dialog.list": "Reports",
36
+ "page.details.panel.discussion.warnings.reports.dialog.header": "Moderation: Review open reports",
37
+ "page.details.panel.discussion.warnings.reports.dialog.reason": "Reason",
38
+ "page.details.panel.discussion.warnings.reports.dialog.reason.BAD_LANGUAGE": "Bad language",
39
+ "page.details.panel.discussion.warnings.reports.dialog.reason.DISCRIMINATION": "Discrimination",
40
+ "page.details.panel.discussion.warnings.reports.dialog.reason.OTHER": "Other",
41
+ "page.details.panel.discussion.warnings.reports.dialog.content": "Content",
42
+ "page.details.panel.discussion.warnings.reports.dialog.createdAt": "Issue date",
43
+ "page.details.panel.discussion.warnings.reports.dialog.status": "Status",
44
+ "page.details.panel.discussion.warnings.reports.dialog.status.OPEN": "OPEN",
45
+ "page.details.panel.discussion.warnings.reports.dialog.status.RESOLVED": "RESOLVED",
46
+ "page.details.panel.discussion.warnings.reports.dialog.actions": "Actions",
47
+ "page.details.panel.discussion.warnings.reports.dialog.actions.resolve": "Resolve",
48
+ "page.details.panel.discussion.warnings.reports.dialog.confirmation.success": "Open report has been resolved",
49
+ "page.details.panel.discussion.status.blocked": "BLOCKED",
50
+ "page.details.panel.entity": "Entity details",
51
+ "page.details.panel.status": "Discussion is",
52
+ "page.details.panel.status.open": "OPEN",
53
+ "page.details.panel.status.blocked": "BLOCKED",
54
+ "page.details.panel.status.pending": "PENDING",
55
+ "page.details.actions.comment.block": "Block comment",
56
+ "page.details.actions.comment.block.confirmation.header": "Moderation: Block comment",
57
+ "page.details.actions.comment.block.confirmation.description": "Do you really want to block this comment?",
58
+ "page.details.actions.comment.block.confirmation.button.confirm": "Yes, block it",
59
+ "page.details.actions.comment.block.confirmation.success": "Comment has been blocked",
60
+ "page.details.actions.comment.unblock": "Unblock comment",
61
+ "page.details.actions.comment.unblock.confirmation.success": "Comment has been unblocked",
62
+ "page.details.actions.comment.reports.review": "Review",
63
+ "page.details.actions.thread.block": "Block thread",
64
+ "page.details.actions.thread.block.confirmation.header": "Moderation: Block thread",
65
+ "page.details.actions.thread.block.confirmation.description": "Do you really want to block whole thread? No further discussions are going to be allowed.",
66
+ "page.details.actions.thread.block.confirmation.button.confirm": "Yes, block it",
67
+ "page.details.actions.thread.block.confirmation.success": "Thread has been blocked",
68
+ "page.details.actions.thread.unblock": "Unblock thread",
69
+ "page.details.actions.thread.unblock.confirmation.success": "Thread has been unblocked",
70
+ "page.coming.soon": "Wait for what is coming soon...",
71
+ "compontents.confirmation.dialog.header": "Confirmation",
72
+ "compontents.confirmation.dialog.description": "Do you really want to perform this action?",
73
+ "compontents.confirmation.dialog.button.confirm": "Yes, I do",
74
+ "compontents.confirmation.dialog.button.cancel": "Cancel"
75
+ }
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,35 @@
1
+ import axios from 'axios';
2
+ import { auth } from '@strapi/helper-plugin';
3
+
4
+ const instance = axios.create({
5
+ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
6
+ });
7
+
8
+ instance.interceptors.request.use(
9
+ async config => {
10
+ config.headers = {
11
+ Authorization: `Bearer ${auth.getToken()}`,
12
+ Accept: 'application/json',
13
+ 'Content-Type': 'application/json',
14
+ };
15
+
16
+ return config;
17
+ },
18
+ error => {
19
+ Promise.reject(error);
20
+ }
21
+ );
22
+
23
+ instance.interceptors.response.use(
24
+ response => response,
25
+ error => {
26
+ if (error.response?.status === 401) {
27
+ auth.clearAppStorage();
28
+ window.location.reload();
29
+ }
30
+
31
+ throw error;
32
+ }
33
+ );
34
+
35
+ export default instance;
@@ -0,0 +1,28 @@
1
+ export const APPROVAL_STATUS = {
2
+ PENDING: "PENDING",
3
+ APPROVED: "APPROVED",
4
+ REJECTED: "REJECTED",
5
+ };
6
+
7
+ export const REPORT_STATUS = {
8
+ 'RESOLVED': 'RESOLVED',
9
+ 'OPEN': 'OPEN',
10
+ };
11
+
12
+ export const REPORT_REASON = {
13
+ 'BAD_LANGUAGE': 'BAD_LANGUAGE',
14
+ 'DISCRIMINATION': 'DISCRIMINATION',
15
+ 'OTHER': 'OTHER',
16
+ };
17
+
18
+ export const COMMENT_STATUS = {
19
+ 'BLOCKED': 'BLOCKED',
20
+ 'OPEN': 'OPEN',
21
+ 'TO_REVIEW': 'TO_REVIEW',
22
+ };
23
+
24
+ export const REGEX = {
25
+ uid: new RegExp(/^(?<type>[a-z]+)\:{2}(?<api>[a-z]+)\.{1}(?<contentType>[a-z]+)$/gmi),
26
+ relatedUid: new RegExp(/^(?<uid>[a-z]+\:{2}[a-z]+\.[a-z]+)\:{1}(?<id>[0-9]+)$/gmi),
27
+ email: new RegExp(/\S+@\S+\.\S+/),
28
+ };
@@ -0,0 +1,5 @@
1
+ import pluginId from '../pluginId';
2
+
3
+ const getApiURL = endPoint => `/${pluginId}/${endPoint}`;
4
+
5
+ export default getApiURL;
@@ -0,0 +1,21 @@
1
+
2
+ import { useIntl } from 'react-intl';
3
+ import { isString } from 'lodash';
4
+
5
+ import pluginId from '../pluginId';
6
+
7
+ const getMessage = (input, defaultMessage, inPluginScope = true) => {
8
+ const { formatMessage } = useIntl();
9
+ let formattedId = ''
10
+ if (isString(input)) {
11
+ formattedId = input;
12
+ } else {
13
+ formattedId = input?.id;
14
+ }
15
+ return formatMessage({
16
+ id: `${inPluginScope ? pluginId : 'app.components'}.${formattedId}`,
17
+ defaultMessage,
18
+ }, input?.props || undefined)
19
+ };
20
+
21
+ export default getMessage;
@@ -0,0 +1,5 @@
1
+ import { REGEX } from "./constants";
2
+
3
+ const getRelatedGroups = related => related.split(REGEX.relatedUid).filter(s => s && s.length > 0);
4
+
5
+ export default getRelatedGroups;
@@ -0,0 +1,5 @@
1
+ import pluginId from '../pluginId';
2
+
3
+ const getUrl = (path = '') => `/plugins/${pluginId}/${path}`;
4
+
5
+ export default getUrl;
@@ -0,0 +1,15 @@
1
+
2
+ const handleAPIError = (err = null, toggleNotification = null) => {
3
+ toggleNotification({
4
+ type: 'warning',
5
+ message: 'app.components.notification.error',
6
+ });
7
+
8
+ if (err) {
9
+ throw err;
10
+ } else {
11
+ throw new Error('error');
12
+ }
13
+ }
14
+
15
+ export default handleAPIError;
@@ -0,0 +1,6 @@
1
+ export { default as axiosInstance } from './axiosInstance';
2
+ export { default as getApiURL } from './getApiURL';
3
+ export { default as getUrl } from './getUrl';
4
+ export { default as getMessage } from './getMessage';
5
+ export { default as handleAPIError } from './handleAPIError';
6
+ export { default as getRelatedGroups } from './getRelatedGroups';
package/codecov.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  comment:
2
2
  branches:
3
- - master
3
+ - master
4
+ - feat/strapi-v4
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Comments Collection Type
3
+ */
4
+
5
+ module.exports = {
6
+ info: {
7
+ tableName: 'plugin-comments-comments',
8
+ singularName: 'comment',
9
+ pluralName: 'comments',
10
+ displayName: 'Comment',
11
+ description: 'Comment content type',
12
+ kind: 'collectionType',
13
+ },
14
+ options: {
15
+ draftAndPublish: false,
16
+ },
17
+ pluginOptions: {
18
+ 'content-manager': {
19
+ visible: false
20
+ },
21
+ 'content-type-builder': {
22
+ visible: false
23
+ }
24
+ },
25
+ attributes: {
26
+ content: {
27
+ type: 'text',
28
+ configurable: false,
29
+ required: true
30
+ },
31
+ blocked: {
32
+ type: 'boolean',
33
+ default: false,
34
+ configurable: false
35
+ },
36
+ blockedThread: {
37
+ type: 'boolean',
38
+ default: false,
39
+ configurable: false
40
+ },
41
+ blockReason: {
42
+ type: 'string',
43
+ configurable: false
44
+ },
45
+ authorUser: {
46
+ type: 'relation',
47
+ relation: 'oneToOne',
48
+ target: 'plugin::users-permissions.user',
49
+ configurable: false,
50
+ },
51
+ authorType: {
52
+ type: 'string',
53
+ configurable: false
54
+ },
55
+ authorId: {
56
+ type: 'string',
57
+ configurable: false
58
+ },
59
+ authorName: {
60
+ type: 'string',
61
+ configurable: false
62
+ },
63
+ authorEmail: {
64
+ type: 'email',
65
+ configurable: false
66
+ },
67
+ authorAvatar: {
68
+ type: 'string',
69
+ configurable: false
70
+ },
71
+ removed: {
72
+ type: 'boolean',
73
+ configurable: false
74
+ },
75
+ approvalStatus: {
76
+ type: 'string',
77
+ configurable: false
78
+ },
79
+ related: {
80
+ type: 'string',
81
+ configurable: false
82
+ },
83
+ reports: {
84
+ type: 'relation',
85
+ relation: 'oneToMany',
86
+ target: 'plugin::comments.comment-report',
87
+ mappedBy: 'related',
88
+ configurable: false,
89
+ },
90
+ threadOf: {
91
+ type: 'relation',
92
+ relation: 'oneToOne',
93
+ target: 'plugin::comments.comment',
94
+ configurable: false,
95
+ },
96
+ },
97
+ };
@@ -0,0 +1,11 @@
1
+ const CommentCT = require('./comment');
2
+ const ReportCT = require('./report');
3
+
4
+ module.exports = {
5
+ 'comment': {
6
+ schema: CommentCT,
7
+ },
8
+ 'comment-report': {
9
+ schema: ReportCT,
10
+ },
11
+ };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Comments Collection Type
3
+ */
4
+
5
+ module.exports = {
6
+ info: {
7
+ tableName: 'plugin-comments-reports',
8
+ singularName: 'comment-report',
9
+ pluralName: 'comment-reports',
10
+ displayName: 'Reports',
11
+ description: 'Reports content type',
12
+ kind: 'collectionType',
13
+ },
14
+ options: {
15
+ draftAndPublish: false,
16
+ },
17
+ pluginOptions: {
18
+ 'content-manager': {
19
+ visible: false
20
+ },
21
+ 'content-type-builder': {
22
+ visible: false
23
+ }
24
+ },
25
+ attributes: {
26
+ content: {
27
+ type: 'text',
28
+ configurable: false
29
+ },
30
+ reason: {
31
+ type: 'enumeration',
32
+ enum: [
33
+ 'BAD_LANGUAGE',
34
+ 'DISCRIMINATION',
35
+ 'OTHER'
36
+ ],
37
+ default: 'OTHER',
38
+ configurable: false,
39
+ required: true
40
+ },
41
+ resolved: {
42
+ type: 'boolean',
43
+ default: false,
44
+ configurable: false
45
+ },
46
+ related: {
47
+ type: 'relation',
48
+ relation: 'manyToOne',
49
+ target: 'plugin::comments.comment',
50
+ inversedBy: 'reports',
51
+ configurable: false,
52
+ },
53
+ },
54
+ };
package/package.json CHANGED
@@ -1,41 +1,27 @@
1
1
  {
2
2
  "name": "strapi-plugin-comments",
3
- "version": "1.0.2",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "Strapi - Comments plugin",
5
5
  "strapi": {
6
- "name": "Comments",
7
- "icon": "comments",
8
- "description": "Comments & audience engagement"
6
+ "name": "comments",
7
+ "description": "Comments & audience engagement",
8
+ "kind": "plugin"
9
+ },
10
+ "scripts": {
11
+ "test:unit": "jest --verbose --coverage"
9
12
  },
10
13
  "repository": {
11
14
  "type": "git",
12
15
  "url": "https://github.com/VirtusLab-Open-Source/strapi-plugin-comments"
13
16
  },
14
- "scripts": {
15
- "test:unit": "jest --verbose --coverage"
16
- },
17
17
  "dependencies": {
18
- "bad-words": "^3.0.3",
19
- "lodash": "^4.17.11",
20
- "react": "^16.9.0",
21
- "react-dom": "^16.9.0",
22
- "react-intl": "4.5.0",
23
- "react-redux": "^7.0.2",
24
- "react-router": "^5.0.0",
25
- "react-router-dom": "^5.0.0",
26
- "reactstrap": "8.4.1",
27
- "redux-saga": "^0.16.0",
28
- "request": "^2.83.0",
29
- "strapi-helper-plugin": "3.6.8",
30
- "strapi-utils": "3.6.8",
31
- "uuid": "^3.1.0"
18
+ "bad-words": "^3.0.4"
32
19
  },
33
20
  "devDependencies": {
34
- "koa": "^2.8.0",
21
+ "codecov": "^3.7.2",
35
22
  "jest": "^26.0.1",
36
23
  "jest-cli": "^26.0.1",
37
- "jest-styled-components": "^7.0.2",
38
- "codecov": "^3.7.2"
24
+ "jest-styled-components": "^7.0.2"
39
25
  },
40
26
  "author": {
41
27
  "name": "VirtusLab // Mateusz Ziarko",
@@ -55,7 +41,7 @@
55
41
  }
56
42
  ],
57
43
  "engines": {
58
- "node": ">=10.16.0",
44
+ "node": ">=12.x. <=16.x.x",
59
45
  "npm": ">=6.0.0"
60
46
  },
61
47
  "keywords": ["strapi", "plugin", "comments"],
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => {
4
+ // bootstrap phase
5
+ };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ default: {
5
+ entryLabel: {
6
+ '*': ['Title', 'title', 'Name', 'name', 'Subject', 'subject']
7
+ }
8
+ },
9
+ validator() {},
10
+ };
@@ -0,0 +1,134 @@
1
+ 'use strict';
2
+
3
+ const { getPluginService } = require('./../utils/functions');
4
+ const { parseParams, throwError } = require('./utils/functions');
5
+ const _ = require('lodash');
6
+
7
+ module.exports = {
8
+
9
+ getService(name = 'admin') {
10
+ return getPluginService(name);
11
+ },
12
+
13
+ async findAll(ctx) {
14
+ return this.getService()
15
+ .findAll(ctx.query);
16
+ },
17
+
18
+ async findOne(ctx) {
19
+ const { params = {} } = ctx;
20
+ const { id } = parseParams(params);
21
+ try {
22
+ return await this.getService()
23
+ .findOneAndThread(id);
24
+ } catch (e) {
25
+ throwError(ctx, e);
26
+ }
27
+ },
28
+
29
+ async blockComment(ctx) {
30
+ const { params = {} } = ctx;
31
+ const { id } = parseParams(params);
32
+ try {
33
+ return await this.getService()
34
+ .blockComment(id, true);
35
+ } catch (e) {
36
+ throwError(ctx, e);
37
+ }
38
+ },
39
+
40
+ async unblockComment(ctx) {
41
+ const { params = {} } = ctx;
42
+ const { id } = parseParams(params);
43
+ try {
44
+ return await this.getService()
45
+ .blockComment(id, false);
46
+ } catch (e) {
47
+ throwError(ctx, e);
48
+ }
49
+ },
50
+
51
+ async blockCommentThread(ctx) {
52
+ const { params = {} } = ctx;
53
+ const { id } = parseParams(params);
54
+ try {
55
+ return await this.getService()
56
+ .blockCommentThread(id, true);
57
+ } catch (e) {
58
+ throwError(ctx, e);
59
+ }
60
+ },
61
+
62
+ async unblockCommentThread(ctx) {
63
+ const { params = {} } = ctx;
64
+ const { id } = parseParams(params);
65
+ try {
66
+ return await this.getService()
67
+ .blockCommentThread(id, false);
68
+ } catch (e) {
69
+ throwError(ctx, e);
70
+ }
71
+ },
72
+
73
+ async resolveAbuseReport(ctx) {
74
+ const { params = {} } = ctx;
75
+ const { id: commentId, reportId } = parseParams(params);
76
+ try {
77
+ return await this.getService()
78
+ .resolveAbuseReport(reportId, commentId);
79
+ } catch (e) {
80
+ throwError(ctx, e);
81
+ }
82
+ },
83
+
84
+ async approveComment(ctx) {
85
+ const { id } = parseParams(ctx.params || {});
86
+ try {
87
+ return await this.getService()
88
+ .approveComment(id);
89
+ } catch (e) {
90
+ throwError(ctx, e);
91
+ }
92
+ },
93
+
94
+ async rejectComment(ctx) {
95
+ const { id } = parseParams(ctx.params || {});
96
+ try {
97
+ return await this.getService()
98
+ .rejectComment(id);
99
+ } catch (e) {
100
+ throwError(ctx, e);
101
+ }
102
+ },
103
+
104
+ async config() {
105
+ try {
106
+ return await this.getService().config();
107
+ } catch (e) {
108
+ throwError(ctx, e);
109
+ }
110
+ },
111
+
112
+ getContentsTypes() {
113
+ return Object.entries(strapi.contentTypes)
114
+ .filter(([, contentType]) => (
115
+ contentType.associations || []).some(_ => _.plugin === 'comments' && _.collection === 'comment'),
116
+ )
117
+ .reduce((acc, [, contentType]) => [
118
+ ...acc,
119
+ { key: contentType.globalName, value: contentType.collectionName }],
120
+ [],
121
+ );
122
+ },
123
+
124
+ async contentTypeName(ctx) {
125
+ const { params: { contentTypeName } } = ctx;
126
+ try {
127
+ const result = await this.getService()
128
+ .contentTypeName(contentTypeName);
129
+ return { list: result };
130
+ } catch (e) {
131
+ throwError(ctx, e);
132
+ }
133
+ },
134
+ };