strapi-plugin-comments 1.0.4 → 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 (144) hide show
  1. package/.circleci/config.yml +2 -2
  2. package/README.md +47 -125
  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 +58 -0
  6. package/admin/src/components/DiscussionThreadItem/index.js +87 -0
  7. package/admin/src/components/DiscussionThreadItem/styles.js +87 -0
  8. package/admin/src/components/DiscussionThreadItemActions/index.js +176 -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 +137 -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 +45 -0
  20. package/admin/src/components/ReportsReviewTable/index.js +142 -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/index.js +56 -42
  25. package/admin/src/pages/App/index.js +32 -0
  26. package/admin/src/pages/ComingSoonPage/index.js +25 -0
  27. package/admin/src/pages/Details/index.js +109 -0
  28. package/admin/src/pages/Details/utils/api.js +41 -0
  29. package/admin/src/pages/Discover/index.js +185 -0
  30. package/admin/src/pages/Discover/utils/api.js +23 -0
  31. package/admin/src/pages/Discover/utils/filtersSchema.js +9 -0
  32. package/admin/src/permissions.js +13 -37
  33. package/admin/src/pluginId.js +2 -4
  34. package/admin/src/translations/en.json +72 -37
  35. package/admin/src/translations/fr.json +1 -0
  36. package/admin/src/utils/axiosInstance.js +35 -0
  37. package/admin/src/utils/constants.js +25 -6
  38. package/admin/src/utils/getApiUrl.js +5 -0
  39. package/admin/src/utils/getMessage.js +14 -0
  40. package/admin/src/utils/getRelatedGroups.js +5 -0
  41. package/admin/src/utils/getUrl.js +5 -0
  42. package/admin/src/utils/handleAPIError.js +15 -0
  43. package/admin/src/utils/index.js +6 -0
  44. package/codecov.yml +2 -1
  45. package/content-types/comment.js +97 -0
  46. package/content-types/index.js +11 -0
  47. package/content-types/report.js +54 -0
  48. package/package.json +11 -25
  49. package/server/bootstrap.js +5 -0
  50. package/server/config/index.js +6 -0
  51. package/server/controllers/admin.js +150 -0
  52. package/server/controllers/client.js +109 -0
  53. package/server/controllers/index.js +9 -0
  54. package/{controllers → server/controllers}/utils/__tests__/functions.test.js +0 -0
  55. package/{controllers → server/controllers}/utils/functions.js +1 -1
  56. package/server/destroy.js +5 -0
  57. package/server/index.js +22 -0
  58. package/server/register.js +5 -0
  59. package/server/routes/admin.js +92 -0
  60. package/server/routes/client.js +52 -0
  61. package/server/routes/index.js +15 -0
  62. package/server/services/admin.js +180 -0
  63. package/server/services/client.js +227 -0
  64. package/server/services/common.js +191 -0
  65. package/server/services/index.js +11 -0
  66. package/{services → server/services}/utils/__tests__/functions.test.js +0 -0
  67. package/{services → server/services}/utils/functions.js +17 -6
  68. package/server/utils/constants.js +16 -0
  69. package/{services → server}/utils/error.js +0 -0
  70. package/server/utils/functions.js +19 -0
  71. package/strapi-admin.js +3 -0
  72. package/strapi-server.js +9 -0
  73. package/admin/src/assets/images/icon-cross-blue.svg +0 -1
  74. package/admin/src/assets/images/icon_remove.svg +0 -19
  75. package/admin/src/assets/images/logo.svg +0 -5
  76. package/admin/src/components/AbuseReportsPopUp/ItemPreviewContainer.js +0 -8
  77. package/admin/src/components/AbuseReportsPopUp/ModalFooter.js +0 -31
  78. package/admin/src/components/AbuseReportsPopUp/TableContainer.js +0 -63
  79. package/admin/src/components/AbuseReportsPopUp/index.js +0 -148
  80. package/admin/src/components/Container/index.js +0 -7
  81. package/admin/src/components/EmptyView/index.js +0 -25
  82. package/admin/src/components/Filters/index.js +0 -151
  83. package/admin/src/components/Filters/index.styled.js +0 -82
  84. package/admin/src/components/Filters/utils.js +0 -21
  85. package/admin/src/components/Item/CardItem.js +0 -30
  86. package/admin/src/components/Item/CardWrapper.js +0 -10
  87. package/admin/src/components/Item/index.js +0 -107
  88. package/admin/src/components/ItemDetails/CardItem.js +0 -33
  89. package/admin/src/components/ItemDetails/CardLevelCounter.js +0 -46
  90. package/admin/src/components/ItemDetails/CardLevelCounterLink.js +0 -24
  91. package/admin/src/components/ItemDetails/CardLevelWrapper.js +0 -22
  92. package/admin/src/components/ItemDetails/CardWrapper.js +0 -52
  93. package/admin/src/components/ItemDetails/index.js +0 -167
  94. package/admin/src/components/ItemFooter/CardItemAuthor.js +0 -10
  95. package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
  96. package/admin/src/components/ItemFooter/Wrapper.js +0 -20
  97. package/admin/src/components/ItemFooter/index.js +0 -87
  98. package/admin/src/components/ItemHeader/CardHeaderBlocked.js +0 -24
  99. package/admin/src/components/ItemHeader/CardHeaderIndicator.js +0 -30
  100. package/admin/src/components/ItemHeader/CardHeaderIndicatorBlue.js +0 -11
  101. package/admin/src/components/ItemHeader/CardHeaderIndicatorRed.js +0 -11
  102. package/admin/src/components/ItemHeader/CardHeaderIndicatorsContainer.js +0 -18
  103. package/admin/src/components/ItemHeader/CardHeaderPending.js +0 -11
  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 -97
  107. package/admin/src/components/ItemModeration/Wrapper.js +0 -19
  108. package/admin/src/components/ItemModeration/index.js +0 -84
  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 -15
  115. package/admin/src/containers/DataManagerProvider/index.js +0 -332
  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 -106
  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 -62
  136. package/config/routes.json +0 -142
  137. package/config/schema.graphql.js +0 -268
  138. package/controllers/comments.js +0 -228
  139. package/models/comment.js +0 -8
  140. package/models/comment.settings.json +0 -102
  141. package/models/report.js +0 -8
  142. package/models/report.settings.json +0 -49
  143. package/services/comments.js +0 -539
  144. package/services/utils/constants.js +0 -9
