strapi-plugin-comments 1.0.2 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +2 -2
- package/README.md +70 -109
- 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 +59 -0
- package/admin/src/components/DiscussionThreadItem/index.js +87 -0
- package/admin/src/components/DiscussionThreadItem/styles.js +88 -0
- package/admin/src/components/DiscussionThreadItemActions/index.js +178 -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 +141 -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 +43 -0
- package/admin/src/components/ReportsReviewTable/index.js +146 -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/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 +58 -42
- package/admin/src/pages/App/index.js +71 -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 +26 -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 +12 -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/components/DiscoverTableRow/index.js +196 -0
- package/admin/src/pages/Discover/index.js +157 -0
- package/admin/src/pages/Discover/utils/api.js +14 -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 +73 -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 +21 -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 +117 -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 +215 -0
- package/server/services/client.js +227 -0
- package/server/services/common.js +197 -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,19 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { Button } from '@buffetjs/styles';
|
|
4
|
-
import { colors } from 'strapi-helper-plugin';
|
|
5
|
-
|
|
6
|
-
const Wrapper = styled.div`
|
|
7
|
-
display: flex;
|
|
8
|
-
margin-top: 1rem;
|
|
9
|
-
|
|
10
|
-
flex-wrap: wrap;
|
|
11
|
-
justify-items: center;
|
|
12
|
-
align-items: stretch;
|
|
13
|
-
|
|
14
|
-
${Button} {
|
|
15
|
-
margin-right: 1rem;
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
export default Wrapper;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { useGlobalContext, CheckPermissions } from 'strapi-helper-plugin';
|
|
4
|
-
import { Button } from '@buffetjs/core';
|
|
5
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
6
|
-
import { faComment, faCommentSlash, faComments } from '@fortawesome/free-solid-svg-icons';
|
|
7
|
-
import Wrapper from './Wrapper';
|
|
8
|
-
import pluginId from '../../pluginId';
|
|
9
|
-
import pluginPermissions from '../../permissions';
|
|
10
|
-
|
|
11
|
-
const ItemModeration = ({ id, blocked, blockedThread, onBlockClick, onBlockThreadClick }) => {
|
|
12
|
-
|
|
13
|
-
const { formatMessage } = useGlobalContext();
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<CheckPermissions permissions={pluginPermissions.moderate}>
|
|
17
|
-
<Wrapper>
|
|
18
|
-
{ !blockedThread && (
|
|
19
|
-
<CheckPermissions permissions={pluginPermissions.moderateComments}>
|
|
20
|
-
<Button
|
|
21
|
-
onClick={e => onBlockClick(id)}
|
|
22
|
-
color={blocked ? 'primary' : 'delete'}
|
|
23
|
-
icon={<FontAwesomeIcon icon={blocked ? faComment : faCommentSlash} />}
|
|
24
|
-
label={formatMessage({ id: `${pluginId}.list.item.moderation.button.comment.${blocked ? 'restore' : 'hide'}` })} />
|
|
25
|
-
</CheckPermissions>
|
|
26
|
-
)}
|
|
27
|
-
<CheckPermissions permissions={pluginPermissions.moderateThreads}>
|
|
28
|
-
<Button
|
|
29
|
-
onClick={e => onBlockThreadClick(id)}
|
|
30
|
-
color={blockedThread ? 'primary' : 'delete'}
|
|
31
|
-
icon={<FontAwesomeIcon icon={faComments} />}
|
|
32
|
-
label={formatMessage({ id: `${pluginId}.list.item.moderation.button.thread.${blockedThread ? 'restore' : 'hide'}` })} />
|
|
33
|
-
</CheckPermissions>
|
|
34
|
-
</Wrapper>
|
|
35
|
-
</CheckPermissions>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
ItemModeration.propTypes = {
|
|
40
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
41
|
-
blocked: PropTypes.bool,
|
|
42
|
-
blockedThread: PropTypes.bool,
|
|
43
|
-
onBlockClick: PropTypes.func.isRequired,
|
|
44
|
-
onBlockThreadClick: PropTypes.func.isRequired,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default ItemModeration;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors, sizes } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const Container = styled.ul`
|
|
6
|
-
display: flex;
|
|
7
|
-
padding: ${2*sizes.margin}px;
|
|
8
|
-
flex-direction: column;
|
|
9
|
-
flex-grow: 1;
|
|
10
|
-
margin: 0;
|
|
11
|
-
|
|
12
|
-
z-index: 0;
|
|
13
|
-
|
|
14
|
-
overflow-x: hidden;
|
|
15
|
-
overflow-y: auto;
|
|
16
|
-
|
|
17
|
-
list-style: none;
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
export default Container;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import Item from '../Item';
|
|
4
|
-
import Container from './Container';
|
|
5
|
-
|
|
6
|
-
const List = ({ items, relatedContentTypes }) => (
|
|
7
|
-
<Container>
|
|
8
|
-
{items.map((item, n) => (
|
|
9
|
-
<Item
|
|
10
|
-
key={`list-item-${item.id || n}`}
|
|
11
|
-
relatedContentTypes={relatedContentTypes}
|
|
12
|
-
{...item}
|
|
13
|
-
/>))}
|
|
14
|
-
</Container>
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
List.propTypes = {
|
|
18
|
-
items: PropTypes.array,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default List;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
*
|
|
3
|
-
* Search
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import React, { memo } from 'react';
|
|
8
|
-
import { isEmpty, upperFirst } from 'lodash';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
|
-
import { FormattedMessage } from 'react-intl';
|
|
11
|
-
import { HeaderSearch } from 'strapi-helper-plugin';
|
|
12
|
-
import getTrad from '../../utils/getTrad';
|
|
13
|
-
|
|
14
|
-
const WAIT = 400;
|
|
15
|
-
|
|
16
|
-
class Search extends React.Component {
|
|
17
|
-
state = { value: this.props.initValue };
|
|
18
|
-
|
|
19
|
-
timer = null;
|
|
20
|
-
|
|
21
|
-
componentDidUpdate(prevProps) {
|
|
22
|
-
const { model, value } = this.props;
|
|
23
|
-
|
|
24
|
-
if (prevProps.model !== model || (!isEmpty(prevProps.value) && isEmpty(value))) {
|
|
25
|
-
this.resetState();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
resetState = () => this.setState({ value: '' });
|
|
30
|
-
|
|
31
|
-
handleChange = ({ target }) => {
|
|
32
|
-
clearTimeout(this.timer);
|
|
33
|
-
this.setState({ value: target.value });
|
|
34
|
-
this.timer = setTimeout(() => this.triggerChange(target.value), WAIT);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
handleClick = () => {
|
|
38
|
-
this.setState({ value: '' });
|
|
39
|
-
this.triggerChange('');
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
triggerChange = value =>
|
|
43
|
-
this.props.changeParams({
|
|
44
|
-
target: {
|
|
45
|
-
name: '_q',
|
|
46
|
-
value,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
render() {
|
|
51
|
-
const { model } = this.props;
|
|
52
|
-
const { value } = this.state;
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<FormattedMessage id={getTrad('components.Search.placeholder')}>
|
|
56
|
-
{placeholder => (
|
|
57
|
-
<HeaderSearch
|
|
58
|
-
label={upperFirst(model)}
|
|
59
|
-
onChange={this.handleChange}
|
|
60
|
-
onClear={this.handleClick}
|
|
61
|
-
placeholder={placeholder}
|
|
62
|
-
value={value}
|
|
63
|
-
/>
|
|
64
|
-
)}
|
|
65
|
-
</FormattedMessage>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
Search.defaultProps = {
|
|
71
|
-
changeParams: () => {},
|
|
72
|
-
model: '',
|
|
73
|
-
value: '',
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
Search.propTypes = {
|
|
77
|
-
changeParams: PropTypes.func,
|
|
78
|
-
initValue: PropTypes.string.isRequired,
|
|
79
|
-
model: PropTypes.string,
|
|
80
|
-
value: PropTypes.string,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export default memo(Search);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { sizes } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const Wrapper = styled.div`
|
|
6
|
-
min-height: calc(100vh - ${sizes.header.height});
|
|
7
|
-
.centered {
|
|
8
|
-
position: fixed;
|
|
9
|
-
top: calc(50% - 13px);
|
|
10
|
-
right: calc(50% - 13px);
|
|
11
|
-
}
|
|
12
|
-
`;
|
|
13
|
-
|
|
14
|
-
export default Wrapper;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* This component is the skeleton around the actual pages, and should only
|
|
4
|
-
* contain code that should be seen on all pages. (e.g. navigation bar)
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, { Suspense, lazy }from 'react';
|
|
9
|
-
import { Switch, Route } from 'react-router-dom';
|
|
10
|
-
import { NotFound, LoadingIndicatorPage, CheckPagePermissions } from 'strapi-helper-plugin';
|
|
11
|
-
import Wrapper from './Wrapper';
|
|
12
|
-
// Utils
|
|
13
|
-
import pluginId from '../../pluginId';
|
|
14
|
-
import DataManagerProvider from '../DataManagerProvider';
|
|
15
|
-
import pluginPermissions from '../../permissions';
|
|
16
|
-
// Containers
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const Panel = lazy(() => import('../Panel'));
|
|
20
|
-
|
|
21
|
-
const App = () => {
|
|
22
|
-
return (
|
|
23
|
-
<CheckPagePermissions permissions={pluginPermissions.main}>
|
|
24
|
-
<Wrapper>
|
|
25
|
-
<DataManagerProvider>
|
|
26
|
-
<Suspense fallback={<LoadingIndicatorPage />}>
|
|
27
|
-
<Switch>
|
|
28
|
-
<Route
|
|
29
|
-
path={`/plugins/${pluginId}`}
|
|
30
|
-
component={Panel}
|
|
31
|
-
exact
|
|
32
|
-
/>
|
|
33
|
-
<Route
|
|
34
|
-
path={`/plugins/${pluginId}/display/:id`}
|
|
35
|
-
component={Panel}
|
|
36
|
-
exact
|
|
37
|
-
/>
|
|
38
|
-
<Route component={NotFound} />
|
|
39
|
-
</Switch>
|
|
40
|
-
</Suspense>
|
|
41
|
-
</DataManagerProvider>
|
|
42
|
-
</Wrapper>
|
|
43
|
-
</CheckPagePermissions>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default App;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const GET_DATA = 'GET_DATA';
|
|
2
|
-
export const GET_DATA_SUCCEEDED = 'GET_DATA_SUCCEEDED';
|
|
3
|
-
export const GET_SINGLE_DATA = 'GET_SINGLE_DATA';
|
|
4
|
-
export const BLOCK_COMMENT = 'BLOCK_COMMENT';
|
|
5
|
-
export const BLOCK_COMMENT_THREAD = 'BLOCK_COMMENT_THREAD';
|
|
6
|
-
export const GET_SINGLE_DATA_SUCCEEDED = 'GET_SINGLE_DATA_SUCCEEDED';
|
|
7
|
-
export const RELOAD_PLUGIN = 'RELOAD_PLUGIN';
|
|
8
|
-
export const BLOCK_COMMENT_SUCCESS = 'BLOCK_COMMENT_SUCCESS';
|
|
9
|
-
export const BLOCK_COMMENT_THREAD_SUCCESS = 'BLOCK_COMMENT_THREAD_SUCCESS';
|
|
10
|
-
export const RESOLVE_ABUSE_REPORT = 'RESOLVE_ABUSE_REPORT';
|
|
11
|
-
export const RESOLVE_ABUSE_REPORT_SUCCESS = 'RESOLVE_ABUSE_REPORT_SUCCESS';
|
|
@@ -1,280 +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
|
-
} from './actions';
|
|
35
|
-
|
|
36
|
-
const RECENTLY_VIEVEW_KEY = `${pluginId}-recently-viewed`;
|
|
37
|
-
|
|
38
|
-
const getCurrent = async (dispatch, searchParams = {}, recentlyViewed = undefined) => {
|
|
39
|
-
try {
|
|
40
|
-
const generatedSearch = generateSearchFromObject(searchParams);
|
|
41
|
-
dispatch({
|
|
42
|
-
type: GET_DATA,
|
|
43
|
-
});
|
|
44
|
-
const result = await request(`/${pluginId}/moderation/all?${generatedSearch}`, {
|
|
45
|
-
method: 'GET',
|
|
46
|
-
});
|
|
47
|
-
const { items, total: itemsTotal } = result;
|
|
48
|
-
|
|
49
|
-
dispatch({
|
|
50
|
-
type: GET_DATA_SUCCEEDED,
|
|
51
|
-
items,
|
|
52
|
-
itemsTotal,
|
|
53
|
-
recentlyViewed,
|
|
54
|
-
});
|
|
55
|
-
} catch (err) {
|
|
56
|
-
console.error({ err });
|
|
57
|
-
strapi.notification.error('notification.error');
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const getDetails = async (dispatch, activeId) => {
|
|
62
|
-
try {
|
|
63
|
-
if (activeId) {
|
|
64
|
-
dispatch({
|
|
65
|
-
type: GET_SINGLE_DATA,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const activeItem = await request(`/${pluginId}/moderation/single/${activeId}`, {
|
|
69
|
-
method: 'GET',
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
dispatch({
|
|
73
|
-
type: GET_SINGLE_DATA_SUCCEEDED,
|
|
74
|
-
activeItem,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
} catch (err) {
|
|
78
|
-
console.error({ err });
|
|
79
|
-
strapi.notification.error('notification.error');
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const DataManagerProvider = ({ children }) => {
|
|
84
|
-
const [reducerState, dispatch] = useReducer(reducer, initialState, init);
|
|
85
|
-
const {
|
|
86
|
-
autoReload,
|
|
87
|
-
currentEnvironment,
|
|
88
|
-
emitEvent,
|
|
89
|
-
formatMessage,
|
|
90
|
-
} = useGlobalContext();
|
|
91
|
-
const {
|
|
92
|
-
items,
|
|
93
|
-
itemsTotal,
|
|
94
|
-
activeItem,
|
|
95
|
-
isLoading,
|
|
96
|
-
isLoadingForDetailsDataToBeSet,
|
|
97
|
-
initialData,
|
|
98
|
-
} = reducerState.toJS();
|
|
99
|
-
const { pathname, search } = useLocation();
|
|
100
|
-
const { push } = useHistory();
|
|
101
|
-
|
|
102
|
-
const formatMessageRef = useRef();
|
|
103
|
-
formatMessageRef.current = formatMessage;
|
|
104
|
-
|
|
105
|
-
const isInDevelopmentMode = currentEnvironment === 'development' && autoReload;
|
|
106
|
-
|
|
107
|
-
const detailsViewMatch = useRouteMatch(`/plugins/${pluginId}/display/:id`);
|
|
108
|
-
const activeId = get(detailsViewMatch, 'params.id', null);
|
|
109
|
-
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
getCurrent(dispatch, getSearchParams(), moment(storeData.get(RECENTLY_VIEVEW_KEY) || undefined));
|
|
112
|
-
storeData.set(RECENTLY_VIEVEW_KEY, moment().toString());
|
|
113
|
-
}, [search, dispatch]);
|
|
114
|
-
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
// We need to set the modifiedData after the data has been retrieved
|
|
117
|
-
// and also on pathname change
|
|
118
|
-
if (!isLoading) {
|
|
119
|
-
getDetails(dispatch, activeId);
|
|
120
|
-
}
|
|
121
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
122
|
-
}, [isLoading, pathname, dispatch, activeId]);
|
|
123
|
-
|
|
124
|
-
useEffect(() => {
|
|
125
|
-
if (currentEnvironment === 'development' && !autoReload) {
|
|
126
|
-
strapi.notification.info(
|
|
127
|
-
formatMessageRef.current({
|
|
128
|
-
id: getTrad('notification.info.autoreaload-disable'),
|
|
129
|
-
}),
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
}, [autoReload, currentEnvironment]);
|
|
133
|
-
|
|
134
|
-
const blockComment = async (id) => {
|
|
135
|
-
try {
|
|
136
|
-
emitEvent('willBlockComment');
|
|
137
|
-
dispatch({ type: BLOCK_COMMENT });
|
|
138
|
-
|
|
139
|
-
await request(`/${pluginId}/moderation/block/${id}`, {
|
|
140
|
-
method: 'PUT',
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
getCurrent(dispatch, getSearchParams());
|
|
144
|
-
getDetails(dispatch, activeId);
|
|
145
|
-
|
|
146
|
-
emitEvent('didBlockComment');
|
|
147
|
-
dispatch({ type: BLOCK_COMMENT_SUCCESS });
|
|
148
|
-
|
|
149
|
-
strapi.notification.success(`${pluginId}.notification.comment.visibility`);
|
|
150
|
-
|
|
151
|
-
} catch (err) {
|
|
152
|
-
emitEvent('didNotBlockComment');
|
|
153
|
-
console.error({ err: err.response });
|
|
154
|
-
strapi.notification.error('notification.error');
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const blockCommentThread = async (id) => {
|
|
159
|
-
try {
|
|
160
|
-
emitEvent('willBlockCommentThread');
|
|
161
|
-
dispatch({ type: BLOCK_COMMENT_THREAD });
|
|
162
|
-
|
|
163
|
-
await request(`/${pluginId}/moderation/block-thread/${id}`, {
|
|
164
|
-
method: 'PUT',
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
getCurrent(dispatch, getSearchParams());
|
|
168
|
-
getDetails(dispatch, activeId);
|
|
169
|
-
|
|
170
|
-
emitEvent('didBlockCommentThread');
|
|
171
|
-
dispatch({ type: BLOCK_COMMENT_THREAD_SUCCESS });
|
|
172
|
-
|
|
173
|
-
strapi.notification.success(`${pluginId}.notification.thread.visibility`);
|
|
174
|
-
|
|
175
|
-
} catch (err) {
|
|
176
|
-
emitEvent('didNotBlockCommentThread');
|
|
177
|
-
console.error({ err: err.response });
|
|
178
|
-
strapi.notification.error('notification.error');
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const resolveAbuseReport = async (id, commentId) => {
|
|
183
|
-
try {
|
|
184
|
-
emitEvent('willResolveAbuseReport');
|
|
185
|
-
dispatch({ type: RESOLVE_ABUSE_REPORT });
|
|
186
|
-
|
|
187
|
-
await request(`/${pluginId}/moderation/abuse-reports/${commentId}/resolve/${id}`, {
|
|
188
|
-
method: 'PATCH',
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
getCurrent(dispatch, getSearchParams());
|
|
192
|
-
getDetails(dispatch, activeId);
|
|
193
|
-
|
|
194
|
-
emitEvent('didResolveAbuseReport');
|
|
195
|
-
dispatch({ type: RESOLVE_ABUSE_REPORT_SUCCESS });
|
|
196
|
-
|
|
197
|
-
strapi.notification.success(`${pluginId}.notification.abuse-report.resolution`);
|
|
198
|
-
|
|
199
|
-
} catch (err) {
|
|
200
|
-
emitEvent('didNotResolveAbuseReport');
|
|
201
|
-
console.error({ err: err.response });
|
|
202
|
-
strapi.notification.error('notification.error');
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const getSearchParams = useCallback(
|
|
207
|
-
(updatedParams = {}) => {
|
|
208
|
-
return {
|
|
209
|
-
_limit: getQueryParameters(search, '_limit') || 10,
|
|
210
|
-
_page: getQueryParameters(search, '_page') || 1,
|
|
211
|
-
_q: getQueryParameters(search, '_q') || '',
|
|
212
|
-
filters: generateFiltersFromSearch(search),
|
|
213
|
-
...updatedParams,
|
|
214
|
-
};
|
|
215
|
-
},
|
|
216
|
-
[search],
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
const handleChangeParams = ({ target: { name, value } }) => {
|
|
220
|
-
const currentParams = getSearchParams();
|
|
221
|
-
const updatedParams = {
|
|
222
|
-
...currentParams,
|
|
223
|
-
[name]: value,
|
|
224
|
-
};
|
|
225
|
-
const updatedSearch = getSearchParams({
|
|
226
|
-
...updatedParams,
|
|
227
|
-
_start: name === '_q' ? 0 : updatedParams._start,
|
|
228
|
-
_page: name === '_q' ? 1 : updatedParams._page,
|
|
229
|
-
});
|
|
230
|
-
const newSearch = generateSearchFromFilters(updatedSearch);
|
|
231
|
-
|
|
232
|
-
if (name === '_limit') {
|
|
233
|
-
emitEvent('willChangeNumberOfEntriesPerPage');
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
push({ search: newSearch });
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
return (
|
|
240
|
-
<DataManagerContext.Provider
|
|
241
|
-
value={{
|
|
242
|
-
items,
|
|
243
|
-
itemsTotal,
|
|
244
|
-
search: getSearchParams(),
|
|
245
|
-
getSearchParams,
|
|
246
|
-
activeItem,
|
|
247
|
-
initialData,
|
|
248
|
-
isLoading,
|
|
249
|
-
isLoadingForDetailsDataToBeSet,
|
|
250
|
-
blockComment,
|
|
251
|
-
blockCommentThread,
|
|
252
|
-
resolveAbuseReport,
|
|
253
|
-
isInDevelopmentMode,
|
|
254
|
-
handleChangeParams,
|
|
255
|
-
}}
|
|
256
|
-
>
|
|
257
|
-
{isLoading ? (
|
|
258
|
-
<LoadingIndicatorPage />
|
|
259
|
-
) : (
|
|
260
|
-
<>
|
|
261
|
-
<Container>
|
|
262
|
-
<Search
|
|
263
|
-
changeParams={handleChangeParams}
|
|
264
|
-
initValue={getQueryParameters(search, '_q') || ''}
|
|
265
|
-
model="Comments"
|
|
266
|
-
value={getQueryParameters(search, '_q') || ''}
|
|
267
|
-
/>
|
|
268
|
-
</Container>
|
|
269
|
-
{children}
|
|
270
|
-
</>
|
|
271
|
-
)}
|
|
272
|
-
</DataManagerContext.Provider>
|
|
273
|
-
);
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
DataManagerProvider.propTypes = {
|
|
277
|
-
children: PropTypes.node.isRequired,
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
export default memo(DataManagerProvider);
|
|
@@ -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;
|