strapi-plugin-comments 1.0.2-beta.1 → 2.0.0-beta.2
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.
- package/.circleci/config.yml +2 -2
- package/README.md +71 -95
- package/admin/src/components/ConfirmationDialog/index.js +56 -0
- package/admin/src/components/DiscussionStatus/index.js +33 -0
- package/admin/src/components/DiscussionThread/index.js +58 -0
- package/admin/src/components/DiscussionThreadItem/index.js +87 -0
- package/admin/src/components/DiscussionThreadItem/styles.js +87 -0
- package/admin/src/components/DiscussionThreadItemActions/index.js +176 -0
- package/admin/src/components/DiscussionThreadItemActions/styles.js +22 -0
- package/admin/src/components/DiscussionThreadItemMeta/index.js +31 -0
- package/admin/src/components/DiscussionThreadItemWarnings/index.js +137 -0
- package/admin/src/components/DiscussionThreadItemWarnings/styles.js +7 -0
- package/admin/src/components/EntityDetails/index.js +53 -0
- package/admin/src/{containers → components}/Initializer/index.js +4 -4
- package/admin/src/components/LoadingIndicatorOverlay/index.js +15 -0
- package/admin/src/components/LoadingIndicatorOverlay/styles.js +20 -0
- package/admin/src/components/Nav/index.js +45 -0
- package/admin/src/components/PluginIcon/index.js +12 -0
- package/admin/src/components/ReportsReviewModal/index.js +45 -0
- package/admin/src/components/ReportsReviewTable/index.js +142 -0
- package/admin/src/components/TableFilters/index.js +53 -0
- package/admin/src/components/TablePagination/index.js +35 -0
- package/admin/src/components/icons/comments.js +9 -0
- package/admin/src/index.js +58 -42
- package/admin/src/pages/App/index.js +60 -0
- package/admin/src/pages/App/reducer/actions.js +8 -0
- package/admin/src/pages/App/reducer/constants.js +4 -0
- package/admin/src/pages/App/reducer/index.js +27 -0
- package/admin/src/pages/App/reducer/init.js +7 -0
- package/admin/src/pages/App/reducer/selectors.js +35 -0
- package/admin/src/pages/App/utils/api.js +20 -0
- package/admin/src/pages/ComingSoonPage/index.js +25 -0
- package/admin/src/pages/Details/index.js +109 -0
- package/admin/src/pages/Details/utils/api.js +41 -0
- package/admin/src/pages/Discover/index.js +203 -0
- package/admin/src/pages/Discover/utils/api.js +20 -0
- package/admin/src/pages/Discover/utils/filtersSchema.js +9 -0
- package/admin/src/permissions.js +13 -33
- package/admin/src/pluginId.js +2 -4
- package/admin/src/reducers.js +8 -0
- package/admin/src/translations/en.json +72 -33
- package/admin/src/translations/fr.json +1 -0
- package/admin/src/utils/axiosInstance.js +35 -0
- package/admin/src/utils/constants.js +28 -0
- package/admin/src/utils/getApiUrl.js +5 -0
- package/admin/src/utils/getMessage.js +14 -0
- package/admin/src/utils/getRelatedGroups.js +5 -0
- package/admin/src/utils/getUrl.js +5 -0
- package/admin/src/utils/handleAPIError.js +15 -0
- package/admin/src/utils/index.js +6 -0
- package/codecov.yml +2 -1
- package/content-types/comment.js +97 -0
- package/content-types/index.js +11 -0
- package/content-types/report.js +54 -0
- package/package.json +11 -25
- package/server/bootstrap.js +5 -0
- package/server/config/index.js +10 -0
- package/server/controllers/admin.js +134 -0
- package/server/controllers/client.js +109 -0
- package/server/controllers/index.js +9 -0
- package/{controllers → server/controllers}/utils/__tests__/functions.test.js +0 -0
- package/{controllers → server/controllers}/utils/functions.js +1 -1
- package/server/destroy.js +5 -0
- package/server/index.js +22 -0
- package/server/register.js +5 -0
- package/server/routes/admin.js +92 -0
- package/server/routes/client.js +52 -0
- package/server/routes/index.js +15 -0
- package/server/services/admin.js +186 -0
- package/server/services/client.js +227 -0
- package/server/services/common.js +191 -0
- package/server/services/index.js +11 -0
- package/{services → server/services}/utils/__tests__/functions.test.js +7 -9
- package/{services → server/services}/utils/functions.js +19 -8
- package/server/utils/constants.js +16 -0
- package/{services → server}/utils/error.js +0 -0
- package/server/utils/functions.js +19 -0
- package/strapi-admin.js +3 -0
- package/strapi-server.js +9 -0
- package/admin/src/assets/images/icon-cross-blue.svg +0 -1
- package/admin/src/assets/images/icon_remove.svg +0 -19
- package/admin/src/assets/images/logo.svg +0 -5
- package/admin/src/components/AbuseReportsPopUp/ItemPreviewContainer.js +0 -8
- package/admin/src/components/AbuseReportsPopUp/ModalFooter.js +0 -31
- package/admin/src/components/AbuseReportsPopUp/TableContainer.js +0 -63
- package/admin/src/components/AbuseReportsPopUp/index.js +0 -148
- package/admin/src/components/Container/index.js +0 -7
- package/admin/src/components/EmptyView/index.js +0 -25
- package/admin/src/components/Filters/index.js +0 -151
- package/admin/src/components/Filters/index.styled.js +0 -82
- package/admin/src/components/Filters/utils.js +0 -21
- package/admin/src/components/Item/CardItem.js +0 -30
- package/admin/src/components/Item/CardWrapper.js +0 -10
- package/admin/src/components/Item/index.js +0 -92
- package/admin/src/components/ItemDetails/CardItem.js +0 -33
- package/admin/src/components/ItemDetails/CardLevelCounter.js +0 -46
- package/admin/src/components/ItemDetails/CardLevelCounterLink.js +0 -24
- package/admin/src/components/ItemDetails/CardLevelWrapper.js +0 -22
- package/admin/src/components/ItemDetails/CardWrapper.js +0 -52
- package/admin/src/components/ItemDetails/index.js +0 -151
- package/admin/src/components/ItemFooter/CardItemAuthor.js +0 -10
- package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
- package/admin/src/components/ItemFooter/Wrapper.js +0 -20
- package/admin/src/components/ItemFooter/index.js +0 -87
- package/admin/src/components/ItemHeader/CardHeaderBlocked.js +0 -24
- package/admin/src/components/ItemHeader/CardHeaderIndicator.js +0 -30
- package/admin/src/components/ItemHeader/CardHeaderIndicatorBlue.js +0 -11
- package/admin/src/components/ItemHeader/CardHeaderIndicatorRed.js +0 -11
- package/admin/src/components/ItemHeader/CardHeaderIndicatorsContainer.js +0 -18
- package/admin/src/components/ItemHeader/CardHeaderReports.js +0 -40
- package/admin/src/components/ItemHeader/Wrapper.js +0 -16
- package/admin/src/components/ItemHeader/index.js +0 -80
- package/admin/src/components/ItemModeration/Wrapper.js +0 -19
- package/admin/src/components/ItemModeration/index.js +0 -47
- package/admin/src/components/List/Container.js +0 -20
- package/admin/src/components/List/index.js +0 -21
- package/admin/src/components/Search/index.js +0 -83
- package/admin/src/containers/App/Wrapper.js +0 -14
- package/admin/src/containers/App/index.js +0 -47
- package/admin/src/containers/DataManagerProvider/actions.js +0 -11
- package/admin/src/containers/DataManagerProvider/index.js +0 -280
- package/admin/src/containers/DataManagerProvider/init.js +0 -5
- package/admin/src/containers/DataManagerProvider/reducer.js +0 -59
- package/admin/src/containers/DetailsView/Wrapper.js +0 -18
- package/admin/src/containers/DetailsView/index.js +0 -100
- package/admin/src/containers/ListView/FadedWrapper.js +0 -42
- package/admin/src/containers/ListView/Footer.js +0 -53
- package/admin/src/containers/ListView/Wrapper.js +0 -17
- package/admin/src/containers/ListView/components.js +0 -138
- package/admin/src/containers/ListView/index.js +0 -45
- package/admin/src/containers/Panel/actions.js +0 -5
- package/admin/src/containers/Panel/index.js +0 -191
- package/admin/src/containers/Panel/index.styled.js +0 -6
- package/admin/src/containers/Panel/reducer.js +0 -44
- package/admin/src/contexts/DataManagerContext.js +0 -5
- package/admin/src/hooks/useDataManager.js +0 -6
- package/admin/src/lifecycles.js +0 -3
- package/admin/src/translations/index.js +0 -7
- package/admin/src/utils/getTrad.js +0 -5
- package/admin/src/utils/getTradId.js +0 -5
- package/config/functions/bootstrap.js +0 -48
- package/config/routes.json +0 -116
- package/config/schema.graphql.js +0 -270
- package/controllers/comments.js +0 -211
- package/models/comment.js +0 -8
- package/models/comment.settings.json +0 -98
- package/models/report.js +0 -8
- package/models/report.settings.json +0 -49
- package/services/comments.js +0 -486
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const BadWordsFilter = require('bad-words');
|
|
2
|
-
const PluginError = require('
|
|
2
|
+
const PluginError = require('./../../utils/error');
|
|
3
|
+
const { REGEX } = require('./../../utils/constants')
|
|
3
4
|
const { first, get, isObject, isNil } = require('lodash');
|
|
4
5
|
|
|
5
6
|
const buildNestedStructure = (
|
|
@@ -8,12 +9,11 @@ const buildNestedStructure = (
|
|
|
8
9
|
field = 'parent',
|
|
9
10
|
dropBlockedThreads = false,
|
|
10
11
|
blockNestedThreads = false,
|
|
11
|
-
isMongoDB = false
|
|
12
12
|
) =>
|
|
13
13
|
entities
|
|
14
14
|
.filter(entity => {
|
|
15
15
|
// mongo by default not return `null` for empty data
|
|
16
|
-
if (
|
|
16
|
+
if (entity[field] === null && id === null) {
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
let data = entity[field];
|
|
@@ -34,12 +34,15 @@ const buildNestedStructure = (
|
|
|
34
34
|
module.exports = {
|
|
35
35
|
isEqualEntity: (existing, data, user) => {
|
|
36
36
|
const { authorUser, authorId } = existing;
|
|
37
|
+
console.log('data', data);
|
|
38
|
+
console.log(existing);
|
|
39
|
+
const { author } = data;
|
|
37
40
|
if (authorUser) {
|
|
38
|
-
const existingUserId =
|
|
39
|
-
const receivedUserId =
|
|
41
|
+
const existingUserId = authorUser?.id || authorUser;
|
|
42
|
+
const receivedUserId = user?.id || author;
|
|
40
43
|
return existingUserId === receivedUserId;
|
|
41
44
|
}
|
|
42
|
-
return authorId ===
|
|
45
|
+
return authorId === author?.id;
|
|
43
46
|
},
|
|
44
47
|
|
|
45
48
|
extractMeta: plugins => {
|
|
@@ -54,13 +57,21 @@ module.exports = {
|
|
|
54
57
|
};
|
|
55
58
|
},
|
|
56
59
|
|
|
60
|
+
getRelatedGroups: related => related.split(REGEX.relatedUid).filter(s => s && s.length > 0),
|
|
61
|
+
|
|
62
|
+
getModelUid: name => {
|
|
63
|
+
return strapi
|
|
64
|
+
.plugin('comments')
|
|
65
|
+
.contentTypes[name]?.uid;
|
|
66
|
+
},
|
|
67
|
+
|
|
57
68
|
filterOurResolvedReports: item => (item ? {
|
|
58
69
|
...item,
|
|
59
70
|
reports: (item.reports || []).filter(report => !report.resolved),
|
|
60
71
|
} : item),
|
|
61
72
|
|
|
62
73
|
checkBadWords: content => {
|
|
63
|
-
const config = get(strapi.config, '
|
|
74
|
+
const config = get(strapi.config, 'plugins.comments.badWords', true);
|
|
64
75
|
if (config) {
|
|
65
76
|
const filter = new BadWordsFilter(isObject(config) ? config : undefined);
|
|
66
77
|
if (content && filter.isProfane(content)) {
|
|
@@ -82,7 +93,7 @@ module.exports = {
|
|
|
82
93
|
buildNestedStructure,
|
|
83
94
|
|
|
84
95
|
isValidUserContext: (user = {}) => {
|
|
85
|
-
|
|
96
|
+
const builtInContextEnabled = get(strapi.config, 'plugins.comments.enableUsers', false);
|
|
86
97
|
return builtInContextEnabled ? !isNil(user.id) : true;
|
|
87
98
|
},
|
|
88
99
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const APPROVAL_STATUS = {
|
|
2
|
+
PENDING: "PENDING",
|
|
3
|
+
APPROVED: "APPROVED",
|
|
4
|
+
REJECTED: "REJECTED",
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const REGEX = {
|
|
8
|
+
uid: new RegExp(/^(?<type>[a-z]+)\:{2}(?<api>[a-z]+)\.{1}(?<contentType>[a-z]+)$/gmi),
|
|
9
|
+
relatedUid: new RegExp(/^(?<uid>[a-z]+\:{2}[a-z]+\.[a-z]+)\:{1}(?<id>[0-9]+)$/gmi),
|
|
10
|
+
email: new RegExp(/\S+@\S+\.\S+/),
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
APPROVAL_STATUS,
|
|
15
|
+
REGEX,
|
|
16
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
getPluginService(name) {
|
|
5
|
+
return strapi
|
|
6
|
+
.plugin('comments')
|
|
7
|
+
.service(name);
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
parseParams: params =>
|
|
11
|
+
Object.keys(params).reduce((prev, curr) => {
|
|
12
|
+
const value = params[curr];
|
|
13
|
+
const parsedValue = Number(value);
|
|
14
|
+
return {
|
|
15
|
+
...prev,
|
|
16
|
+
[curr]: isNaN(parsedValue) ? value : parsedValue
|
|
17
|
+
};
|
|
18
|
+
}, {}),
|
|
19
|
+
};
|
package/strapi-admin.js
ADDED
package/strapi-server.js
ADDED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg width="8" height="8" xmlns="http://www.w3.org/2000/svg"><path d="M7.78 6.72L5.06 4l2.72-2.72a.748.748 0 0 0 0-1.06.748.748 0 0 0-1.06 0L4 2.94 1.28.22a.748.748 0 0 0-1.06 0 .748.748 0 0 0 0 1.06L2.94 4 .22 6.72a.748.748 0 0 0 0 1.06.748.748 0 0 0 1.06 0L4 5.06l2.72 2.72a.748.748 0 0 0 1.06 0 .752.752 0 0 0 0-1.06z" fill="#007EFF" fill-rule="evenodd"/></svg>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
-
<!-- Generator: Sketch 49.3 (51167) - http://www.bohemiancoding.com/sketch -->
|
|
4
|
-
<title>Icon remove</title>
|
|
5
|
-
<desc>Created with Sketch.</desc>
|
|
6
|
-
<defs></defs>
|
|
7
|
-
<g id="Pages" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
8
|
-
<g id="Content-Manager---List-view" transform="translate(-279.000000, -165.000000)">
|
|
9
|
-
<g id="Container" transform="translate(234.000000, 0.000000)">
|
|
10
|
-
<g id="Add-filters" transform="translate(0.000000, 60.000000)">
|
|
11
|
-
<g id="Icon-remove" transform="translate(45.000000, 105.000000)">
|
|
12
|
-
<rect id="Rectangle-12" stroke="#E3E9F3" x="0.5" y="0.5" width="19" height="19" rx="9.5"></rect>
|
|
13
|
-
<path d="M6,10 L14,10" id="Line-4" stroke="#007EFF" stroke-width="2" stroke-linecap="round"></path>
|
|
14
|
-
</g>
|
|
15
|
-
</g>
|
|
16
|
-
</g>
|
|
17
|
-
</g>
|
|
18
|
-
</g>
|
|
19
|
-
</svg>
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M532 386.2c27.5-27.1 44-61.1 44-98.2 0-80-76.5-146.1-176.2-157.9C368.3 72.5 294.3 32 208 32 93.1 32 0 103.6 0 192c0 37 16.5 71 44 98.2-15.3 30.7-37.3 54.5-37.7 54.9-6.3 6.7-8.1 16.5-4.4 25 3.6 8.5 12 14 21.2 14 53.5 0 96.7-20.2 125.2-38.8 9.2 2.1 18.7 3.7 28.4 4.9C208.1 407.6 281.8 448 368 448c20.8 0 40.8-2.4 59.8-6.8C456.3 459.7 499.4 480 553 480c9.2 0 17.5-5.5 21.2-14 3.6-8.5 1.9-18.3-4.4-25-.4-.3-22.5-24.1-37.8-54.8zm-392.8-92.3L122.1 305c-14.1 9.1-28.5 16.3-43.1 21.4 2.7-4.7 5.4-9.7 8-14.8l15.5-31.1L77.7 256C64.2 242.6 48 220.7 48 192c0-60.7 73.3-112 160-112s160 51.3 160 112-73.3 112-160 112c-16.5 0-33-1.9-49-5.6l-19.8-4.5zM498.3 352l-24.7 24.4 15.5 31.1c2.6 5.1 5.3 10.1 8 14.8-14.6-5.1-29-12.3-43.1-21.4l-17.1-11.1-19.9 4.6c-16 3.7-32.5 5.6-49 5.6-54 0-102.2-20.1-131.3-49.7C338 339.5 416 272.9 416 192c0-3.4-.4-6.7-.7-10C479.7 196.5 528 238.8 528 288c0 28.7-16.2 50.6-29.7 64z"/></svg>
|
|
2
|
-
<!--
|
|
3
|
-
Font Awesome Free 5.2.0 by @fontawesome - https://fontawesome.com
|
|
4
|
-
License - https://fontawesome.com/license (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
|
5
|
-
-->
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ModalFooter as StrapiModalFooter, colors } from 'strapi-helper-plugin';
|
|
2
|
-
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
|
|
5
|
-
const ModalFooter = styled(StrapiModalFooter)`
|
|
6
|
-
section {
|
|
7
|
-
justify-content: flex-end;
|
|
8
|
-
&:last-of-type {
|
|
9
|
-
justify-content: flex-end;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
label {
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: row;
|
|
15
|
-
align-items: center;
|
|
16
|
-
justify-content: center;
|
|
17
|
-
padding: 0;
|
|
18
|
-
margin: 0;
|
|
19
|
-
|
|
20
|
-
color: ${colors.leftMenu.darkGrey};
|
|
21
|
-
font-weight: 600;
|
|
22
|
-
font-style: italic;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
button {
|
|
26
|
-
margin-left: 1rem;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
export default ModalFooter;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { colors } from 'strapi-helper-plugin';
|
|
2
|
-
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
|
|
5
|
-
const TableContainer = styled.div`
|
|
6
|
-
table {
|
|
7
|
-
thead {
|
|
8
|
-
tr {
|
|
9
|
-
border-bottom: 1px ${colors.grey} solid;
|
|
10
|
-
|
|
11
|
-
td {
|
|
12
|
-
background: transparent;
|
|
13
|
-
|
|
14
|
-
&:first-child {
|
|
15
|
-
padding-left: 0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
&:last-child {
|
|
19
|
-
padding-right: 0;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
tbody {
|
|
26
|
-
tr {
|
|
27
|
-
background-color: white;
|
|
28
|
-
|
|
29
|
-
td {
|
|
30
|
-
&:first-child {
|
|
31
|
-
padding-left: 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&:last-child {
|
|
35
|
-
padding-right: 0;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&:last-child {
|
|
40
|
-
border-bottom: 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&:hover {
|
|
44
|
-
background-color: white;
|
|
45
|
-
|
|
46
|
-
cursor: default;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
p {
|
|
52
|
-
margin: 0;
|
|
53
|
-
padding: 0;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&>div {
|
|
58
|
-
box-shadow: none;
|
|
59
|
-
border: 0;
|
|
60
|
-
}
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
export default TableContainer;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* AbuseReportsPopUp
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { FormattedMessage } from 'react-intl';
|
|
9
|
-
import moment from 'moment';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import { isEmpty } from 'lodash';
|
|
12
|
-
import {
|
|
13
|
-
ButtonModal,
|
|
14
|
-
HeaderModal,
|
|
15
|
-
HeaderModalTitle,
|
|
16
|
-
Modal,
|
|
17
|
-
ModalBody,
|
|
18
|
-
ModalForm,
|
|
19
|
-
useGlobalContext,
|
|
20
|
-
CheckPermissions,
|
|
21
|
-
} from 'strapi-helper-plugin';
|
|
22
|
-
import { Table, Button } from '@buffetjs/core';
|
|
23
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
24
|
-
import {
|
|
25
|
-
faCheck,
|
|
26
|
-
faSmile,
|
|
27
|
-
} from '@fortawesome/free-solid-svg-icons';
|
|
28
|
-
import TableContainer from './TableContainer';
|
|
29
|
-
import EmptyView from '../EmptyView';
|
|
30
|
-
import ItemDetails from '../ItemDetails';
|
|
31
|
-
import ItemPreviewContainer from './ItemPreviewContainer';
|
|
32
|
-
import ModalFooter from './ModalFooter';
|
|
33
|
-
import pluginId from '../../pluginId';
|
|
34
|
-
|
|
35
|
-
// Translations
|
|
36
|
-
import en from '../../translations/en.json';
|
|
37
|
-
import pluginPermissions from '../../permissions';
|
|
38
|
-
|
|
39
|
-
const CustomRow = props => {
|
|
40
|
-
const { row, formatMessage, onClick } = props;
|
|
41
|
-
const { created_at, reason, content } = row;
|
|
42
|
-
return (<tr>
|
|
43
|
-
<td>{ created_at }</td>
|
|
44
|
-
<td>{ reason }</td>
|
|
45
|
-
<td><em>{ content }</em></td>
|
|
46
|
-
<td style={{ textAlign: 'right' }}><Button
|
|
47
|
-
onClick={onClick}
|
|
48
|
-
color="secondary"
|
|
49
|
-
icon={<FontAwesomeIcon icon={faCheck} />}
|
|
50
|
-
label={formatMessage({ id: `${pluginId}.popup.reports.item.button` })}
|
|
51
|
-
/></td>
|
|
52
|
-
</tr>);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const AbuseReportsPopUp = ({ isOpen, reports, comment, blocked, blockedThread, onBlockClick, onBlockThreadClick, onClose, onAbuseReportResolveClick }) => {
|
|
56
|
-
|
|
57
|
-
const { formatMessage } = useGlobalContext();
|
|
58
|
-
|
|
59
|
-
const resolveReportReason = reason => formatMessage({ id: `${pluginId}.popup.reports.item.reason.${reason.toLowerCase()}`});
|
|
60
|
-
|
|
61
|
-
const headers = [
|
|
62
|
-
{
|
|
63
|
-
name: formatMessage({ id: `${pluginId}.popup.reports.item.header.date` }),
|
|
64
|
-
value: 'created_at',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: formatMessage({ id: `${pluginId}.popup.reports.item.header.reason` }),
|
|
68
|
-
value: 'reason',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: formatMessage({ id: `${pluginId}.popup.reports.item.header.message` }),
|
|
72
|
-
value: 'content',
|
|
73
|
-
},
|
|
74
|
-
{ value: 'actions' }
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
const rows = reports.map(({ id, created_at, content, reason }) => ({
|
|
78
|
-
id,
|
|
79
|
-
created_at: moment(created_at).format('DD/MM/YYYY, HH:mm'),
|
|
80
|
-
reason: resolveReportReason(reason),
|
|
81
|
-
content,
|
|
82
|
-
}));
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<CheckPermissions permissions={pluginPermissions.moderateReports}>
|
|
86
|
-
<Modal isOpen={isOpen} onToggle={onClose}>
|
|
87
|
-
<HeaderModal>
|
|
88
|
-
<section>
|
|
89
|
-
<HeaderModalTitle>
|
|
90
|
-
<FormattedMessage id={`${pluginId}.popup.reports.header`} />
|
|
91
|
-
</HeaderModalTitle>
|
|
92
|
-
</section>
|
|
93
|
-
</HeaderModal>
|
|
94
|
-
<ModalForm>
|
|
95
|
-
<ModalBody>
|
|
96
|
-
<section style={{ width: '100%' }}>
|
|
97
|
-
<ItemPreviewContainer>
|
|
98
|
-
<ItemDetails root={true} {...comment} />
|
|
99
|
-
</ItemPreviewContainer>
|
|
100
|
-
{ isEmpty(reports) && (
|
|
101
|
-
<EmptyView>
|
|
102
|
-
<FontAwesomeIcon icon={faSmile} size="5x" />
|
|
103
|
-
<FormattedMessage id={`${pluginId}.popup.reports.empty`} />
|
|
104
|
-
</EmptyView>
|
|
105
|
-
) }
|
|
106
|
-
{ !isEmpty(reports) && (<TableContainer>
|
|
107
|
-
<Table
|
|
108
|
-
customRow={props => (<CustomRow {...props} formatMessage={formatMessage} onClick={(e) => onAbuseReportResolveClick(e, props.row.id)} />)}
|
|
109
|
-
headers={headers}
|
|
110
|
-
rows={rows}
|
|
111
|
-
/>
|
|
112
|
-
</TableContainer>)}
|
|
113
|
-
</section>
|
|
114
|
-
</ModalBody>
|
|
115
|
-
</ModalForm>
|
|
116
|
-
{ !isEmpty(reports) && !blockedThread && !blocked && (<ModalFooter>
|
|
117
|
-
<section>
|
|
118
|
-
<label>
|
|
119
|
-
<FormattedMessage id={`${pluginId}.popup.reports.footer.actions`} />
|
|
120
|
-
</label>
|
|
121
|
-
{ !blockedThread && (<ButtonModal
|
|
122
|
-
onClick={e => onBlockClick(comment.id)}
|
|
123
|
-
isSecondary
|
|
124
|
-
message={`${pluginId}.list.item.moderation.button.comment.hide`} />)}
|
|
125
|
-
<ButtonModal
|
|
126
|
-
onClick={e => onBlockThreadClick(comment.id)}
|
|
127
|
-
isSecondary
|
|
128
|
-
message={`${pluginId}.list.item.moderation.button.thread.hide`} />
|
|
129
|
-
</section>
|
|
130
|
-
</ModalFooter>)}
|
|
131
|
-
</Modal>
|
|
132
|
-
</CheckPermissions>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
AbuseReportsPopUp.propTypes = {
|
|
137
|
-
blocked: PropTypes.bool,
|
|
138
|
-
blockedThread: PropTypes.bool,
|
|
139
|
-
reports: PropTypes.array,
|
|
140
|
-
comment: PropTypes.object.isRequired,
|
|
141
|
-
onBlockClick: PropTypes.func.isRequired,
|
|
142
|
-
onBlockThreadClick: PropTypes.func.isRequired,
|
|
143
|
-
onAbuseReportResolveClick: PropTypes.func.isRequired,
|
|
144
|
-
isOpen: PropTypes.bool,
|
|
145
|
-
onClose: PropTypes.func.isRequired,
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export default AbuseReportsPopUp;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const EmptyView = styled.div`
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-grow: 1;
|
|
8
|
-
flex-direction: column;
|
|
9
|
-
align-items: center;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
padding-left: 2rem;
|
|
12
|
-
padding-right: 2rem;
|
|
13
|
-
padding-bottom: ${props => props.fixPosition ? '8rem' : 0};
|
|
14
|
-
|
|
15
|
-
font-size: 2rem;
|
|
16
|
-
font-weight: 600;
|
|
17
|
-
color: ${colors.leftMenu.grey};
|
|
18
|
-
text-align: center;
|
|
19
|
-
|
|
20
|
-
svg {
|
|
21
|
-
margin-bottom: 1rem;
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
export default EmptyView;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import { FormattedMessage } from 'react-intl';
|
|
3
|
-
import { Collapse } from 'reactstrap';
|
|
4
|
-
import { Select } from '@buffetjs/core';
|
|
5
|
-
import { map, noop, startCase } from 'lodash';
|
|
6
|
-
|
|
7
|
-
import { FilterButton, getFilterType } from 'strapi-helper-plugin';
|
|
8
|
-
|
|
9
|
-
import { AddFilterCta, Container, FilterIcon, FiltersWrapper, InputWrapper, styles, Wrapper } from './index.styled';
|
|
10
|
-
import useDataManager from '../../hooks/useDataManager';
|
|
11
|
-
import { isEntityFilter, isMatch } from './utils';
|
|
12
|
-
|
|
13
|
-
const allowedAttributes = ['Related to'];
|
|
14
|
-
|
|
15
|
-
const Filters = ({
|
|
16
|
-
contentsTypes,
|
|
17
|
-
isLoadingContentsTypes,
|
|
18
|
-
isOpenFilter,
|
|
19
|
-
onToggleOpen,
|
|
20
|
-
onRemoveFilter,
|
|
21
|
-
onChangeFilter,
|
|
22
|
-
filters,
|
|
23
|
-
isLoadingEntries,
|
|
24
|
-
availableEntriesMap,
|
|
25
|
-
}) => {
|
|
26
|
-
const filtersOptions = getFilterType();
|
|
27
|
-
const { search } = useDataManager();
|
|
28
|
-
|
|
29
|
-
const searchFilters = useMemo(
|
|
30
|
-
() => (search.filters.reduce(
|
|
31
|
-
(acc, current) => ({ ...acc, [current.name]: { ...current, contentType: filters?.related?.value } }),
|
|
32
|
-
{})
|
|
33
|
-
),
|
|
34
|
-
[search.filters],
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const contentsTypesOptions = useMemo(
|
|
38
|
-
() => [{ key: '', value: '' }, ...(contentsTypes || []).map(_ => ({ ..._, key: startCase(_.key) }))],
|
|
39
|
-
[contentsTypes],
|
|
40
|
-
);
|
|
41
|
-
const availableEntriesOptions = useMemo(
|
|
42
|
-
() => [{ key: '', value: '' }, ...(availableEntriesMap[filters?.related?.value] || [])],
|
|
43
|
-
[availableEntriesMap],
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
if (isLoadingContentsTypes) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
return (
|
|
50
|
-
<>
|
|
51
|
-
<Collapse isOpen={isOpenFilter}>
|
|
52
|
-
<Container>
|
|
53
|
-
<form>
|
|
54
|
-
<Wrapper>
|
|
55
|
-
<FiltersWrapper borderLeft={filters.related.value}>
|
|
56
|
-
<InputWrapper>
|
|
57
|
-
<Select
|
|
58
|
-
disabled
|
|
59
|
-
options={allowedAttributes}
|
|
60
|
-
onChange={noop}
|
|
61
|
-
name='name'
|
|
62
|
-
value={filters.related.name}
|
|
63
|
-
style={styles.select}
|
|
64
|
-
/>
|
|
65
|
-
<Select
|
|
66
|
-
disabled
|
|
67
|
-
name='filter'
|
|
68
|
-
onChange={noop}
|
|
69
|
-
value={filters.related.filter}
|
|
70
|
-
options={
|
|
71
|
-
filtersOptions.map(({ id, value }) => (
|
|
72
|
-
<FormattedMessage key={id} id={id}>
|
|
73
|
-
{msg => <option value={value}>{msg}</option>}
|
|
74
|
-
</FormattedMessage>
|
|
75
|
-
))
|
|
76
|
-
}
|
|
77
|
-
style={styles.selectMiddle}
|
|
78
|
-
/>
|
|
79
|
-
<Select
|
|
80
|
-
name="related-value"
|
|
81
|
-
onChange={onChangeFilter}
|
|
82
|
-
value={filters.related.value}
|
|
83
|
-
options={
|
|
84
|
-
contentsTypesOptions
|
|
85
|
-
.map(({ key, value }) => (
|
|
86
|
-
<option key={value} value={value}>
|
|
87
|
-
{key}
|
|
88
|
-
</option>
|
|
89
|
-
))
|
|
90
|
-
}
|
|
91
|
-
style={styles.select}
|
|
92
|
-
/>
|
|
93
|
-
{
|
|
94
|
-
filters.related.value && !isLoadingEntries && (
|
|
95
|
-
<Select
|
|
96
|
-
name="entity-value"
|
|
97
|
-
options={
|
|
98
|
-
availableEntriesOptions.map(({ key, value }) => (
|
|
99
|
-
<option key={key} value={value}>
|
|
100
|
-
{key}
|
|
101
|
-
</option>
|
|
102
|
-
))
|
|
103
|
-
}
|
|
104
|
-
value={filters?.entity?.value}
|
|
105
|
-
onChange={onChangeFilter}
|
|
106
|
-
style={styles.select}
|
|
107
|
-
/>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
</InputWrapper>
|
|
111
|
-
</FiltersWrapper>
|
|
112
|
-
</Wrapper>
|
|
113
|
-
</form>
|
|
114
|
-
</Container>
|
|
115
|
-
</Collapse>
|
|
116
|
-
<div className="container-fluid">
|
|
117
|
-
<div className="row">
|
|
118
|
-
<AddFilterCta type="button" onClick={onToggleOpen}>
|
|
119
|
-
<FilterIcon />
|
|
120
|
-
<FormattedMessage id="app.utils.filters" />
|
|
121
|
-
</AddFilterCta>
|
|
122
|
-
{
|
|
123
|
-
!isLoadingEntries && map(
|
|
124
|
-
searchFilters,
|
|
125
|
-
(filter) => {
|
|
126
|
-
if (!filter.value) {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
const label = {
|
|
130
|
-
...filter,
|
|
131
|
-
value: (isEntityFilter(filter.name)
|
|
132
|
-
? availableEntriesMap[filter.contentType] || []
|
|
133
|
-
: contentsTypesOptions).find(isMatch(filter.value))?.key,
|
|
134
|
-
};
|
|
135
|
-
return (
|
|
136
|
-
<FilterButton
|
|
137
|
-
key={filter.name}
|
|
138
|
-
onClick={onRemoveFilter(filter)}
|
|
139
|
-
label={label}
|
|
140
|
-
type="string"
|
|
141
|
-
/>
|
|
142
|
-
);
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
</div>
|
|
146
|
-
</div>
|
|
147
|
-
</>
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export default Filters;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { Button, FilterIcon as Filter } from 'strapi-helper-plugin';
|
|
3
|
-
|
|
4
|
-
export const FilterIcon = styled(Filter)`
|
|
5
|
-
padding: 0 !important;
|
|
6
|
-
margin: auto !important;
|
|
7
|
-
> g {
|
|
8
|
-
stroke: #282b2c;
|
|
9
|
-
}
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
export const AddFilterCta = styled(Button)`
|
|
13
|
-
display: flex;
|
|
14
|
-
height: 30px;
|
|
15
|
-
margin-right: 10px;
|
|
16
|
-
padding: 0 10px;
|
|
17
|
-
text-align: center;
|
|
18
|
-
background-color: #ffffff;
|
|
19
|
-
border: 1px solid #e3e9f3;
|
|
20
|
-
border-radius: 2px;
|
|
21
|
-
line-height: 28px;
|
|
22
|
-
font-size: 13px;
|
|
23
|
-
font-weight: 500;
|
|
24
|
-
font-family: Lato;
|
|
25
|
-
-webkit-font-smoothing: antialiased;
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
&:hover {
|
|
28
|
-
background: #f7f8f8;
|
|
29
|
-
}
|
|
30
|
-
&:focus,
|
|
31
|
-
&:active {
|
|
32
|
-
outline: 0;
|
|
33
|
-
}
|
|
34
|
-
> span {
|
|
35
|
-
margin-left: 10px;
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
export const Container = styled.div`
|
|
40
|
-
padding: 18px 30px 18px 0;
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
export const Wrapper = styled.div`
|
|
44
|
-
margin-top: -6px;
|
|
45
|
-
> div {
|
|
46
|
-
padding-top: 2px;
|
|
47
|
-
&:not(:first-of-type) {
|
|
48
|
-
padding-top: 9px;
|
|
49
|
-
padding-bottom: 2px;
|
|
50
|
-
&:last-of-type:nth-of-type(even) {
|
|
51
|
-
padding-bottom: 11px;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
export const FiltersWrapper = styled.div`
|
|
58
|
-
min-height: 38px;
|
|
59
|
-
border-left: ${props => props.borderLeft && '3px solid #007EFF'};
|
|
60
|
-
padding-left: ${props => (props.borderLeft ? '10px' : '13px')};
|
|
61
|
-
margin-bottom: 0 !important;
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
|
-
export const InputWrapper = styled.div`
|
|
65
|
-
display: flex;
|
|
66
|
-
input,
|
|
67
|
-
select {
|
|
68
|
-
margin: 0px 5px !important;
|
|
69
|
-
}
|
|
70
|
-
`;
|
|
71
|
-
export const styles = {
|
|
72
|
-
select: {
|
|
73
|
-
minWidth: '170px',
|
|
74
|
-
maxWidth: '200px',
|
|
75
|
-
},
|
|
76
|
-
selectMiddle: {
|
|
77
|
-
minWidth: '130px',
|
|
78
|
-
maxWidth: '200px',
|
|
79
|
-
marginLeft: '10px',
|
|
80
|
-
marginRight: '10px',
|
|
81
|
-
},
|
|
82
|
-
};
|