strapi-plugin-comments 1.0.4 → 2.0.0-beta.4

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 (156) hide show
  1. package/.circleci/config.yml +2 -2
  2. package/README.md +53 -126
  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 +59 -0
  6. package/admin/src/components/DiscussionThreadItem/index.js +87 -0
  7. package/admin/src/components/DiscussionThreadItem/styles.js +88 -0
  8. package/admin/src/components/DiscussionThreadItemActions/index.js +178 -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 +141 -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 +43 -0
  20. package/admin/src/components/ReportsReviewTable/index.js +146 -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/components/icons/index.js +6 -0
  25. package/admin/src/components/icons/lock.js +22 -0
  26. package/admin/src/components/icons/review.js +18 -0
  27. package/admin/src/components/icons/unlock.js +20 -0
  28. package/admin/src/index.js +58 -42
  29. package/admin/src/pages/App/index.js +71 -0
  30. package/admin/src/pages/App/reducer/actions.js +8 -0
  31. package/admin/src/pages/App/reducer/constants.js +4 -0
  32. package/admin/src/pages/App/reducer/index.js +26 -0
  33. package/admin/src/pages/App/reducer/init.js +7 -0
  34. package/admin/src/pages/App/reducer/selectors.js +35 -0
  35. package/admin/src/pages/App/utils/api.js +12 -0
  36. package/admin/src/pages/ComingSoonPage/index.js +25 -0
  37. package/admin/src/pages/Details/index.js +109 -0
  38. package/admin/src/pages/Details/utils/api.js +41 -0
  39. package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +196 -0
  40. package/admin/src/pages/Discover/index.js +157 -0
  41. package/admin/src/pages/Discover/utils/api.js +14 -0
  42. package/admin/src/pages/Discover/utils/filtersSchema.js +9 -0
  43. package/admin/src/permissions.js +13 -37
  44. package/admin/src/pluginId.js +2 -4
  45. package/admin/src/reducers.js +8 -0
  46. package/admin/src/translations/en.json +73 -37
  47. package/admin/src/translations/fr.json +1 -0
  48. package/admin/src/utils/axiosInstance.js +35 -0
  49. package/admin/src/utils/constants.js +25 -6
  50. package/admin/src/utils/getApiUrl.js +5 -0
  51. package/admin/src/utils/getMessage.js +21 -0
  52. package/admin/src/utils/getRelatedGroups.js +5 -0
  53. package/admin/src/utils/getUrl.js +5 -0
  54. package/admin/src/utils/handleAPIError.js +15 -0
  55. package/admin/src/utils/index.js +6 -0
  56. package/codecov.yml +2 -1
  57. package/content-types/comment.js +97 -0
  58. package/content-types/index.js +11 -0
  59. package/content-types/report.js +54 -0
  60. package/package.json +11 -25
  61. package/server/bootstrap.js +5 -0
  62. package/server/config/index.js +10 -0
  63. package/server/controllers/admin.js +134 -0
  64. package/server/controllers/client.js +117 -0
  65. package/server/controllers/index.js +9 -0
  66. package/{controllers → server/controllers}/utils/__tests__/functions.test.js +0 -0
  67. package/{controllers → server/controllers}/utils/functions.js +1 -1
  68. package/server/destroy.js +5 -0
  69. package/server/index.js +22 -0
  70. package/server/register.js +5 -0
  71. package/server/routes/admin.js +92 -0
  72. package/server/routes/client.js +52 -0
  73. package/server/routes/index.js +15 -0
  74. package/server/services/admin.js +215 -0
  75. package/server/services/client.js +227 -0
  76. package/server/services/common.js +197 -0
  77. package/server/services/index.js +11 -0
  78. package/{services → server/services}/utils/__tests__/functions.test.js +0 -0
  79. package/{services → server/services}/utils/functions.js +17 -6
  80. package/server/utils/constants.js +16 -0
  81. package/{services → server}/utils/error.js +0 -0
  82. package/server/utils/functions.js +19 -0
  83. package/strapi-admin.js +3 -0
  84. package/strapi-server.js +9 -0
  85. package/admin/src/assets/images/icon-cross-blue.svg +0 -1
  86. package/admin/src/assets/images/icon_remove.svg +0 -19
  87. package/admin/src/assets/images/logo.svg +0 -5
  88. package/admin/src/components/AbuseReportsPopUp/ItemPreviewContainer.js +0 -8
  89. package/admin/src/components/AbuseReportsPopUp/ModalFooter.js +0 -31
  90. package/admin/src/components/AbuseReportsPopUp/TableContainer.js +0 -63
  91. package/admin/src/components/AbuseReportsPopUp/index.js +0 -148
  92. package/admin/src/components/Container/index.js +0 -7
  93. package/admin/src/components/EmptyView/index.js +0 -25
  94. package/admin/src/components/Filters/index.js +0 -151
  95. package/admin/src/components/Filters/index.styled.js +0 -82
  96. package/admin/src/components/Filters/utils.js +0 -21
  97. package/admin/src/components/Item/CardItem.js +0 -30
  98. package/admin/src/components/Item/CardWrapper.js +0 -10
  99. package/admin/src/components/Item/index.js +0 -107
  100. package/admin/src/components/ItemDetails/CardItem.js +0 -33
  101. package/admin/src/components/ItemDetails/CardLevelCounter.js +0 -46
  102. package/admin/src/components/ItemDetails/CardLevelCounterLink.js +0 -24
  103. package/admin/src/components/ItemDetails/CardLevelWrapper.js +0 -22
  104. package/admin/src/components/ItemDetails/CardWrapper.js +0 -52
  105. package/admin/src/components/ItemDetails/index.js +0 -167
  106. package/admin/src/components/ItemFooter/CardItemAuthor.js +0 -10
  107. package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
  108. package/admin/src/components/ItemFooter/Wrapper.js +0 -20
  109. package/admin/src/components/ItemFooter/index.js +0 -87
  110. package/admin/src/components/ItemHeader/CardHeaderBlocked.js +0 -24
  111. package/admin/src/components/ItemHeader/CardHeaderIndicator.js +0 -30
  112. package/admin/src/components/ItemHeader/CardHeaderIndicatorBlue.js +0 -11
  113. package/admin/src/components/ItemHeader/CardHeaderIndicatorRed.js +0 -11
  114. package/admin/src/components/ItemHeader/CardHeaderIndicatorsContainer.js +0 -18
  115. package/admin/src/components/ItemHeader/CardHeaderPending.js +0 -11
  116. package/admin/src/components/ItemHeader/CardHeaderReports.js +0 -40
  117. package/admin/src/components/ItemHeader/Wrapper.js +0 -16
  118. package/admin/src/components/ItemHeader/index.js +0 -97
  119. package/admin/src/components/ItemModeration/Wrapper.js +0 -19
  120. package/admin/src/components/ItemModeration/index.js +0 -84
  121. package/admin/src/components/List/Container.js +0 -20
  122. package/admin/src/components/List/index.js +0 -21
  123. package/admin/src/components/Search/index.js +0 -83
  124. package/admin/src/containers/App/Wrapper.js +0 -14
  125. package/admin/src/containers/App/index.js +0 -47
  126. package/admin/src/containers/DataManagerProvider/actions.js +0 -15
  127. package/admin/src/containers/DataManagerProvider/index.js +0 -332
  128. package/admin/src/containers/DataManagerProvider/init.js +0 -5
  129. package/admin/src/containers/DataManagerProvider/reducer.js +0 -59
  130. package/admin/src/containers/DetailsView/Wrapper.js +0 -18
  131. package/admin/src/containers/DetailsView/index.js +0 -106
  132. package/admin/src/containers/ListView/FadedWrapper.js +0 -42
  133. package/admin/src/containers/ListView/Footer.js +0 -53
  134. package/admin/src/containers/ListView/Wrapper.js +0 -17
  135. package/admin/src/containers/ListView/components.js +0 -138
  136. package/admin/src/containers/ListView/index.js +0 -45
  137. package/admin/src/containers/Panel/actions.js +0 -5
  138. package/admin/src/containers/Panel/index.js +0 -191
  139. package/admin/src/containers/Panel/index.styled.js +0 -6
  140. package/admin/src/containers/Panel/reducer.js +0 -44
  141. package/admin/src/contexts/DataManagerContext.js +0 -5
  142. package/admin/src/hooks/useDataManager.js +0 -6
  143. package/admin/src/lifecycles.js +0 -3
  144. package/admin/src/translations/index.js +0 -7
  145. package/admin/src/utils/getTrad.js +0 -5
  146. package/admin/src/utils/getTradId.js +0 -5
  147. package/config/functions/bootstrap.js +0 -62
  148. package/config/routes.json +0 -142
  149. package/config/schema.graphql.js +0 -268
  150. package/controllers/comments.js +0 -228
  151. package/models/comment.js +0 -8
  152. package/models/comment.settings.json +0 -102
  153. package/models/report.js +0 -8
  154. package/models/report.settings.json +0 -49
  155. package/services/comments.js +0 -539
  156. package/services/utils/constants.js +0 -9