@@ -0,0 +1,176 @@
1
+ /**
2
+ *
3
+ * Entity Details
4
+ *
5
+ */
6
+
7
+ import React, { useState, useEffect } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { useMutation, useQueryClient } from 'react-query';
10
+ import { isNil } from 'lodash';
11
+ import { Button } from '@strapi/design-system/Button';
12
+ import { Flex } from '@strapi/design-system/Flex';
13
+ import { IconButton } from '@strapi/design-system/IconButton';
14
+ import { Lock, Check, Cross, Key } from '@strapi/icons';
15
+ import { useNotification, useOverlayBlocker } from '@strapi/helper-plugin';
16
+ import { getMessage, handleAPIError } from '../../utils';
17
+ import { DiscussionThreadItemActionsBadge, DiscussionThreadItemActionsGroupWrapper, DiscussionThreadItemActionsWrapper } from './styles';
18
+ import ConfirmationDialog from '../ConfirmationDialog';
19
+ import { blockItem, blockItemThread, unblockItem, unblockItemThread } from '../../pages/Details/utils/api';
20
+
21
+ const DiscussionThreadItemActions = ({ id, blocked, blockedThread, approvalStatus, root }) => {
22
+
23
+ const [blockConfirmationVisible, setBlockConfirmationVisible] = useState(false);
24
+ const [blockThreadConfirmationVisible, setBlockThreadConfirmationVisible] = useState(false);
25
+
26
+ const toggleNotification = useNotification();
27
+ const queryClient = useQueryClient();
28
+ const { lockApp, unlockApp } = useOverlayBlocker();
29
+
30
+ const onSuccess = (message, stateAction = () => {}) => async () => {
31
+ await queryClient.invalidateQueries('get-details-data');
32
+ toggleNotification({
33
+ type: 'success',
34
+ message,
35
+ });
36
+ stateAction(false);
37
+ unlockApp();
38
+ };
39
+
40
+ const onError = err => { handleAPIError(err, toggleNotification); };
41
+
42
+ const blockItemMutation = useMutation(blockItem, {
43
+ onSuccess: onSuccess(
44
+ 'page.details.actions.comment.block.confirmation.success',
45
+ setBlockConfirmationVisible
46
+ ),
47
+ onError,
48
+ refetchActive: false,
49
+ });
50
+ const unblockItemMutation = useMutation(unblockItem, {
51
+ onSuccess: onSuccess('page.details.actions.comment.unblock.confirmation.success'),
52
+ onError,
53
+ refetchActive: false,
54
+ });
55
+ const blockItemThreadMutation = useMutation(blockItemThread, {
56
+ onSuccess: onSuccess(
57
+ 'page.details.actions.thread.block.confirmation.success',
58
+ setBlockThreadConfirmationVisible
59
+ ),
60
+ onError,
61
+ refetchActive: false,
62
+ });
63
+ const unblockItemThreadMutation = useMutation(unblockItemThread, {
64
+ onSuccess: onSuccess('page.details.actions.thread.unblock.confirmation.success'),
65
+ onError,
66
+ refetchActive: false,
67
+ });
68
+
69
+ const gotApprovalFlow = !isNil(approvalStatus);
70
+ const needsApproval = gotApprovalFlow && (approvalStatus === 'PENDING');
71
+ const isBlocked = blocked || blockedThread;
72
+
73
+ const resolveStatusBadge = () => {
74
+ let color = 'primary';
75
+ let label = '';
76
+
77
+ if (isBlocked) {
78
+ color = 'danger';
79
+ label = 'blocked';
80
+ } else if (gotApprovalFlow) {
81
+ label = approvalStatus.toLowerCase();
82
+ switch (approvalStatus) {
83
+ case 'APPROVED':
84
+ color = 'success';
85
+ break;
86
+ case 'REJECTED':
87
+ color = 'danger';
88
+ break;
89
+ default:
90
+ color = 'alternative';
91
+ break;
92
+ };
93
+ }
94
+
95
+ return {
96
+ badgeVisible: isBlocked || gotApprovalFlow,
97
+ badgeColor: color,
98
+ badgeLabel: label,
99
+ }
100
+ }
101
+
102
+ const {badgeVisible, badgeColor, badgeLabel } = resolveStatusBadge();
103
+
104
+ const handleBlockClick = () => setBlockConfirmationVisible(true);
105
+ const handleBlockConfirm = async () => {
106
+ lockApp();
107
+ blockItemMutation.mutate(id);
108
+ };
109
+ const handleBlockCancel = () => {
110
+ setBlockConfirmationVisible(false);
111
+ };
112
+ const handleUnblockClick = async () => {
113
+ lockApp();
114
+ unblockItemMutation.mutate(id);
115
+ };
116
+
117
+ const handleBlockThreadClick = () => setBlockThreadConfirmationVisible(true);
118
+ const handleBlockThreadConfirm = async () => {
119
+ lockApp();
120
+ blockItemThreadMutation.mutate(id);
121
+ };
122
+ const handleBlockThreadCancel = () => {
123
+ setBlockThreadConfirmationVisible(false);
124
+ };
125
+ const handleUnblockThreadClick = async () => {
126
+ lockApp();
127
+ unblockItemThreadMutation.mutate(id);
128
+ };
129
+
130
+ return (<>
131
+ <DiscussionThreadItemActionsWrapper as={Flex} direction="row">
132
+ { badgeVisible && (<DiscussionThreadItemActionsBadge color={badgeColor} backgroundColor={`${badgeColor}100`} textColor={`${badgeColor}600`}>{getMessage(`page.details.panel.discussion.status.${badgeLabel}`, badgeLabel)}</DiscussionThreadItemActionsBadge>)}
133
+ { !blockedThread && !(blocked || needsApproval) && (<IconButton onClick={handleBlockClick} loading={blockItemMutation.isLoading} icon={<Lock />} label={getMessage('page.details.actions.comment.block', 'Block')} />)}
134
+ { !blockedThread && blocked && (<IconButton onClick={handleUnblockClick} loading={unblockItemMutation.isLoading} icon={<Key />} label={getMessage('page.details.actions.comment.unblock', 'Unblock')} />)}
135
+ { (!blockedThread && root) && (<Button onClick={handleBlockThreadClick} startIcon={<Lock />} loading={blockItemThreadMutation.isLoading} variant="danger">{ getMessage('page.details.actions.thread.block', 'Block thread') }</Button>) }
136
+ { (blockedThread && root) && (<Button onClick={handleUnblockThreadClick} startIcon={<Key />} loading={unblockItemThreadMutation.isLoading} variant="success">{ getMessage('page.details.actions.thread.unblock', 'Unblock thread') }</Button>) }
137
+ { needsApproval && (<DiscussionThreadItemActionsGroupWrapper>
138
+ <IconButton icon={<Check />} label={getMessage('page.details.actions.comment.approve', 'Approve')} />
139
+ <IconButton icon={<Cross />} label={getMessage('page.details.actions.comment.reject', 'Reject')} />
140
+ </DiscussionThreadItemActionsGroupWrapper>) }
141
+ </DiscussionThreadItemActionsWrapper>
142
+ { !blocked && (<ConfirmationDialog
143
+ isVisible={blockConfirmationVisible}
144
+ isActionAsync={blockItemMutation.isLoading}
145
+ header={getMessage('page.details.actions.comment.block.confirmation.header')}
146
+ labelConfirm={getMessage('page.details.actions.comment.block.confirmation.button.confirm')}
147
+ iconConfirm={<Lock />}
148
+ onConfirm={handleBlockConfirm}
149
+ onCancel={handleBlockCancel}>
150
+ { getMessage('page.details.actions.comment.block.confirmation.description') }
151
+ </ConfirmationDialog>) }
152
+ { (!blockedThread && root) && (<ConfirmationDialog
153
+ isVisible={blockThreadConfirmationVisible}
154
+ isActionAsync={blockItemThreadMutation.isLoading}
155
+ header={getMessage('page.details.actions.thread.block.confirmation.header')}
156
+ labelConfirm={getMessage('page.details.actions.thread.block.confirmation.button.confirm')}
157
+ iconConfirm={<Lock />}
158
+ onConfirm={handleBlockThreadConfirm}
159
+ onCancel={handleBlockThreadCancel}>
160
+ { getMessage('page.details.actions.thread.block.confirmation.description') }
161
+ </ConfirmationDialog>) }
162
+ </>);
163
+ };
164
+
165
+ DiscussionThreadItemActions.propTypes = {
166
+ isRoot: PropTypes.bool,
167
+ blocked: PropTypes.bool.isRequired,
168
+ blockedThread: PropTypes.bool.isRequired,
169
+ approvalStatus: PropTypes.oneOfType([PropTypes.nullable, PropTypes.oneOf(['PENDING', 'APPROVED', 'REJECTED'])]),
170
+ onBlockClick: PropTypes.func.isRequired,
171
+ onUnBlockClick: PropTypes.func.isRequired,
172
+ onApprovalGroupClick: PropTypes.func.isRequired,
173
+ };
174
+
175
+ export default DiscussionThreadItemActions;
176
+
@@ -0,0 +1,22 @@
1
+ import styled from 'styled-components';
2
+ import { Box } from '@strapi/design-system/Box';
3
+ import { Badge } from '@strapi/design-system/Badge';
4
+ import { IconButtonGroup } from '@strapi/design-system/IconButton';
5
+
6
+ export const DiscussionThreadItemActionsBadge = styled(Badge)`
7
+ border: 1px ${ ({ theme, color }) => theme.colors[`${color}200`] } solid;
8
+ `;
9
+
10
+ export const DiscussionThreadItemActionsWrapper = styled(Box)`
11
+ margin-left: 1rem;
12
+ align-items: start;
13
+
14
+ ${DiscussionThreadItemActionsBadge} {
15
+ margin-top: .175rem;
16
+ margin-right: .5rem;
17
+ }
18
+ `;
19
+
20
+ export const DiscussionThreadItemActionsGroupWrapper = styled(IconButtonGroup)`
21
+ margin-left: .5rem;
22
+ `;
@@ -0,0 +1,31 @@
1
+ /**
2
+ *
3
+ * Entity Details
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { useIntl } from 'react-intl';
10
+ import { Box } from '@strapi/design-system/Box';
11
+ import { Flex } from '@strapi/design-system/Flex';
12
+ import { Typography } from '@strapi/design-system/Typography';
13
+
14
+ const DiscussionThreadItemMeta = ({ authorName, authorEmail, createdAt, updatedAt }) => {
15
+
16
+ const { formatDate } = useIntl();
17
+
18
+ const dateTime = formatDate(updatedAt || createdAt, { dateStyle: 'short', timeStyle: 'short' });
19
+
20
+ return (<Flex as={Box} paddingTop={2} direction="row" justifyContent="space-between">
21
+ <Typography variant="pi" fontWeight="bold">{ authorName }</Typography>
22
+ <Typography variant="pi">{ dateTime }</Typography>
23
+ </Flex>);
24
+ };
25
+
26
+ DiscussionThreadItemMeta.propTypes = {
27
+
28
+ };
29
+
30
+ export default DiscussionThreadItemMeta;
31
+
@@ -0,0 +1,137 @@
1
+ /**
2
+ *
3
+ * Entity Details
4
+ *
5
+ */
6
+
7
+ import React, { useState } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { useMutation, useQueryClient } from 'react-query';
10
+ import { isEmpty, orderBy } from 'lodash';
11
+ import { Badge } from '@strapi/design-system/Badge';
12
+ import { Box } from '@strapi/design-system/Box';
13
+ import { Button } from '@strapi/design-system/Button';
14
+ import { Divider } from '@strapi/design-system/Divider';
15
+ import { Flex } from '@strapi/design-system/Flex';
16
+ import { Typography } from '@strapi/design-system/Typography';
17
+ import { ArrowRight, Lock } from '@strapi/icons';
18
+ import { useNotification, useOverlayBlocker } from '@strapi/helper-plugin';
19
+ import { getMessage, handleAPIError } from '../../utils';
20
+ import { blockItem, blockItemThread, resolveReport } from '../../pages/Details/utils/api';
21
+ import { DiscussionThreadItemWarningsWrapper } from './styles';
22
+ import ReportsReviewModal from '../ReportsReviewModal';
23
+ import ReportsReviewTable from '../ReportsReviewTable';
24
+
25
+ const DiscussionThreadItemWarnings = (item) => {
26
+ const { id, reports } = item;
27
+
28
+ const [reportsReviewVisible, setReportsReviewVisible] = useState(false);
29
+
30
+ const toggleNotification = useNotification();
31
+ const queryClient = useQueryClient();
32
+ const { lockApp, unlockApp } = useOverlayBlocker();
33
+
34
+ const onSuccess = (message, stateAction = () => {}, indalidate = true) => async () => {
35
+ if (indalidate) {
36
+ await queryClient.invalidateQueries('get-details-data');
37
+ }
38
+ toggleNotification({
39
+ type: 'success',
40
+ message,
41
+ });
42
+ stateAction(false);
43
+ unlockApp();
44
+ };
45
+
46
+ const onError = err => { handleAPIError(err, toggleNotification); };
47
+
48
+ const resolveReportMutation = useMutation(resolveReport, {
49
+ onSuccess: onSuccess('page.details.panel.discussion.warnings.reports.dialog.confirmation.success', () => {}, false),
50
+ onError,
51
+ refetchActive: false,
52
+ });
53
+
54
+ const blockItemMutation = useMutation(blockItem, {
55
+ onSuccess: onSuccess(
56
+ 'page.details.actions.comment.block.confirmation.success',
57
+ setReportsReviewVisible
58
+ ),
59
+ onError,
60
+ refetchActive: false,
61
+ });
62
+ const blockItemThreadMutation = useMutation(blockItemThread, {
63
+ onSuccess: onSuccess(
64
+ 'page.details.actions.thread.block.confirmation.success',
65
+ setReportsReviewVisible
66
+ ),
67
+ onError,
68
+ refetchActive: false,
69
+ });
70
+
71
+ const handleReportsReviewClick = () => setReportsReviewVisible(true);
72
+ const handleBlockItemClick = async () => {
73
+ lockApp();
74
+ blockItemMutation.mutate(id);
75
+ };
76
+ const handleBlockItemThreadClick = async () => {
77
+ lockApp();
78
+ blockItemThreadMutation.mutate(id);
79
+ };
80
+ const handleReportsReviewClose = async () => {
81
+ await queryClient.invalidateQueries('get-details-data')
82
+ setReportsReviewVisible(false);
83
+ };
84
+
85
+ const isLoading = blockItemMutation.isLoading || blockItemThreadMutation.isLoading || resolveReportMutation.isLoading;
86
+ const openReports = reports?.filter(_ => !_.resolved);
87
+
88
+ if (isEmpty(reports) || isEmpty(openReports)) {
89
+ return null;
90
+ }
91
+
92
+ return (<>
93
+ <DiscussionThreadItemWarningsWrapper as={Flex} direction="row" padding={2} background="danger100" borderColor="danger200" border={1} hasRadius>
94
+ <Box as={Flex} paddingRight={2} direction="row" grow={1}>
95
+ <Badge textColor="neutral0" backgroundColor="warning600">{ openReports.length }</Badge>
96
+ <Box paddingLeft={2}>
97
+ <Typography textColor="warning600" fontWeight="bold">{getMessage(`page.details.panel.discussion.warnings.reports.description`, 'abuse reports')}</Typography>
98
+ </Box>
99
+ </Box>
100
+ <Button onClick={handleReportsReviewClick} variant="ghost" endIcon={<ArrowRight />}>
101
+ { getMessage(`page.details.actions.comment.report.review`, 'review') }
102
+ </Button>
103
+ </DiscussionThreadItemWarningsWrapper>
104
+ <ReportsReviewModal
105
+ isVisible={reportsReviewVisible}
106
+ isActionAsync={isLoading}
107
+ onClose={handleReportsReviewClose}
108
+ startActions={<>
109
+ <Button onClick={handleBlockItemClick} variant="danger-light" startIcon={<Lock />}>
110
+ { getMessage(`page.details.actions.comment.block`, 'Block comment') }
111
+ </Button>
112
+ <Button onClick={handleBlockItemThreadClick} variant="danger" startIcon={<Lock />}>
113
+ { getMessage(`page.details.actions.thread.block`, 'Block thread') }
114
+ </Button>
115
+ </>}
116
+ item={item}>
117
+ <Typography variant="sigma" textColor="neutral600" id="reports-list">
118
+ { getMessage('page.details.panel.discussion.warnings.reports.list', 'List') }
119
+ </Typography>
120
+ <Box paddingTop={2} paddingBottom={6}>
121
+ <Divider />
122
+ </Box>
123
+ <ReportsReviewTable
124
+ commentId={item.id}
125
+ items={orderBy(reports, ['resolved', 'createdAt'], ['DESC', 'DESC'])}
126
+ mutation={resolveReportMutation}
127
+ />
128
+ </ReportsReviewModal>
129
+ </>);
130
+ };
131
+
132
+ DiscussionThreadItemWarnings.propTypes = {
133
+
134
+ };
135
+
136
+ export default DiscussionThreadItemWarnings;
137
+
@@ -0,0 +1,7 @@
1
+ import styled from 'styled-components';
2
+ import { Box } from '@strapi/design-system/Box';
3
+
4
+ export const DiscussionThreadItemWarningsWrapper = styled(Box)`
5
+ width: 100%;
6
+ margin-top: .5rem;
7
+ `;
@@ -0,0 +1,53 @@
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
+
@@ -8,19 +8,19 @@ import { useEffect, useRef } from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import pluginId from '../../pluginId';
10
10
 
