strapi-plugin-comments 1.0.2-beta.1 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +2 -2
- package/README.md +71 -95
- package/admin/src/components/ConfirmationDialog/index.js +56 -0
- package/admin/src/components/DiscussionStatus/index.js +33 -0
- package/admin/src/components/DiscussionThread/index.js +58 -0
- package/admin/src/components/DiscussionThreadItem/index.js +87 -0
- package/admin/src/components/DiscussionThreadItem/styles.js +87 -0
- package/admin/src/components/DiscussionThreadItemActions/index.js +176 -0
- package/admin/src/components/DiscussionThreadItemActions/styles.js +22 -0
- package/admin/src/components/DiscussionThreadItemMeta/index.js +31 -0
- package/admin/src/components/DiscussionThreadItemWarnings/index.js +137 -0
- package/admin/src/components/DiscussionThreadItemWarnings/styles.js +7 -0
- package/admin/src/components/EntityDetails/index.js +53 -0
- package/admin/src/{containers → components}/Initializer/index.js +4 -4
- package/admin/src/components/LoadingIndicatorOverlay/index.js +15 -0
- package/admin/src/components/LoadingIndicatorOverlay/styles.js +20 -0
- package/admin/src/components/Nav/index.js +45 -0
- package/admin/src/components/PluginIcon/index.js +12 -0
- package/admin/src/components/ReportsReviewModal/index.js +45 -0
- package/admin/src/components/ReportsReviewTable/index.js +142 -0
- package/admin/src/components/TableFilters/index.js +53 -0
- package/admin/src/components/TablePagination/index.js +35 -0
- package/admin/src/components/icons/comments.js +9 -0
- package/admin/src/index.js +58 -42
- package/admin/src/pages/App/index.js +60 -0
- package/admin/src/pages/App/reducer/actions.js +8 -0
- package/admin/src/pages/App/reducer/constants.js +4 -0
- package/admin/src/pages/App/reducer/index.js +27 -0
- package/admin/src/pages/App/reducer/init.js +7 -0
- package/admin/src/pages/App/reducer/selectors.js +35 -0
- package/admin/src/pages/App/utils/api.js +20 -0
- package/admin/src/pages/ComingSoonPage/index.js +25 -0
- package/admin/src/pages/Details/index.js +109 -0
- package/admin/src/pages/Details/utils/api.js +41 -0
- package/admin/src/pages/Discover/index.js +203 -0
- package/admin/src/pages/Discover/utils/api.js +20 -0
- package/admin/src/pages/Discover/utils/filtersSchema.js +9 -0
- package/admin/src/permissions.js +13 -33
- package/admin/src/pluginId.js +2 -4
- package/admin/src/reducers.js +8 -0
- package/admin/src/translations/en.json +72 -33
- package/admin/src/translations/fr.json +1 -0
- package/admin/src/utils/axiosInstance.js +35 -0
- package/admin/src/utils/constants.js +28 -0
- package/admin/src/utils/getApiUrl.js +5 -0
- package/admin/src/utils/getMessage.js +14 -0
- package/admin/src/utils/getRelatedGroups.js +5 -0
- package/admin/src/utils/getUrl.js +5 -0
- package/admin/src/utils/handleAPIError.js +15 -0
- package/admin/src/utils/index.js +6 -0
- package/codecov.yml +2 -1
- package/content-types/comment.js +97 -0
- package/content-types/index.js +11 -0
- package/content-types/report.js +54 -0
- package/package.json +11 -25
- package/server/bootstrap.js +5 -0
- package/server/config/index.js +10 -0
- package/server/controllers/admin.js +134 -0
- package/server/controllers/client.js +109 -0
- package/server/controllers/index.js +9 -0
- package/{controllers → server/controllers}/utils/__tests__/functions.test.js +0 -0
- package/{controllers → server/controllers}/utils/functions.js +1 -1
- package/server/destroy.js +5 -0
- package/server/index.js +22 -0
- package/server/register.js +5 -0
- package/server/routes/admin.js +92 -0
- package/server/routes/client.js +52 -0
- package/server/routes/index.js +15 -0
- package/server/services/admin.js +186 -0
- package/server/services/client.js +227 -0
- package/server/services/common.js +191 -0
- package/server/services/index.js +11 -0
- package/{services → server/services}/utils/__tests__/functions.test.js +7 -9
- package/{services → server/services}/utils/functions.js +19 -8
- package/server/utils/constants.js +16 -0
- package/{services → server}/utils/error.js +0 -0
- package/server/utils/functions.js +19 -0
- package/strapi-admin.js +3 -0
- package/strapi-server.js +9 -0
- package/admin/src/assets/images/icon-cross-blue.svg +0 -1
- package/admin/src/assets/images/icon_remove.svg +0 -19
- package/admin/src/assets/images/logo.svg +0 -5
- package/admin/src/components/AbuseReportsPopUp/ItemPreviewContainer.js +0 -8
- package/admin/src/components/AbuseReportsPopUp/ModalFooter.js +0 -31
- package/admin/src/components/AbuseReportsPopUp/TableContainer.js +0 -63
- package/admin/src/components/AbuseReportsPopUp/index.js +0 -148
- package/admin/src/components/Container/index.js +0 -7
- package/admin/src/components/EmptyView/index.js +0 -25
- package/admin/src/components/Filters/index.js +0 -151
- package/admin/src/components/Filters/index.styled.js +0 -82
- package/admin/src/components/Filters/utils.js +0 -21
- package/admin/src/components/Item/CardItem.js +0 -30
- package/admin/src/components/Item/CardWrapper.js +0 -10
- package/admin/src/components/Item/index.js +0 -92
- package/admin/src/components/ItemDetails/CardItem.js +0 -33
- package/admin/src/components/ItemDetails/CardLevelCounter.js +0 -46
- package/admin/src/components/ItemDetails/CardLevelCounterLink.js +0 -24
- package/admin/src/components/ItemDetails/CardLevelWrapper.js +0 -22
- package/admin/src/components/ItemDetails/CardWrapper.js +0 -52
- package/admin/src/components/ItemDetails/index.js +0 -151
- package/admin/src/components/ItemFooter/CardItemAuthor.js +0 -10
- package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
- package/admin/src/components/ItemFooter/Wrapper.js +0 -20
- package/admin/src/components/ItemFooter/index.js +0 -87
- package/admin/src/components/ItemHeader/CardHeaderBlocked.js +0 -24
- package/admin/src/components/ItemHeader/CardHeaderIndicator.js +0 -30
- package/admin/src/components/ItemHeader/CardHeaderIndicatorBlue.js +0 -11
- package/admin/src/components/ItemHeader/CardHeaderIndicatorRed.js +0 -11
- package/admin/src/components/ItemHeader/CardHeaderIndicatorsContainer.js +0 -18
- package/admin/src/components/ItemHeader/CardHeaderReports.js +0 -40
- package/admin/src/components/ItemHeader/Wrapper.js +0 -16
- package/admin/src/components/ItemHeader/index.js +0 -80
- package/admin/src/components/ItemModeration/Wrapper.js +0 -19
- package/admin/src/components/ItemModeration/index.js +0 -47
- package/admin/src/components/List/Container.js +0 -20
- package/admin/src/components/List/index.js +0 -21
- package/admin/src/components/Search/index.js +0 -83
- package/admin/src/containers/App/Wrapper.js +0 -14
- package/admin/src/containers/App/index.js +0 -47
- package/admin/src/containers/DataManagerProvider/actions.js +0 -11
- package/admin/src/containers/DataManagerProvider/index.js +0 -280
- package/admin/src/containers/DataManagerProvider/init.js +0 -5
- package/admin/src/containers/DataManagerProvider/reducer.js +0 -59
- package/admin/src/containers/DetailsView/Wrapper.js +0 -18
- package/admin/src/containers/DetailsView/index.js +0 -100
- package/admin/src/containers/ListView/FadedWrapper.js +0 -42
- package/admin/src/containers/ListView/Footer.js +0 -53
- package/admin/src/containers/ListView/Wrapper.js +0 -17
- package/admin/src/containers/ListView/components.js +0 -138
- package/admin/src/containers/ListView/index.js +0 -45
- package/admin/src/containers/Panel/actions.js +0 -5
- package/admin/src/containers/Panel/index.js +0 -191
- package/admin/src/containers/Panel/index.styled.js +0 -6
- package/admin/src/containers/Panel/reducer.js +0 -44
- package/admin/src/contexts/DataManagerContext.js +0 -5
- package/admin/src/hooks/useDataManager.js +0 -6
- package/admin/src/lifecycles.js +0 -3
- package/admin/src/translations/index.js +0 -7
- package/admin/src/utils/getTrad.js +0 -5
- package/admin/src/utils/getTradId.js +0 -5
- package/config/functions/bootstrap.js +0 -48
- package/config/routes.json +0 -116
- package/config/schema.graphql.js +0 -270
- package/controllers/comments.js +0 -211
- package/models/comment.js +0 -8
- package/models/comment.settings.json +0 -98
- package/models/report.js +0 -8
- package/models/report.settings.json +0 -49
- package/services/comments.js +0 -486
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { camelCase } from 'lodash';
|
|
2
|
-
|
|
3
|
-
export const isMatch = filterValue => ({ value }) => {
|
|
4
|
-
const parsedValue = Number(filterValue);
|
|
5
|
-
return isNaN(parsedValue) ? filterValue === value : parsedValue === value;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const isRelatedFilter = (name) => name === 'related';
|
|
9
|
-
|
|
10
|
-
export const isEntityFilter = (name) => name === 'entity';
|
|
11
|
-
|
|
12
|
-
const defaultFilter = [
|
|
13
|
-
{ name: 'related', filter: '=', value: '' },
|
|
14
|
-
{ name: 'entity', filter: '=', value: '' },
|
|
15
|
-
];
|
|
16
|
-
export const initFilters = (queryFilters) => {
|
|
17
|
-
return ([...defaultFilter, ...queryFilters])
|
|
18
|
-
.reduce(
|
|
19
|
-
(acc, current) => ({ ...acc, [camelCase(current.name)]: current }), {},
|
|
20
|
-
);
|
|
21
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { Card } from '@buffetjs/styles';
|
|
4
|
-
|
|
5
|
-
import { colors, sizes } from 'strapi-helper-plugin';
|
|
6
|
-
|
|
7
|
-
const CardItem = styled(Card)`
|
|
8
|
-
padding: 1rem;
|
|
9
|
-
|
|
10
|
-
border-bottom: 2px ${props =>
|
|
11
|
-
props.active ? colors.blue : 'tranparent'} solid;
|
|
12
|
-
|
|
13
|
-
transition: all .15s ease-in-out;
|
|
14
|
-
|
|
15
|
-
${ props => !props.active && `
|
|
16
|
-
&:hover {
|
|
17
|
-
background-color: ${colors.lightGrey};
|
|
18
|
-
|
|
19
|
-
transform: translateY(-.5rem);
|
|
20
|
-
|
|
21
|
-
cursor: pointer;
|
|
22
|
-
}
|
|
23
|
-
`}
|
|
24
|
-
|
|
25
|
-
p {
|
|
26
|
-
margin-bottom: 0;
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
export default CardItem;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { useHistory, useParams } from 'react-router-dom';
|
|
4
|
-
import { isEmpty, isArray, first } from 'lodash';
|
|
5
|
-
import { generateSearchFromFilters } from 'strapi-helper-plugin';
|
|
6
|
-
import pluginId from '../../pluginId';
|
|
7
|
-
import CardWrapper from './CardWrapper';
|
|
8
|
-
import CardItem from './CardItem';
|
|
9
|
-
import ItemFooter from '../ItemFooter';
|
|
10
|
-
import ItemHeader from '../ItemHeader';
|
|
11
|
-
import useDataManager from '../../hooks/useDataManager';
|
|
12
|
-
|
|
13
|
-
const Item = ({
|
|
14
|
-
id,
|
|
15
|
-
content,
|
|
16
|
-
authorName,
|
|
17
|
-
authorUser,
|
|
18
|
-
created_at,
|
|
19
|
-
updated_at,
|
|
20
|
-
related,
|
|
21
|
-
reports,
|
|
22
|
-
blocked,
|
|
23
|
-
blockedThread,
|
|
24
|
-
isNew,
|
|
25
|
-
removed,
|
|
26
|
-
createdAt,
|
|
27
|
-
updatedAt,
|
|
28
|
-
relatedContentTypes,
|
|
29
|
-
}) => {
|
|
30
|
-
const { push } = useHistory();
|
|
31
|
-
const { getSearchParams } = useDataManager();
|
|
32
|
-
const { id: activeId } = useParams();
|
|
33
|
-
const parsedId = typeof activeId === 'number' ? Number(activeId) : activeId;
|
|
34
|
-
|
|
35
|
-
const onClick = e => {
|
|
36
|
-
if (!e.target.href) {
|
|
37
|
-
e.preventDefault();
|
|
38
|
-
push({
|
|
39
|
-
pathname: `/plugins/${pluginId}/display/${id}`,
|
|
40
|
-
search: generateSearchFromFilters(getSearchParams()),
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const isAbuseReported = !isEmpty(reports);
|
|
46
|
-
const isItemHeaderDisplayed = blocked || blockedThread || isNew || removed || isAbuseReported;
|
|
47
|
-
const headerProps = {
|
|
48
|
-
blocked,
|
|
49
|
-
blockedThread,
|
|
50
|
-
isNew,
|
|
51
|
-
isAbuseReported,
|
|
52
|
-
isRemoved: removed,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const footerProps = {
|
|
56
|
-
authorName,
|
|
57
|
-
authorUser,
|
|
58
|
-
related: isArray(related) ? first(related) : related,
|
|
59
|
-
created_at: created_at || createdAt,
|
|
60
|
-
updated_at: updated_at || updatedAt,
|
|
61
|
-
relatedContentTypes
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<CardWrapper>
|
|
66
|
-
<CardItem
|
|
67
|
-
onClick={onClick}
|
|
68
|
-
active={id === parsedId}
|
|
69
|
-
>
|
|
70
|
-
{ isItemHeaderDisplayed && (<ItemHeader { ...headerProps } />) }
|
|
71
|
-
<p>{content}</p>
|
|
72
|
-
<ItemFooter {...footerProps} />
|
|
73
|
-
</CardItem>
|
|
74
|
-
</CardWrapper>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
Item.propTypes = {
|
|
79
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
80
|
-
content: PropTypes.string.isRequired,
|
|
81
|
-
authorName: PropTypes.string,
|
|
82
|
-
authorUser: PropTypes.object,
|
|
83
|
-
created_at: PropTypes.string.isRequired,
|
|
84
|
-
updated_at: PropTypes.string,
|
|
85
|
-
related: PropTypes.array,
|
|
86
|
-
reports: PropTypes.array,
|
|
87
|
-
blocked: PropTypes.bool,
|
|
88
|
-
blockedThread: PropTypes.bool,
|
|
89
|
-
isNew: PropTypes.bool,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export default Item;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { Card } from '@buffetjs/styles';
|
|
4
|
-
|
|
5
|
-
import { colors, sizes } from 'strapi-helper-plugin';
|
|
6
|
-
|
|
7
|
-
const CardItem = styled(Card)`
|
|
8
|
-
padding: 1rem;
|
|
9
|
-
|
|
10
|
-
color: ${props => props.active ? 'inherit' : colors.leftMenu.darkGrey};
|
|
11
|
-
background: ${props => props.active ? '#ffffff' : colors.grey};
|
|
12
|
-
|
|
13
|
-
transition: all .15s ease-in-out;
|
|
14
|
-
|
|
15
|
-
${props => props.root && props.clickable && `
|
|
16
|
-
&:hover {
|
|
17
|
-
color: ${colors.leftMenu.black};
|
|
18
|
-
background: #ffffff;
|
|
19
|
-
|
|
20
|
-
transform: translateY(-.5rem);
|
|
21
|
-
|
|
22
|
-
cursor: pointer;
|
|
23
|
-
}
|
|
24
|
-
` }
|
|
25
|
-
|
|
26
|
-
p {
|
|
27
|
-
margin-bottom: 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
export default CardItem;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors, sizes } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const CardLevelCounter = styled.div`
|
|
6
|
-
padding: 0 0 0 4rem;
|
|
7
|
-
margin: 1rem;
|
|
8
|
-
|
|
9
|
-
position: relative;
|
|
10
|
-
|
|
11
|
-
font-weight: 500;
|
|
12
|
-
font-size: 1.25rem;
|
|
13
|
-
|
|
14
|
-
&:before {
|
|
15
|
-
display: ${ props => props.root ? 'none' : 'block' };
|
|
16
|
-
content: '';
|
|
17
|
-
margin-top: -1px;
|
|
18
|
-
|
|
19
|
-
height: 0;
|
|
20
|
-
width: 2rem;
|
|
21
|
-
|
|
22
|
-
position: absolute;
|
|
23
|
-
top: 50%;
|
|
24
|
-
left: 1rem;
|
|
25
|
-
|
|
26
|
-
border-top: 2px ${colors.relations.boxShadow} dotted;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&:after {
|
|
30
|
-
display: ${ props => props.root ? 'none' : 'block' };
|
|
31
|
-
content: '';
|
|
32
|
-
margin-left: -1px;
|
|
33
|
-
|
|
34
|
-
width: 0;
|
|
35
|
-
|
|
36
|
-
position: absolute;
|
|
37
|
-
top: -1rem;
|
|
38
|
-
bottom: calc(50% - 1px);
|
|
39
|
-
left: 1rem;
|
|
40
|
-
|
|
41
|
-
border-left: 2px ${colors.relations.boxShadow} dotted;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
export default CardLevelCounter;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors, sizes, darken } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const CardLevelCounterLink = styled.span`
|
|
6
|
-
display: inline-block;
|
|
7
|
-
margin-left: 1rem;
|
|
8
|
-
|
|
9
|
-
color: ${colors.blue};
|
|
10
|
-
|
|
11
|
-
transition: all .15s ease-in-out;
|
|
12
|
-
|
|
13
|
-
&:hover {
|
|
14
|
-
color: ${darken(colors.blue, 10)};
|
|
15
|
-
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
svg {
|
|
20
|
-
margin-left: .5rem;
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
export default CardLevelCounterLink;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors, sizes } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const CardLevelWrapper = styled.ul`
|
|
6
|
-
padding: 0;
|
|
7
|
-
margin: 0;
|
|
8
|
-
|
|
9
|
-
list-style: none;
|
|
10
|
-
|
|
11
|
-
position: relative;
|
|
12
|
-
z-index: 1;
|
|
13
|
-
|
|
14
|
-
ul {
|
|
15
|
-
padding-left: 4rem;
|
|
16
|
-
|
|
17
|
-
position: relative;
|
|
18
|
-
z-index: 0;
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
export default CardLevelWrapper;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors, sizes } from 'strapi-helper-plugin';
|
|
4
|
-
import CardItem from './CardItem';
|
|
5
|
-
|
|
6
|
-
const CardWrapper = styled.li`
|
|
7
|
-
padding: 0;
|
|
8
|
-
margin: 0 0 2rem 0;
|
|
9
|
-
|
|
10
|
-
position: relative;
|
|
11
|
-
z-index: 1;
|
|
12
|
-
|
|
13
|
-
${CardItem}:before {
|
|
14
|
-
display: ${ props => props.root ? 'none' : 'block' };
|
|
15
|
-
content: '';
|
|
16
|
-
margin-top: -1px;
|
|
17
|
-
|
|
18
|
-
height: 2px;
|
|
19
|
-
width: 2rem;
|
|
20
|
-
|
|
21
|
-
position: absolute;
|
|
22
|
-
top: 50%;
|
|
23
|
-
left: -2rem;
|
|
24
|
-
z-index: -1;
|
|
25
|
-
|
|
26
|
-
background-color: ${colors.relations.boxShadow};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&:after {
|
|
30
|
-
display: ${ props => props.root ? 'none' : 'block' };
|
|
31
|
-
content: '';
|
|
32
|
-
margin-left: -1px;
|
|
33
|
-
|
|
34
|
-
width: 2px;
|
|
35
|
-
|
|
36
|
-
position: absolute;
|
|
37
|
-
top: -2rem;
|
|
38
|
-
bottom: 0;
|
|
39
|
-
left: -2rem;
|
|
40
|
-
z-index: -1;
|
|
41
|
-
|
|
42
|
-
background-color: ${colors.relations.boxShadow};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&:last-child {
|
|
46
|
-
&:after {
|
|
47
|
-
bottom: ${props => props.active ? `calc(50% - 1px + 2rem)` : `calc(50% - 1px)`};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
51
|
-
|
|
52
|
-
export default CardWrapper;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { FormattedMessage } from 'react-intl';
|
|
4
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
-
import { faArrowRight } from '@fortawesome/free-solid-svg-icons';
|
|
6
|
-
import { isEmpty, isArray, first } from 'lodash';
|
|
7
|
-
import CardWrapper from './CardWrapper';
|
|
8
|
-
import CardItem from './CardItem';
|
|
9
|
-
import CardLevelCounter from './CardLevelCounter';
|
|
10
|
-
import CardLevelCounterLink from './CardLevelCounterLink';
|
|
11
|
-
import ItemFooter from '../ItemFooter';
|
|
12
|
-
import ItemModeration from '../ItemModeration';
|
|
13
|
-
import ItemHeader from '../ItemHeader';
|
|
14
|
-
import AbuseReportsPopUp from '../AbuseReportsPopUp';
|
|
15
|
-
import pluginId from '../../pluginId';
|
|
16
|
-
|
|
17
|
-
const ItemDetails = ({
|
|
18
|
-
id,
|
|
19
|
-
content,
|
|
20
|
-
active,
|
|
21
|
-
clickable,
|
|
22
|
-
root,
|
|
23
|
-
threadsCount,
|
|
24
|
-
authorName,
|
|
25
|
-
authorUser,
|
|
26
|
-
created_at,
|
|
27
|
-
createdAt,
|
|
28
|
-
updated_at,
|
|
29
|
-
updatedAt,
|
|
30
|
-
related,
|
|
31
|
-
reports,
|
|
32
|
-
blocked,
|
|
33
|
-
blockedThread,
|
|
34
|
-
removed,
|
|
35
|
-
onClick,
|
|
36
|
-
onBlockClick,
|
|
37
|
-
onBlockThreadClick,
|
|
38
|
-
onAbuseReportResolve,
|
|
39
|
-
}) => {
|
|
40
|
-
const [showPopUp, setPopUpVisibility] = useState(false);
|
|
41
|
-
|
|
42
|
-
const onPopUpOpen = e => {
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
e.stopPropagation();
|
|
45
|
-
setPopUpVisibility(true);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const onPopUpClose = e => {
|
|
49
|
-
e.preventDefault();
|
|
50
|
-
e.stopPropagation();
|
|
51
|
-
setPopUpVisibility(false);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const onAbuseReportResolveClick = (e, reportId) => {
|
|
55
|
-
e.preventDefault();
|
|
56
|
-
e.stopPropagation();
|
|
57
|
-
onAbuseReportResolve(reportId, id);
|
|
58
|
-
};
|
|
59
|
-
const hasThreads = (threadsCount !== undefined) && (threadsCount > 0);
|
|
60
|
-
const isAbuseReported = !isEmpty(reports);
|
|
61
|
-
const isItemHeaderDisplayed = blocked || blockedThread || removed || isAbuseReported;
|
|
62
|
-
const footerProps = {
|
|
63
|
-
authorName,
|
|
64
|
-
authorUser,
|
|
65
|
-
related: isArray(related) ? first(related) : related,
|
|
66
|
-
created_at: created_at || createdAt,
|
|
67
|
-
updated_at: updated_at || updatedAt,
|
|
68
|
-
isDelailedView: true,
|
|
69
|
-
};
|
|
70
|
-
const headerProps = {
|
|
71
|
-
active,
|
|
72
|
-
blocked,
|
|
73
|
-
blockedThread,
|
|
74
|
-
isRemoved: removed,
|
|
75
|
-
abuseReports: reports || [],
|
|
76
|
-
isAbuseReported: !isEmpty(reports),
|
|
77
|
-
isDelailedView: true,
|
|
78
|
-
onReportsClick: onPopUpOpen,
|
|
79
|
-
};
|
|
80
|
-
const moderationProps = {
|
|
81
|
-
id,
|
|
82
|
-
blocked,
|
|
83
|
-
blockedThread,
|
|
84
|
-
onBlockClick,
|
|
85
|
-
onBlockThreadClick,
|
|
86
|
-
};
|
|
87
|
-
const reportsPopUpProps = {
|
|
88
|
-
blocked,
|
|
89
|
-
blockedThread,
|
|
90
|
-
reports,
|
|
91
|
-
comment: {
|
|
92
|
-
id, content, authorName, authorUser, created_at, updated_at,
|
|
93
|
-
},
|
|
94
|
-
onBlockClick,
|
|
95
|
-
onBlockThreadClick,
|
|
96
|
-
onAbuseReportResolveClick,
|
|
97
|
-
isOpen: showPopUp,
|
|
98
|
-
onClose: onPopUpClose,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<CardWrapper root={root} active={active}>
|
|
103
|
-
<CardItem
|
|
104
|
-
onClick={e => (hasThreads || root) && clickable && !active && onClick(e)}
|
|
105
|
-
clickable={clickable}
|
|
106
|
-
root={root}
|
|
107
|
-
active={active}>
|
|
108
|
-
{ isItemHeaderDisplayed && (<ItemHeader { ...headerProps } />) }
|
|
109
|
-
<p>{content}</p>
|
|
110
|
-
<ItemFooter {...footerProps} />
|
|
111
|
-
</CardItem>
|
|
112
|
-
{ hasThreads && (<CardLevelCounter>
|
|
113
|
-
<FormattedMessage id={`${pluginId}.list.item.threads.count`} values={{ count: threadsCount }}/>
|
|
114
|
-
<CardLevelCounterLink onClick={onClick}>
|
|
115
|
-
<FormattedMessage id={`${pluginId}.list.item.threads.drilldown`} />
|
|
116
|
-
<FontAwesomeIcon icon={faArrowRight} />
|
|
117
|
-
</CardLevelCounterLink>
|
|
118
|
-
</CardLevelCounter>
|
|
119
|
-
)}
|
|
120
|
-
{ active && !removed && (<ItemModeration { ...moderationProps } />) }
|
|
121
|
-
{ (!isEmpty(reports) && active) && (
|
|
122
|
-
<AbuseReportsPopUp
|
|
123
|
-
{...reportsPopUpProps}
|
|
124
|
-
/>
|
|
125
|
-
)}
|
|
126
|
-
</CardWrapper>
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
ItemDetails.propTypes = {
|
|
131
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
132
|
-
content: PropTypes.string.isRequired,
|
|
133
|
-
active: PropTypes.bool,
|
|
134
|
-
clickable: PropTypes.bool,
|
|
135
|
-
root: PropTypes.bool,
|
|
136
|
-
threadsCount: PropTypes.number,
|
|
137
|
-
authorName: PropTypes.string,
|
|
138
|
-
authorUser: PropTypes.object,
|
|
139
|
-
created_at: PropTypes.string.isRequired,
|
|
140
|
-
updated_at: PropTypes.string,
|
|
141
|
-
related: PropTypes.array,
|
|
142
|
-
reports: PropTypes.array,
|
|
143
|
-
blocked: PropTypes.bool,
|
|
144
|
-
blockedThread: PropTypes.bool,
|
|
145
|
-
onClick: PropTypes.func,
|
|
146
|
-
onBlockClick: PropTypes.func,
|
|
147
|
-
onBlockThreadClick: PropTypes.func,
|
|
148
|
-
onAbuseReportResolve: PropTypes.func,
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export default ItemDetails;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { sizes } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const CardItemRelation = styled.span`
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-grow: 1;
|
|
8
|
-
flex-direction: row;
|
|
9
|
-
|
|
10
|
-
align-items: center;
|
|
11
|
-
justify-content: flex-end;
|
|
12
|
-
|
|
13
|
-
svg {
|
|
14
|
-
margin-right: ${sizes.margin/2}px;
|
|
15
|
-
}
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
export default CardItemRelation;
|
|
@@ -1,20 +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
|
-
padding-top: 1rem;
|
|
8
|
-
margin-top: 1rem;
|
|
9
|
-
|
|
10
|
-
flex-wrap: wrap;
|
|
11
|
-
justify-items: center;
|
|
12
|
-
align-items: stretch;
|
|
13
|
-
|
|
14
|
-
color: ${colors.leftMenu.grey};
|
|
15
|
-
font-size: 1.25rem;
|
|
16
|
-
|
|
17
|
-
border-top: 1px ${colors.leftMenu.lightGrey} solid;
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
export default Wrapper;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import moment from 'moment';
|
|
4
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
-
import { faLink } from '@fortawesome/free-solid-svg-icons';
|
|
6
|
-
import CardItemRelation from './CardItemRelation';
|
|
7
|
-
import CardItemAuthor from './CardItemAuthor';
|
|
8
|
-
import Wrapper from './Wrapper';
|
|
9
|
-
import { find, isNil, isObject, kebabCase, snakeCase, startCase } from 'lodash';
|
|
10
|
-
import { Link } from 'react-router-dom';
|
|
11
|
-
|
|
12
|
-
const ENTITY_NAME_PARAMS = ['title', 'Title', 'subject', 'Subject', 'name', 'Name'];
|
|
13
|
-
|
|
14
|
-
const getLink = (to, contentType) => (
|
|
15
|
-
<Link to={`${to}`}>
|
|
16
|
-
{startCase(contentType)}
|
|
17
|
-
</Link>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const getContentTypeLink = (name) => `application::${name}.${name}`;
|
|
21
|
-
|
|
22
|
-
const resolveEntityName = entity => ENTITY_NAME_PARAMS.map(_ => entity[_]).filter(_ => _)[0] || '';
|
|
23
|
-
|
|
24
|
-
const ItemFooter = ({ authorName, authorUser, related, created_at, isDetailedView, relatedContentTypes }) => {
|
|
25
|
-
const formatAuthor = () => {
|
|
26
|
-
if (authorUser) {
|
|
27
|
-
return authorUser.username;
|
|
28
|
-
}
|
|
29
|
-
return authorName;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const formatDateTime = () => {
|
|
33
|
-
return moment(created_at).format('DD/MM/YYYY, HH:mm:ss');
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const relatedExist = useMemo(() => !isNil(related) && isObject(related), [related]);
|
|
37
|
-
|
|
38
|
-
const formatRelationType = () => {
|
|
39
|
-
if (relatedExist) {
|
|
40
|
-
const { id, __contentType: contentType } = related;
|
|
41
|
-
const name = snakeCase(contentType);
|
|
42
|
-
const relation = find(relatedContentTypes, ({ globalName }) => globalName === name);
|
|
43
|
-
if (relation && relation.contentManager) {
|
|
44
|
-
const contentManagerRoot = `/plugins/content-manager`;
|
|
45
|
-
if (relation.isSingle) {
|
|
46
|
-
return getLink(
|
|
47
|
-
relation.url || `${contentManagerRoot}/singleType/${getContentTypeLink(kebabCase(name))}`,
|
|
48
|
-
related.__contentType,
|
|
49
|
-
);
|
|
50
|
-
} else if (relation.url) {
|
|
51
|
-
const url = `${relation.url.replace(':id', id)}'?_sort=id:ASC&_where[0][id]=${id}`;
|
|
52
|
-
return getLink(url, related[relation.key] || related.__contentType);
|
|
53
|
-
} else {
|
|
54
|
-
const url = `${contentManagerRoot}/collectionType/${getContentTypeLink(
|
|
55
|
-
kebabCase(name))}?_sort=id:ASC&_where[0][id]=${id}`;
|
|
56
|
-
return getLink(url, related[relation.key] || related.__contentType);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return startCase(related.__contentType);
|
|
60
|
-
}
|
|
61
|
-
return '';
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const formatRelationName = () => relatedExist ? resolveEntityName(related) : '';
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<Wrapper>
|
|
68
|
-
<CardItemAuthor>{formatAuthor()} @ {formatDateTime()}</CardItemAuthor>
|
|
69
|
-
{!isNil(related) && (
|
|
70
|
-
<CardItemRelation title={!isDetailedView && formatRelationName()}>
|
|
71
|
-
<FontAwesomeIcon icon={faLink} />
|
|
72
|
-
{isDetailedView ? `(${formatRelationType()}) ${formatRelationName()}` : formatRelationType()}
|
|
73
|
-
</CardItemRelation>
|
|
74
|
-
)}
|
|
75
|
-
</Wrapper>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
ItemFooter.propTypes = {
|
|
80
|
-
authorName: PropTypes.string,
|
|
81
|
-
authorUser: PropTypes.object,
|
|
82
|
-
related: PropTypes.object,
|
|
83
|
-
created_at: PropTypes.string.isRequired,
|
|
84
|
-
isDetailedView: PropTypes.bool,
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export default ItemFooter;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const CardHeaderBlocked = styled.span`
|
|
6
|
-
display: inline-flex;
|
|
7
|
-
flex-direction: row;
|
|
8
|
-
align-items: center;
|
|
9
|
-
justify-items: center;
|
|
10
|
-
height: 2.5rem;
|
|
11
|
-
margin-right: 1rem;
|
|
12
|
-
padding: .25rem 1rem;
|
|
13
|
-
|
|
14
|
-
color: ${colors.leftMenu.grey};
|
|
15
|
-
|
|
16
|
-
border-radius: 1.25rem;
|
|
17
|
-
background: ${colors.leftMenu.lightGrey};
|
|
18
|
-
|
|
19
|
-
svg {
|
|
20
|
-
margin-right: .5rem;
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
export default CardHeaderBlocked;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const CardHeaderIndicator = styled.span`
|
|
6
|
-
display: inline-flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
justify-content: center;
|
|
9
|
-
width: 1.8rem;
|
|
10
|
-
height: 1.8rem;
|
|
11
|
-
|
|
12
|
-
font-size: 1rem;
|
|
13
|
-
color: ${colors.beige};
|
|
14
|
-
vertical-align: middle;
|
|
15
|
-
line-height: 1.8rem;
|
|
16
|
-
text-align: center;
|
|
17
|
-
|
|
18
|
-
border-radius: .9rem;
|
|
19
|
-
background: ${colors.grey};
|
|
20
|
-
|
|
21
|
-
&:first-child {
|
|
22
|
-
margin-right: .5rem;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&:last-child {
|
|
26
|
-
margin-right: 0;
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
export default CardHeaderIndicator;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors } from 'strapi-helper-plugin';
|
|
4
|
-
import CardHeaderIndicator from './CardHeaderIndicator';
|
|
5
|
-
|
|
6
|
-
const CardHeaderIndicatorBlue = styled(CardHeaderIndicator)`
|
|
7
|
-
color: ${colors.beige};
|
|
8
|
-
background: ${colors.blue};
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
export default CardHeaderIndicatorBlue;
|