@@ -1,148 +0,0 @@
1
- /**
2
- *
3
- * AbuseReportsPopUp
4
- *
5
- */
6
-
7
- import React from 'react';
8
- import { FormattedMessage } from 'react-intl';
9
- import moment from 'moment';
10
- import PropTypes from 'prop-types';
11
- import { isEmpty } from 'lodash';
12
- import {
13
- ButtonModal,
14
- HeaderModal,
15
- HeaderModalTitle,
16
- Modal,
17
- ModalBody,
18
- ModalForm,
19
- useGlobalContext,
20
- CheckPermissions,
21
- } from 'strapi-helper-plugin';
22
- import { Table, Button } from '@buffetjs/core';
23
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
24
- import {
25
- faCheck,
26
- faSmile,
27
- } from '@fortawesome/free-solid-svg-icons';
28
- import TableContainer from './TableContainer';
29
- import EmptyView from '../EmptyView';
30
- import ItemDetails from '../ItemDetails';
31
- import ItemPreviewContainer from './ItemPreviewContainer';
32
- import ModalFooter from './ModalFooter';
33
- import pluginId from '../../pluginId';
34
-
35
- // Translations
36
- import en from '../../translations/en.json';
37
- import pluginPermissions from '../../permissions';
38
-
39
- const CustomRow = props => {
40
- const { row, formatMessage, onClick } = props;
41
- const { created_at, reason, content } = row;
42
- return (<tr>
43
- <td>{ created_at }</td>
44
- <td>{ reason }</td>
45
- <td><em>{ content }</em></td>
46
- <td style={{ textAlign: 'right' }}><Button
47
- onClick={onClick}
48
- color="secondary"
49
- icon={<FontAwesomeIcon icon={faCheck} />}
50
- label={formatMessage({ id: `${pluginId}.popup.reports.item.button` })}
51
- /></td>
52
- </tr>);
53
- }
54
-
55
- const AbuseReportsPopUp = ({ isOpen, reports, comment, blocked, blockedThread, onBlockClick, onBlockThreadClick, onClose, onAbuseReportResolveClick }) => {
56
-
57
- const { formatMessage } = useGlobalContext();
58
-
59
- const resolveReportReason = reason => formatMessage({ id: `${pluginId}.popup.reports.item.reason.${reason.toLowerCase()}`});
60
-
61
- const headers = [
62
- {
63
- name: formatMessage({ id: `${pluginId}.popup.reports.item.header.date` }),
64
- value: 'created_at',
65
- },
66
- {
67
- name: formatMessage({ id: `${pluginId}.popup.reports.item.header.reason` }),
68
- value: 'reason',
69
- },
70
- {
71
- name: formatMessage({ id: `${pluginId}.popup.reports.item.header.message` }),
72
- value: 'content',
73
- },
74
- { value: 'actions' }
75
- ];
76
-
77
- const rows = reports.map(({ id, created_at, content, reason }) => ({
78
- id,
79
- created_at: moment(created_at).format('DD/MM/YYYY, HH:mm'),
80
- reason: resolveReportReason(reason),
81
- content,
82
- }));
83
-
84
- return (
85
- <CheckPermissions permissions={pluginPermissions.moderateReports}>
86
- <Modal isOpen={isOpen} onToggle={onClose}>
87
- <HeaderModal>
88
- <section>
89
- <HeaderModalTitle>
90
- <FormattedMessage id={`${pluginId}.popup.reports.header`} />
91
- </HeaderModalTitle>
92
- </section>
93
- </HeaderModal>
94
- <ModalForm>
95
- <ModalBody>
96
- <section style={{ width: '100%' }}>
97
- <ItemPreviewContainer>
98
- <ItemDetails root={true} {...comment} />
99
- </ItemPreviewContainer>
100
- { isEmpty(reports) && (
101
- <EmptyView>
102
- <FontAwesomeIcon icon={faSmile} size="5x" />
103
- <FormattedMessage id={`${pluginId}.popup.reports.empty`} />
104
- </EmptyView>
105
- ) }
106
- { !isEmpty(reports) && (<TableContainer>
107
- <Table
108
- customRow={props => (<CustomRow {...props} formatMessage={formatMessage} onClick={(e) => onAbuseReportResolveClick(e, props.row.id)} />)}
109
- headers={headers}
110
- rows={rows}
111
- />
112
- </TableContainer>)}
113
- </section>
114
- </ModalBody>
115
- </ModalForm>
116
- { !isEmpty(reports) && !blockedThread && !blocked && (<ModalFooter>
117
- <section>
118
- <label>
119
- <FormattedMessage id={`${pluginId}.popup.reports.footer.actions`} />
120
- </label>
121
- { !blockedThread && (<ButtonModal
122
- onClick={e => onBlockClick(comment.id)}
123
- isSecondary
124
- message={`${pluginId}.list.item.moderation.button.comment.hide`} />)}
125
- <ButtonModal
126
- onClick={e => onBlockThreadClick(comment.id)}
127
- isSecondary
128
- message={`${pluginId}.list.item.moderation.button.thread.hide`} />
129
- </section>
130
- </ModalFooter>)}
131
- </Modal>
132
- </CheckPermissions>
133
- );
134
- }
135
-
136
- AbuseReportsPopUp.propTypes = {
137
- blocked: PropTypes.bool,
138
- blockedThread: PropTypes.bool,
139
- reports: PropTypes.array,
140
- comment: PropTypes.object.isRequired,
141
- onBlockClick: PropTypes.func.isRequired,
142
- onBlockThreadClick: PropTypes.func.isRequired,
143
- onAbuseReportResolveClick: PropTypes.func.isRequired,
144
- isOpen: PropTypes.bool,
145
- onClose: PropTypes.func.isRequired,
146
- };
147
-
148
- export default AbuseReportsPopUp;
@@ -1,7 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- const Container = styled.div`
4
- padding: 0 30px;
5
- `;
6
-
7
- export default Container;
@@ -1,25 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- import { colors } from 'strapi-helper-plugin';
4
-
5
- const EmptyView = styled.div`
6
- display: flex;
7
- flex-grow: 1;
8
- flex-direction: column;
9
- align-items: center;
10
- justify-content: center;
11
- padding-left: 2rem;
12
- padding-right: 2rem;
13
- padding-bottom: ${props => props.fixPosition ? '8rem' : 0};
14
-
15
- font-size: 2rem;
16
- font-weight: 600;
17
- color: ${colors.leftMenu.grey};
18
- text-align: center;
19
-
20
- svg {
21
- margin-bottom: 1rem;
22
- }
23
- `;
24
-
25
- export default EmptyView;
@@ -1,151 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { FormattedMessage } from 'react-intl';
3
- import { Collapse } from 'reactstrap';
4
- import { Select } from '@buffetjs/core';
5
- import { map, noop, startCase } from 'lodash';
6
-
7
- import { FilterButton, getFilterType } from 'strapi-helper-plugin';
8
-
9
- import { AddFilterCta, Container, FilterIcon, FiltersWrapper, InputWrapper, styles, Wrapper } from './index.styled';
10
- import useDataManager from '../../hooks/useDataManager';
11
- import { isEntityFilter, isMatch } from './utils';
12
-
13
- const allowedAttributes = ['Related to'];
14
-
15
- const Filters = ({
16
- contentsTypes,
17
- isLoadingContentsTypes,
18
- isOpenFilter,
19
- onToggleOpen,
20
- onRemoveFilter,
21
- onChangeFilter,
22
- filters,
23
- isLoadingEntries,
24
- availableEntriesMap,
25
- }) => {
26
- const filtersOptions = getFilterType();
27
- const { search } = useDataManager();
28
-
29
- const searchFilters = useMemo(
30
- () => (search.filters.reduce(
31
- (acc, current) => ({ ...acc, [current.name]: { ...current, contentType: filters?.related?.value } }),
32
- {})
33
- ),
34
- [search.filters],
35
- );
36
-
37
- const contentsTypesOptions = useMemo(
38
- () => [{ key: '', value: '' }, ...(contentsTypes || []).map(_ => ({ ..._, key: startCase(_.key) }))],
39
- [contentsTypes],
40
- );
41
- const availableEntriesOptions = useMemo(
42
- () => [{ key: '', value: '' }, ...(availableEntriesMap[filters?.related?.value] || [])],
43
- [availableEntriesMap],
44
- );
45
-
46
- if (isLoadingContentsTypes) {
47
- return null;
48
- }
49
- return (
50
- <>
51
- <Collapse isOpen={isOpenFilter}>
52
- <Container>
53
- <form>
54
- <Wrapper>
55
- <FiltersWrapper borderLeft={filters.related.value}>
56
- <InputWrapper>
57
- <Select
58
- disabled
59
- options={allowedAttributes}
60
- onChange={noop}
61
- name='name'
62
- value={filters.related.name}
63
- style={styles.select}
64
- />
65
- <Select
66
- disabled
67
- name='filter'
68
- onChange={noop}
69
- value={filters.related.filter}
70
- options={
71
- filtersOptions.map(({ id, value }) => (
72
- <FormattedMessage key={id} id={id}>
73
- {msg => <option value={value}>{msg}</option>}
74
- </FormattedMessage>
75
- ))
76
- }
77
- style={styles.selectMiddle}
78
- />
79
- <Select
80
- name="related-value"
81
- onChange={onChangeFilter}
82
- value={filters.related.value}
83
- options={
84
- contentsTypesOptions
85
- .map(({ key, value }) => (
86
- <option key={value} value={value}>
87
- {key}
88
- </option>
89
- ))
90
- }
91
- style={styles.select}
92
- />
93
- {
94
- filters.related.value && !isLoadingEntries && (
95
- <Select
96
- name="entity-value"
97
- options={
98
- availableEntriesOptions.map(({ key, value }) => (
99
- <option key={key} value={value}>
100
- {key}
101
- </option>
102
- ))
103
- }
104
- value={filters?.entity?.value}
105
- onChange={onChangeFilter}
106
- style={styles.select}
107
- />
108
- )
109
- }
110
- </InputWrapper>
111
- </FiltersWrapper>
112
- </Wrapper>
113
- </form>
114
- </Container>
115
- </Collapse>
116
- <div className="container-fluid">
117
- <div className="row">
118
- <AddFilterCta type="button" onClick={onToggleOpen}>
119
- <FilterIcon />
120
- <FormattedMessage id="app.utils.filters" />
121
- </AddFilterCta>
122
- {
123
- !isLoadingEntries && map(
124
- searchFilters,
125
- (filter) => {
126
- if (!filter.value) {
127
- return null;
128
- }
129
- const label = {
130
- ...filter,
131
- value: (isEntityFilter(filter.name)
132
- ? availableEntriesMap[filter.contentType] || []
133
- : contentsTypesOptions).find(isMatch(filter.value))?.key,
134
- };
135
- return (
136
- <FilterButton
137
- key={filter.name}
138
- onClick={onRemoveFilter(filter)}
139
- label={label}
140
- type="string"
141
- />
142
- );
143
- })
144
- }
145
- </div>
146
- </div>
147
- </>
148
- );
149
- };
150
-
151
- export default Filters;
@@ -1,82 +0,0 @@
1
- import styled from 'styled-components';
2
- import { Button, FilterIcon as Filter } from 'strapi-helper-plugin';
3
-
4
- export const FilterIcon = styled(Filter)`
5
- padding: 0 !important;
6
- margin: auto !important;
7
- > g {
8
- stroke: #282b2c;
9
- }
10
- `;
11
-
12
- export const AddFilterCta = styled(Button)`
13
- display: flex;
14
- height: 30px;
15
- margin-right: 10px;
16
- padding: 0 10px;
17
- text-align: center;
18
- background-color: #ffffff;
19
- border: 1px solid #e3e9f3;
20
- border-radius: 2px;
21
- line-height: 28px;
22
- font-size: 13px;
23
- font-weight: 500;
24
- font-family: Lato;
25
- -webkit-font-smoothing: antialiased;
26
- cursor: pointer;
27
- &:hover {
28
- background: #f7f8f8;
29
- }
30
- &:focus,
31
- &:active {
32
- outline: 0;
33
- }
34
- > span {
35
- margin-left: 10px;
36
- }
37
- `;
38
-
39
- export const Container = styled.div`
40
- padding: 18px 30px 18px 0;
41
- `;
42
-
43
- export const Wrapper = styled.div`
44
- margin-top: -6px;
45
- > div {
46
- padding-top: 2px;
47
- &:not(:first-of-type) {
48
- padding-top: 9px;
49
- padding-bottom: 2px;
50
- &:last-of-type:nth-of-type(even) {
51
- padding-bottom: 11px;
52
- }
53
- }
54
- }
55
- `;
56
-
57
- export const FiltersWrapper = styled.div`
58
- min-height: 38px;
59
- border-left: ${props => props.borderLeft && '3px solid #007EFF'};
60
- padding-left: ${props => (props.borderLeft ? '10px' : '13px')};
61
- margin-bottom: 0 !important;
62
- `;
63
-
64
- export const InputWrapper = styled.div`
65
- display: flex;
66
- input,
67
- select {
68
- margin: 0px 5px !important;
69
- }
70
- `;
71
- export const styles = {
72
- select: {
73
- minWidth: '170px',
74
- maxWidth: '200px',
75
- },
76
- selectMiddle: {
77
- minWidth: '130px',
78
- maxWidth: '200px',
79
- marginLeft: '10px',
80
- marginRight: '10px',
81
- },
82
- };
@@ -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,10 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- import { colors, sizes } from 'strapi-helper-plugin';
4
-
5
- const CardWrapper = styled.li`
6
- padding: 0;
7
- margin: 0 0 2rem 0;
8
- `;
9
-
10
- export default CardWrapper;
@@ -1,107 +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
- import { APPROVAL_STATUS } from '../../utils/constants';
13
-
14
- const Item = ({
15
- id,
16
- content,
17
- authorName,
18
- authorUser,
19
- created_at,
20
- updated_at,
21
- related,
22
- reports,
23
- blocked,
24
- blockedThread,
25
- isNew,
26
- removed,
27
- createdAt,
28
- updatedAt,
29
- relatedContentTypes,
30
- onApproveCommentClick,
31
- onRejectCommentClick,
32
- approvalStatus,
33
- }) => {
34
- const { push } = useHistory();
35
- const { getSearchParams } = useDataManager();
36
- const { id: activeId } = useParams();
37
- const parsedId = typeof activeId === 'number' ? Number(activeId) : activeId;
38
-
39
- const onClick = e => {
40
- if (!e.target.href) {
41
- e.preventDefault();
42
- push({
43
- pathname: `/plugins/${pluginId}/display/${id}`,
44
- search: generateSearchFromFilters(getSearchParams()),
45
- });
46
- }
47
- };
48
-
49
- const isAbuseReported = !isEmpty(reports);
50
- const isPending = approvalStatus === APPROVAL_STATUS.PENDING;
51
- const isItemHeaderDisplayed = blocked || blockedThread || isNew || removed || isAbuseReported || isPending;
52
- const headerProps = {
53
- blocked,
54
- blockedThread,
55
- isNew,
56
- isAbuseReported,
57
- isRemoved: removed,
58
- onApproveCommentClick,
59
- onRejectCommentClick,
60
- approvalStatus,
61
- };
62
-
63
- const footerProps = {
64
- authorName,
65
- authorUser,
66
- related: isArray(related) ? first(related) : related,
67
- created_at: created_at || createdAt,
68
- updated_at: updated_at || updatedAt,
69
- relatedContentTypes
70
- };
71
-
72
- return (
73
- <CardWrapper>
74
- <CardItem
75
- onClick={onClick}
76
- active={id === parsedId}
77
- >
78
- {isItemHeaderDisplayed && (<ItemHeader { ...headerProps } />) }
79
- <p>{content}</p>
80
- <ItemFooter {...footerProps} />
81
- </CardItem>
82
- </CardWrapper>
83
- );
84
- };
85
-
86
- Item.propTypes = {
87
- id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
88
- content: PropTypes.string.isRequired,
89
- authorName: PropTypes.string,
90
- authorUser: PropTypes.object,
91
- created_at: PropTypes.string.isRequired,
92
- updated_at: PropTypes.string,
93
- related: PropTypes.array,
94
- reports: PropTypes.array,
95
- blocked: PropTypes.bool,
96
- blockedThread: PropTypes.bool,
97
- isNew: PropTypes.bool,
98
- approvalStatus: PropTypes.oneOf([
99
- APPROVAL_STATUS.APPROVED,
100
- APPROVAL_STATUS.PENDING,
101
- APPROVAL_STATUS
102
- ]),
103
- onApproveCommentClick: PropTypes.func,
104
- onRejectCommentClick: PropTypes.func,
105
- };
106
-
107
- 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;