11
- const Initializer = ({ updatePlugin }) => {
11
+ const Initializer = ({ setPlugin }) => {
12
12
  const ref = useRef();
13
- ref.current = updatePlugin;
13
+ ref.current = setPlugin;
14
14
 
15
15
  useEffect(() => {
16
- ref.current(pluginId, 'isReady', true);
16
+ ref.current(pluginId);
17
17
  }, []);
18
18
 
19
19
  return null;
20
20
  };
21
21
 
22
22
  Initializer.propTypes = {
23
- updatePlugin: PropTypes.func.isRequired,
23
+ setPlugin: PropTypes.func.isRequired,
24
24
  };
25
25
 
26
26
  export default Initializer;
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * Entity Details
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ import { LoadingIndicatorPage } from '@strapi/helper-plugin';
9
+ import { LoadingIndicatorOverlayWrapper } from './styles';
10
+
11
+ const LoadingIndicatorOverlay = () => (<LoadingIndicatorOverlayWrapper>
12
+ <LoadingIndicatorPage />
13
+ </LoadingIndicatorOverlayWrapper>);
14
+
15
+ export default LoadingIndicatorOverlay;
@@ -0,0 +1,20 @@
1
+ import styled from 'styled-components';
2
+ import { Box } from '@strapi/design-system/Box';
3
+
4
+ export const LoadingIndicatorOverlayWrapper = styled(Box)`
5
+ height: 100% !important;
6
+ position: absolute;
7
+ top: 0;
8
+ left: 0;
9
+ width: 100%;
10
+ background: rgba(255,255,255,.7);
11
+ z-index: 1;
12
+
13
+ &>div {
14
+ height: 100% !important;
15
+ }
16
+ `;
17
+
18
+ export const LoadingIndicatorContainer = styled((props) => props.as)`
19
+ position: relative;
20
+ `
@@ -0,0 +1,45 @@
1
+ /*
2
+ *
3
+ * Nav
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ import {
9
+ SubNav,
10
+ SubNavHeader,
11
+ SubNavSection,
12
+ SubNavSections,
13
+ SubNavLink,
14
+ } from '@strapi/design-system/SubNav';
15
+ import { ExclamationMarkCircle, Apps } from '@strapi/icons';
16
+ import getMessage from '../../utils/getMessage';
17
+
18
+ // import PropTypes from 'prop-types';
19
+ import getUrl from '../../utils/getUrl';
20
+
21
+ const Nav = ({ hasNewComments, hasNewReports }) => {
22
+ return <SubNav ariaLabel="Comments sub nav">
23
+ <SubNavHeader label={getMessage('plugin.name')} />
24
+ <SubNavSections>
25
+ <SubNavLink to={ getUrl('dashboard') } withBullet={hasNewComments} icon={<Apps />}>
26
+ { getMessage('nav.item.updates') }
27
+ </SubNavLink>
28
+ <SubNavSection label={getMessage('nav.header.moderation')}>
29
+ <SubNavLink to={ getUrl('discover') } icon={<Apps />}>
30
+ { getMessage('nav.item.discover') }
31
+ </SubNavLink>
32
+ <SubNavLink to={ getUrl('reports') } withBullet={hasNewReports} icon={<Apps />}>
33
+ { getMessage('nav.item.reports') }
34
+ </SubNavLink>
35
+ </SubNavSection>
36
+ <SubNavSection label={getMessage('nav.header.settings')}>
37
+ <SubNavLink to={ getUrl('settings') } icon={<Apps />}>
38
+ { getMessage('nav.item.settings') }
39
+ </SubNavLink>
40
+ </SubNavSection>
41
+ </SubNavSections>
42
+ </SubNav>;
43
+ }
44
+
45
+ export default Nav;
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * PluginIcon
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ import CommentsIcon from "../icons/comments"
9
+
10
+ const PluginIcon = () => <CommentsIcon />;
11
+
12
+ export default PluginIcon;
@@ -0,0 +1,45 @@
1
+ /**
2
+ *
3
+ * Entity Details
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { ModalLayout, ModalBody, ModalHeader, ModalFooter } from '@strapi/design-system/ModalLayout';
10
+ import { Typography } from '@strapi/design-system/Typography';
11
+ import { getMessage } from '../../utils';
12
+ import DiscussionThreadItem from '../DiscussionThreadItem';
13
+
14
+ const ReportsReviewModal = ({
15
+ isVisible = false,
16
+ isActionAsync = false,
17
+ item,
18
+ children,
19
+ onClose,
20
+ startActions,
21
+ endActions,
22
+ }) => ( isVisible &&
23
+ (<ModalLayout onClose={onClose}>
24
+ <ModalHeader>
25
+ <Typography fontWeight="bold" textColor="neutral800" as="h2" id="title">{ getMessage('page.details.panel.discussion.warnings.reports.dialog.header', 'Open reports') }</Typography>
26
+ </ModalHeader>
27
+ <ModalBody>
28
+ <DiscussionThreadItem {...item} root preview isSelected={false} />
29
+ { children }
30
+ </ModalBody>
31
+ <ModalFooter variant="tertiary" startActions={startActions} endActions={endActions} />
32
+ </ModalLayout>)
33
+ );
34
+
35
+ ReportsReviewModal.propTypes = {
36
+ isVisible: PropTypes.bool,
37
+ isActionAsync: PropTypes.bool,
38
+ startActions: PropTypes.array,
39
+ endActions: PropTypes.array,
40
+ item: PropTypes.object.isRequired,
41
+ children: PropTypes.array.isRequired,
42
+ onClose: PropTypes.func.isRequired,
43
+ };
44
+
45
+ export default ReportsReviewModal;