strapi-plugin-comments 2.0.0-beta.2 → 2.0.0-beta.6
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/README.md +31 -5
- package/admin/src/components/DiscussionThread/index.js +10 -2
- package/admin/src/components/DiscussionThreadItem/index.js +25 -6
- package/admin/src/components/DiscussionThreadItem/styles.js +1 -0
- package/admin/src/components/DiscussionThreadItemActions/index.js +69 -56
- package/admin/src/components/DiscussionThreadItemActions/styles.js +0 -4
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +81 -0
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.js +6 -0
- package/admin/src/components/DiscussionThreadItemWarnings/index.js +26 -16
- package/admin/src/components/Nav/index.js +5 -1
- package/admin/src/components/ReportsReviewModal/index.js +5 -2
- package/admin/src/components/ReportsReviewTable/index.js +69 -57
- package/admin/src/components/icons/index.js +6 -0
- package/admin/src/components/icons/lock.js +22 -0
- package/admin/src/components/icons/review.js +18 -0
- package/admin/src/components/icons/unlock.js +20 -0
- package/admin/src/index.js +1 -1
- package/admin/src/pages/App/index.js +20 -9
- package/admin/src/pages/App/reducer/index.js +0 -1
- package/admin/src/pages/App/reducer/selectors.js +1 -1
- package/admin/src/pages/App/utils/api.js +2 -10
- package/admin/src/pages/Details/components/DetailsEntity/index.js +66 -0
- package/admin/src/pages/Details/components/DetailsFilters/index.js +37 -0
- package/admin/src/pages/Details/components/DetailsFilters/styles.js +8 -0
- package/admin/src/pages/Details/index.js +75 -42
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +210 -0
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.js +8 -0
- package/admin/src/pages/Discover/index.js +69 -102
- package/admin/src/pages/Discover/utils/api.js +2 -8
- package/admin/src/pages/{Details/utils → utils}/api.js +15 -3
- package/admin/src/permissions.js +10 -8
- package/admin/src/translations/en.json +17 -4
- package/admin/src/utils/constants.js +3 -6
- package/admin/src/utils/getMessage.js +10 -3
- package/admin/src/utils/getRelatedGroups.js +1 -3
- package/admin/src/utils/handleAPIError.js +1 -1
- package/admin/src/utils/index.js +4 -2
- package/admin/src/utils/renderEntryTitle.js +14 -0
- package/admin/src/utils/resolveCommentStatus.js +30 -0
- package/admin/src/utils/resolveCommentStatusColor.js +22 -0
- package/package.json +7 -3
- package/permissions.js +19 -0
- package/server/bootstrap.js +38 -2
- package/server/config/index.js +4 -3
- package/server/controllers/admin.js +3 -3
- package/server/controllers/client.js +11 -2
- package/server/services/admin.js +69 -13
- package/server/services/client.js +23 -15
- package/server/services/common.js +40 -69
- package/server/services/utils/functions.js +7 -14
- package/server/utils/constants.js +3 -3
- package/strapi-server.js +33 -0
- package/admin/src/components/EntityDetails/index.js +0 -53
|
@@ -34,9 +34,14 @@ 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
37
|
const { author } = data;
|
|
38
|
+
|
|
39
|
+
// Disallow approval status change by Client
|
|
40
|
+
if (data.approvalStatus && (existing.approvalStatus !== data.approvalStatus)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Make sure that author is exact the same
|
|
40
45
|
if (authorUser) {
|
|
41
46
|
const existingUserId = authorUser?.id || authorUser;
|
|
42
47
|
const receivedUserId = user?.id || author;
|
|
@@ -45,18 +50,6 @@ module.exports = {
|
|
|
45
50
|
return authorId === author?.id;
|
|
46
51
|
},
|
|
47
52
|
|
|
48
|
-
extractMeta: plugins => {
|
|
49
|
-
const { comments: plugin } = plugins;
|
|
50
|
-
const { comments: service } = plugin.services;
|
|
51
|
-
const { comment: model} = plugin.models;
|
|
52
|
-
return {
|
|
53
|
-
model,
|
|
54
|
-
service,
|
|
55
|
-
plugin,
|
|
56
|
-
pluginName: plugin.package.strapi.name.toLowerCase()
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
|
|
60
53
|
getRelatedGroups: related => related.split(REGEX.relatedUid).filter(s => s && s.length > 0),
|
|
61
54
|
|
|
62
55
|
getModelUid: name => {
|
|
@@ -5,9 +5,9 @@ const APPROVAL_STATUS = {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
const REGEX = {
|
|
8
|
-
uid:
|
|
9
|
-
relatedUid:
|
|
10
|
-
email:
|
|
8
|
+
uid: /^(?<type>[a-z0-9-]+)\:{2}(?<api>[a-z0-9-]+)\.{1}(?<contentType>[a-z0-9-]+)$/i,
|
|
9
|
+
relatedUid: /^(?<uid>[a-z0-9-]+\:{2}[a-z0-9-]+\.[a-z0-9-]+)\:{1}(?<id>[a-z0-9-]+)$/i,
|
|
10
|
+
email: /\S+@\S+\.\S+/,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
module.exports = {
|
package/strapi-server.js
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { isArray, isEmpty, isString } = require('lodash');
|
|
4
|
+
|
|
3
5
|
const server = require('./server');
|
|
4
6
|
const contentTypes = require('./content-types');
|
|
7
|
+
const { REGEX } = require('./server/utils/constants');
|
|
5
8
|
|
|
6
9
|
module.exports = () => ({
|
|
7
10
|
...server,
|
|
8
11
|
contentTypes,
|
|
12
|
+
config: {
|
|
13
|
+
...server.config,
|
|
14
|
+
default: ({ env }) => ({
|
|
15
|
+
...server.config.default,
|
|
16
|
+
}),
|
|
17
|
+
validator: (config) => {
|
|
18
|
+
// Check moderatorRoles values
|
|
19
|
+
const moderatorRolesValid = config.moderatorRoles
|
|
20
|
+
.filter(_ => !isString(_)).length === 0;
|
|
21
|
+
if (!moderatorRolesValid) {
|
|
22
|
+
throw new Error(`'moderatorRoles' must roles keys`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Check approvalFlow values
|
|
26
|
+
const approvalFlowValid = config.approvalFlow
|
|
27
|
+
.filter(_ => !REGEX.uid.test(_)).length === 0;
|
|
28
|
+
if (!approvalFlowValid) {
|
|
29
|
+
throw new Error(`'approvalFlow' must contain Content Types identifiers in the format like 'api::<collection name>.<content type name>'`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Check entryLabel keys and values
|
|
33
|
+
const entryLabelKeysValid = Object.keys(config.entryLabel)
|
|
34
|
+
.filter(_ => _ !== '*')
|
|
35
|
+
.filter(_ => !(REGEX.uid.test(_) && isArray(config.entryLabel[_]) && !isEmpty(config.entryLabel[_]))).length === 0;
|
|
36
|
+
|
|
37
|
+
if (!entryLabelKeysValid) {
|
|
38
|
+
throw new Error(`'entryLabel' must contain records in the format like 'api::<collection name>.<content type name>': ['Field1', 'field_2']`);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
},
|
|
9
42
|
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* Entity Details
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import PropTypes from 'prop-types';
|
|
9
|
-
import { isNil } from 'lodash';
|
|
10
|
-
import { Box } from '@strapi/design-system/Box';
|
|
11
|
-
import { Divider } from '@strapi/design-system/Divider';
|
|
12
|
-
import { Flex } from '@strapi/design-system/Flex';
|
|
13
|
-
import { Stack } from '@strapi/design-system/Stack';
|
|
14
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
15
|
-
import { getMessage } from '../../utils';
|
|
16
|
-
|
|
17
|
-
const EntityDetails = ({ data = {}, schema = {} }) => {
|
|
18
|
-
const { attributes = {} } = schema;
|
|
19
|
-
const keys = Object.keys(attributes);
|
|
20
|
-
|
|
21
|
-
if (keys.length === 0) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const itemKeys = keys.filter(_ => (attributes[_].type === 'string') && !isNil(data[_]));
|
|
26
|
-
|
|
27
|
-
return (<Box padding={4}>
|
|
28
|
-
<Typography variant="sigma" textColor="neutral600" id="entity-details">
|
|
29
|
-
{ getMessage('page.details.panel.entity', 'Details') }
|
|
30
|
-
</Typography>
|
|
31
|
-
<Box paddingTop={2} paddingBottom={6}>
|
|
32
|
-
<Divider />
|
|
33
|
-
</Box>
|
|
34
|
-
<Stack size={itemKeys.length}>
|
|
35
|
-
{ itemKeys.map(_ =>
|
|
36
|
-
(<Flex justifyContent="space-between">
|
|
37
|
-
<Typography fontWeight="bold">
|
|
38
|
-
{ _ }
|
|
39
|
-
</Typography>
|
|
40
|
-
<Typography>{ data[_] }</Typography>
|
|
41
|
-
</Flex>))
|
|
42
|
-
}
|
|
43
|
-
</Stack>
|
|
44
|
-
</Box>);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
EntityDetails.propTypes = {
|
|
48
|
-
data: PropTypes.object.isRequired,
|
|
49
|
-
schema: PropTypes.object.isRequired,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default EntityDetails;
|
|
53
|
-
|