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
@@ -1,332 +0,0 @@
1
- import React, { memo, useCallback, useEffect, useReducer, useRef } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { get } from 'lodash';
4
- import {
5
- request,
6
- storeData,
7
- LoadingIndicatorPage,
8
- useGlobalContext,
9
- generateFiltersFromSearch,
10
- generateSearchFromFilters,
11
- generateSearchFromObject,
12
- getQueryParameters,
13
- } from 'strapi-helper-plugin';
14
- import { useHistory, useLocation, useRouteMatch } from 'react-router-dom';
15
- import moment from 'moment';
16
- import DataManagerContext from '../../contexts/DataManagerContext';
17
- import Container from '../../components/Container';
18
- import Search from '../../components/Search';
19
- import getTrad from '../../utils/getTrad';
20
- import pluginId from '../../pluginId';
21
- import init from './init';
22
- import reducer, { initialState } from './reducer';
23
- import {
24
- BLOCK_COMMENT,
25
- BLOCK_COMMENT_SUCCESS,
26
- BLOCK_COMMENT_THREAD,
27
- BLOCK_COMMENT_THREAD_SUCCESS,
28
- GET_DATA,
29
- GET_DATA_SUCCEEDED,
30
- GET_SINGLE_DATA,
31
- GET_SINGLE_DATA_SUCCEEDED,
32
- RESOLVE_ABUSE_REPORT,
33
- RESOLVE_ABUSE_REPORT_SUCCESS,
34
- APPROVE_COMMENT,
35
- APPROVE_COMMENT_SUCCESS,
36
- REJECT_COMMENT,
37
- REJECT_COMMENT_SUCCESS,
38
- } from './actions';
39
-
40
- const RECENTLY_VIEVEW_KEY = `${pluginId}-recently-viewed`;
41
-
42
- const getCurrent = async (dispatch, searchParams = {}, recentlyViewed = undefined) => {
43
- try {
44
- const generatedSearch = generateSearchFromObject(searchParams);
45
- dispatch({
46
- type: GET_DATA,
47
- });
48
- const result = await request(`/${pluginId}/moderation/all?${generatedSearch}`, {
49
- method: 'GET',
50
- });
51
- const { items, total: itemsTotal } = result;
52
-
53
- dispatch({
54
- type: GET_DATA_SUCCEEDED,
55
- items,
56
- itemsTotal,
57
- recentlyViewed,
58
- });
59
- } catch (err) {
60
- console.error({ err });
61
- strapi.notification.error('notification.error');
62
- }
63
- };
64
-
65
- const getDetails = async (dispatch, activeId) => {
66
- try {
67
- if (activeId) {
68
- dispatch({
69
- type: GET_SINGLE_DATA,
70
- });
71
-
72
- const activeItem = await request(`/${pluginId}/moderation/single/${activeId}`, {
73
- method: 'GET',
74
- });
75
-
76
- dispatch({
77
- type: GET_SINGLE_DATA_SUCCEEDED,
78
- activeItem,
79
- });
80
- }
81
- } catch (err) {
82
- console.error({ err });
83
- strapi.notification.error('notification.error');
84
- }
85
- };
86
-
87
- const DataManagerProvider = ({ children }) => {
88
- const [reducerState, dispatch] = useReducer(reducer, initialState, init);
89
- const {
90
- autoReload,
91
- currentEnvironment,
92
- emitEvent,
93
- formatMessage,
94
- } = useGlobalContext();
95
- const {
96
- items,
97
- itemsTotal,
98
- activeItem,
99
- isLoading,
100
- isLoadingForDetailsDataToBeSet,
101
- initialData,
102
- } = reducerState.toJS();
103
- const { pathname, search } = useLocation();
104
- const { push } = useHistory();
105
-
106
- const formatMessageRef = useRef();
107
- formatMessageRef.current = formatMessage;
108
-
109
- const isInDevelopmentMode = currentEnvironment === 'development' && autoReload;
110
-
111
- const detailsViewMatch = useRouteMatch(`/plugins/${pluginId}/display/:id`);
112
- const activeId = get(detailsViewMatch, 'params.id', null);
113
-
114
- useEffect(() => {
115
- getCurrent(dispatch, getSearchParams(), moment(storeData.get(RECENTLY_VIEVEW_KEY) || undefined));
116
- storeData.set(RECENTLY_VIEVEW_KEY, moment().toString());
117
- }, [search, dispatch]);
118
-
119
- useEffect(() => {
120
- // We need to set the modifiedData after the data has been retrieved
121
- // and also on pathname change
122
- if (!isLoading) {
123
- getDetails(dispatch, activeId);
124
- }
125
- // eslint-disable-next-line react-hooks/exhaustive-deps
126
- }, [isLoading, pathname, dispatch, activeId]);
127
-
128
- useEffect(() => {
129
- if (currentEnvironment === 'development' && !autoReload) {
130
- strapi.notification.info(
131
- formatMessageRef.current({
132
- id: getTrad('notification.info.autoreaload-disable'),
133
- }),
134
- );
135
- }
136
- }, [autoReload, currentEnvironment]);
137
-
138
- const blockComment = async (id) => {
139
- try {
140
- emitEvent('willBlockComment');
141
- dispatch({ type: BLOCK_COMMENT });
142
-
143
- await request(`/${pluginId}/moderation/block/${id}`, {
144
- method: 'PUT',
145
- });
146
-
147
- getCurrent(dispatch, getSearchParams());
148
- getDetails(dispatch, activeId);
149
-
150
- emitEvent('didBlockComment');
151
- dispatch({ type: BLOCK_COMMENT_SUCCESS });
152
-
153
- strapi.notification.success(`${pluginId}.notification.comment.visibility`);
154
-
155
- } catch (err) {
156
- emitEvent('didNotBlockComment');
157
- console.error({ err: err.response });
158
- strapi.notification.error('notification.error');
159
- }
160
- };
161
-
162
- const blockCommentThread = async (id) => {
163
- try {
164
- emitEvent('willBlockCommentThread');
165
- dispatch({ type: BLOCK_COMMENT_THREAD });
166
-
167
- await request(`/${pluginId}/moderation/block-thread/${id}`, {
168
- method: 'PUT',
169
- });
170
-
171
- getCurrent(dispatch, getSearchParams());
172
- getDetails(dispatch, activeId);
173
-
174
- emitEvent('didBlockCommentThread');
175
- dispatch({ type: BLOCK_COMMENT_THREAD_SUCCESS });
176
-
177
- strapi.notification.success(`${pluginId}.notification.thread.visibility`);
178
-
179
- } catch (err) {
180
- emitEvent('didNotBlockCommentThread');
181
- console.error({ err: err.response });
182
- strapi.notification.error('notification.error');
183
- }
184
- };
185
-
186
- const resolveAbuseReport = async (id, commentId) => {
187
- try {
188
- emitEvent('willResolveAbuseReport');
189
- dispatch({ type: RESOLVE_ABUSE_REPORT });
190
-
191
- await request(`/${pluginId}/moderation/abuse-reports/${commentId}/resolve/${id}`, {
192
- method: 'PATCH',
193
- });
194
-
195
- getCurrent(dispatch, getSearchParams());
196
- getDetails(dispatch, activeId);
197
-
198
- emitEvent('didResolveAbuseReport');
199
- dispatch({ type: RESOLVE_ABUSE_REPORT_SUCCESS });
200
-
201
- strapi.notification.success(`${pluginId}.notification.abuse-report.resolution`);
202
-
203
- } catch (err) {
204
- emitEvent('didNotResolveAbuseReport');
205
- console.error({ err: err.response });
206
- strapi.notification.error('notification.error');
207
- }
208
- };
209
-
210
- const approveComment = async (id) => {
211
- try {
212
- dispatch({ type: APPROVE_COMMENT });
213
- emitEvent('willApprove');
214
-
215
- await request(`/${pluginId}/moderation/approve/${id}`, {
216
- method: 'PUT',
217
- });
218
-
219
- getCurrent(dispatch, getSearchParams());
220
- getDetails(dispatch, activeId);
221
-
222
- dispatch({ type: APPROVE_COMMENT_SUCCESS });
223
- emitEvent('didApprove');
224
-
225
- strapi.notification.success(`${pluginId}.notification.comment.approval`);
226
- } catch (err) {
227
- console.error({ err: err.response });
228
- strapi.notification.error('notification.error');
229
- emitEvent('didNotApprove');
230
- }
231
- };
232
-
233
- const rejectComment = async (id) => {
234
- try {
235
- dispatch({ type: REJECT_COMMENT });
236
- emitEvent('willReject');
237
-
238
- await request(`/${pluginId}/moderation/reject/${id}`, {
239
- method: 'PUT',
240
- });
241
-
242
- getCurrent(dispatch, getSearchParams());
243
- getDetails(dispatch, activeId);
244
-
245
- dispatch({ type: REJECT_COMMENT_SUCCESS });
246
- emitEvent('didReject');
247
-
248
- strapi.notification.success(`${pluginId}.notification.comment.approval`);
249
- } catch (err) {
250
- console.error({ err: err.response });
251
- strapi.notification.error('notification.error');
252
- emitEvent('didNotReject');
253
- }
254
- };
255
-
256
- const getSearchParams = useCallback(
257
- (updatedParams = {}) => {
258
- return {
259
- _limit: getQueryParameters(search, '_limit') || 10,
260
- _page: getQueryParameters(search, '_page') || 1,
261
- _q: getQueryParameters(search, '_q') || '',
262
- filters: generateFiltersFromSearch(search),
263
- ...updatedParams,
264
- };
265
- },
266
- [search],
267
- );
268
-
269
- const handleChangeParams = ({ target: { name, value } }) => {
270
- const currentParams = getSearchParams();
271
- const updatedParams = {
272
- ...currentParams,
273
- [name]: value,
274
- };
275
- const updatedSearch = getSearchParams({
276
- ...updatedParams,
277
- _start: name === '_q' ? 0 : updatedParams._start,
278
- _page: name === '_q' ? 1 : updatedParams._page,
279
- });
280
- const newSearch = generateSearchFromFilters(updatedSearch);
281
-
282
- if (name === '_limit') {
283
- emitEvent('willChangeNumberOfEntriesPerPage');
284
- }
285
-
286
- push({ search: newSearch });
287
- };
288
-
289
- return (
290
- <DataManagerContext.Provider
291
- value={{
292
- items,
293
- itemsTotal,
294
- search: getSearchParams(),
295
- getSearchParams,
296
- activeItem,
297
- initialData,
298
- isLoading,
299
- isLoadingForDetailsDataToBeSet,
300
- blockComment,
301
- blockCommentThread,
302
- resolveAbuseReport,
303
- isInDevelopmentMode,
304
- handleChangeParams,
305
- approveComment,
306
- rejectComment,
307
- }}
308
- >
309
- {isLoading ? (
310
- <LoadingIndicatorPage />
311
- ) : (
312
- <>
313
- <Container>
314
- <Search
315
- changeParams={handleChangeParams}
316
- initValue={getQueryParameters(search, '_q') || ''}
317
- model="Comments"
318
- value={getQueryParameters(search, '_q') || ''}
319
- />
320
- </Container>
321
- {children}
322
- </>
323
- )}
324
- </DataManagerContext.Provider>
325
- );
326
- };
327
-
328
- DataManagerProvider.propTypes = {
329
- children: PropTypes.node.isRequired,
330
- };
331
-
332
- export default memo(DataManagerProvider);
@@ -1,5 +0,0 @@
1
- function init(initialState) {
2
- return initialState;
3
- }
4
-
5
- export default init;
@@ -1,59 +0,0 @@
1
- import { fromJS } from 'immutable';
2
- import moment from 'moment';
3
- import {
4
- BLOCK_COMMENT,
5
- BLOCK_COMMENT_THREAD,
6
- GET_DATA,
7
- GET_DATA_SUCCEEDED,
8
- GET_SINGLE_DATA,
9
- GET_SINGLE_DATA_SUCCEEDED,
10
- RELOAD_PLUGIN,
11
- } from './actions';
12
-
13
- const initialState = fromJS({
14
- items: [],
15
- itemsTotal: 0,
16
- activeItem: undefined,
17
- isLoading: true,
18
- isLoadingForDataToBeSet: false,
19
- isLoadingForDetailsDataToBeSet: false,
20
- });
21
-
22
- const reducer = (state, action) => {
23
- switch (action.type) {
24
- case GET_DATA: {
25
- return state
26
- .removeIn('items')
27
- .update('isLoadingForDataToBeSet', () => true);
28
- }
29
- case GET_DATA_SUCCEEDED: {
30
- return state
31
- .update('items', () => fromJS(action.items.map(_ => ({
32
- ..._,
33
- isNew: moment(_.created_at).diff(moment(action.recentlyViewed), 'seconds') > 0,
34
- }))))
35
- .update('itemsTotal', () => fromJS(action.itemsTotal))
36
- .update('isLoading', () => false)
37
- .update('isLoadingForDataToBeSet', () => false);
38
- }
39
- case GET_SINGLE_DATA:
40
- case BLOCK_COMMENT:
41
- case BLOCK_COMMENT_THREAD: {
42
- return state
43
- .removeIn('activeItem')
44
- .update('isLoadingForDetailsDataToBeSet', () => true);
45
- }
46
- case GET_SINGLE_DATA_SUCCEEDED: {
47
- return state
48
- .update('activeItem', () => fromJS(action.activeItem))
49
- .update('isLoadingForDetailsDataToBeSet', () => false);
50
- }
51
- case RELOAD_PLUGIN:
52
- return initialState;
53
- default:
54
- return state;
55
- }
56
- };
57
-
58
- export default reducer;
59
- export { initialState };
@@ -1,18 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- import { colors } from 'strapi-helper-plugin';
4
-
5
- const Wrapper = styled.div`
6
- display: flex;
7
- flex-direction: column;
8
- width: 100%;
9
- background-color: ${colors.leftMenu.mediumGrey};
10
- padding-top: 1.8rem;
11
- padding-left: 2rem;
12
- padding-right: 2rem;
13
-
14
- overflow-x: hidden;
15
- overflow-y: auto;
16
- `;
17
-
18
- export default Wrapper;
@@ -1,106 +0,0 @@
1
- /*
2
- *
3
- * DetailsView
4
- *
5
- */
6
-
7
- import React from 'react';
8
- import { useHistory } from 'react-router-dom';
9
- import { FormattedMessage } from 'react-intl';
10
- import { isNil } from 'lodash';
11
- import { useGlobalContext, LoadingIndicatorPage } from 'strapi-helper-plugin';
12
- import { Header } from '@buffetjs/custom';
13
-
14
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
15
- import { faComments } from '@fortawesome/free-solid-svg-icons';
16
-
17
- import Wrapper from './Wrapper';
18
- import ItemDetails from '../../components/ItemDetails';
19
- import CardWrapper from '../../components/ItemDetails/CardWrapper';
20
- import CardLevelWrapper from '../../components/ItemDetails/CardLevelWrapper';
21
- import EmptyView from '../../components/EmptyView';
22
-
23
- import pluginId from '../../pluginId';
24
- import getTradId from '../../utils/getTradId';
25
- import getTrad from '../../utils/getTrad';
26
-
27
- import useDataManager from '../../hooks/useDataManager';
28
-
29
- const DetailsView = () => {
30
- const {
31
- activeItem,
32
- isLoadingForDetailsDataToBeSet,
33
- blockComment,
34
- blockCommentThread,
35
- resolveAbuseReport,
36
- approveComment,
37
- rejectComment,
38
- } = useDataManager();
39
-
40
- const { formatMessage } = useGlobalContext();
41
- const { push } = useHistory();
42
-
43
- const onCommentClick = (e, id) => {
44
- e.preventDefault();
45
- e.stopPropagation();
46
- push(`/plugins/${pluginId}/display/${id}`)
47
- }
48
-
49
- const renderCommentsTree = (selected, items) => {
50
- return (<CardLevelWrapper>
51
- {
52
- items.map((item, n) => {
53
- const active = item.id === selected.id;
54
- const threadsCount = item.children && item.children.length;
55
- const hasThreads = threadsCount > 0;
56
- const clickable = !active && hasThreads && !isNil(selected.threadOf);
57
- return (<ItemDetails
58
- key={`list-item-details-${item.id || n}`}
59
- {...item}
60
- active={active}
61
- root={selected.threadOf === null}
62
- clickable={clickable}
63
- threadsCount={threadsCount}
64
- onAbuseReportResolve={resolveAbuseReport}
65
- onBlockClick={blockComment}
66
- onBlockThreadClick={blockCommentThread}
67
- onClick={e => onCommentClick(e, hasThreads ? item.children[0].id : item.id)}
68
- onApproveCommentClick={approveComment}
69
- onRejectCommentClick={rejectComment}
70
- />)
71
- })
72
- }
73
- </CardLevelWrapper>)
74
- }
75
-
76
- const { selected, level } = activeItem || {};
77
-
78
- return (
79
- <Wrapper className="col-md-8">
80
- {isLoadingForDetailsDataToBeSet && <LoadingIndicatorPage />}
81
- {!isLoadingForDetailsDataToBeSet && !activeItem && (<EmptyView fixPosition>
82
- <FontAwesomeIcon icon={faComments} size="5x" />
83
- <FormattedMessage id={getTrad('moderation.content.empty')} />
84
- </EmptyView>)}
85
- {activeItem && (<>
86
- {selected.threadOf && (<CardLevelWrapper>
87
- <ItemDetails
88
- {...selected.threadOf}
89
- clickable={true}
90
- root={true}
91
- onAbuseReportResolve={resolveAbuseReport}
92
- onClick={e => onCommentClick(e, selected.threadOf.id)}
93
- onApproveCommentClick={approveComment}
94
- onRejectCommentClick={rejectComment}
95
- />
96
- <CardWrapper root={true}>
97
- {renderCommentsTree(selected, level)}
98
- </CardWrapper>
99
- </CardLevelWrapper>)}
100
- {!selected.threadOf && renderCommentsTree(selected, level)}
101
- </>)}
102
- </Wrapper>
103
- );
104
- };
105
-
106
- export default DetailsView;
@@ -1,42 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- import { colors, sizes } from 'strapi-helper-plugin';
4
-
5
- const FadedWrapper = styled.div`
6
- display: flex;
7
- flex-direction: column;
8
- flex-grow: 1;
9
- padding: 0;
10
- margin: ${-2*sizes.margin}px;
11
-
12
- position: relative;
13
- z-index: 0;
14
-
15
- overflow: hidden;
16
-
17
- &:before,
18
- &:after {
19
- display: block;
20
- content: '';
21
- height: ${4*sizes.margin}px;
22
-
23
- position: absolute;
24
- left: 0;
25
- right: 0;
26
- z-index: 1;
27
-
28
- background: #ffffff;
29
- }
30
-
31
- &:before {
32
- top: 0;
33
- background: linear-gradient(180deg, rgba(250,250,251,1) 0%, rgba(250,250,251,0) 100%);
34
- }
35
-
36
- &:after {
37
- bottom: 0;
38
- background: linear-gradient(0deg, rgba(250,250,251,1) 0%, rgba(250,250,251,0) 100%);
39
- }
40
- `;
41
-
42
- export default FadedWrapper;
@@ -1,53 +0,0 @@
1
- import React, { memo } from 'react';
2
- import { FormattedMessage } from 'react-intl';
3
- import { GlobalPagination, InputSelect, sizes } from 'strapi-helper-plugin';
4
- import useDataManager from '../../hooks/useDataManager';
5
- import { FooterWrapper, SelectWrapper, Label } from './components';
6
-
7
- function Footer() {
8
- const {
9
- search: { _limit, _page },
10
- itemsTotal,
11
- handleChangeParams
12
- } = useDataManager();
13
-
14
- return (
15
- <FooterWrapper className="row">
16
- <div className="col-6">
17
- <SelectWrapper style={{ marginBottom: `${2*sizes.margin}px` }}>
18
- <InputSelect
19
- style={{ width: '75px', height: '32px', marginTop: '-1px' }}
20
- name="_limit"
21
- onChange={handleChangeParams}
22
- selectOptions={['10', '20', '50', '100']}
23
- value={_limit}
24
- />
25
- <Label htmlFor="_limit" style={{
26
- textOverflow: 'ellipsis',
27
- overflow: 'hidden',
28
- display: 'inline-block',
29
- whiteSpace: 'nowrap'
30
- }}>
31
- <FormattedMessage id="components.PageFooter.select" />
32
- </Label>
33
- </SelectWrapper>
34
- </div>
35
- <div className="col-6">
36
- <GlobalPagination
37
- style={{ marginBottom: `${2*sizes.margin}px` }}
38
- count={itemsTotal}
39
- onChangeParams={({ target: { value } }) => {
40
- handleChangeParams({ target: { name: '_page', value } });
41
- }}
42
- params={{
43
- currentPage: parseInt(_page, 10),
44
- _limit: parseInt(_limit, 10),
45
- _page: parseInt(_page, 10),
46
- }}
47
- />
48
- </div>
49
- </FooterWrapper>
50
- );
51
- }
52
-
53
- export default memo(Footer);
@@ -1,17 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- import { sizes } from 'strapi-helper-plugin';
4
-
5
- const Wrapper = styled.div`
6
- display: flex;
7
- flex-direction: column;
8
- width: 100%;
9
- height: calc(100vh - ${sizes.header.height} - 15rem);
10
- min-height: calc(100vh - ${sizes.header.height} - 15rem);
11
- max-height: calc(100vh - ${sizes.header.height});
12
- padding-top: 1.8rem;
13
- padding-left: 2rem;
14
- padding-right: 2rem;
15
- `;
16
-
17
- export default Wrapper;