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.
Files changed (154) hide show
  1. package/.circleci/config.yml +2 -2
  2. package/README.md +70 -109
  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 -33
  44. package/admin/src/pluginId.js +2 -4
  45. package/admin/src/reducers.js +8 -0
  46. package/admin/src/translations/en.json +73 -33
  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 +28 -0
  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 +7 -9
  79. package/{services → server/services}/utils/functions.js +19 -8
  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 -92
  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 -151
  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/CardHeaderReports.js +0 -40
  116. package/admin/src/components/ItemHeader/Wrapper.js +0 -16
  117. package/admin/src/components/ItemHeader/index.js +0 -80
  118. package/admin/src/components/ItemModeration/Wrapper.js +0 -19
  119. package/admin/src/components/ItemModeration/index.js +0 -47
  120. package/admin/src/components/List/Container.js +0 -20
  121. package/admin/src/components/List/index.js +0 -21
  122. package/admin/src/components/Search/index.js +0 -83
  123. package/admin/src/containers/App/Wrapper.js +0 -14
  124. package/admin/src/containers/App/index.js +0 -47
  125. package/admin/src/containers/DataManagerProvider/actions.js +0 -11
  126. package/admin/src/containers/DataManagerProvider/index.js +0 -280
  127. package/admin/src/containers/DataManagerProvider/init.js +0 -5
  128. package/admin/src/containers/DataManagerProvider/reducer.js +0 -59
  129. package/admin/src/containers/DetailsView/Wrapper.js +0 -18
  130. package/admin/src/containers/DetailsView/index.js +0 -100
  131. package/admin/src/containers/ListView/FadedWrapper.js +0 -42
  132. package/admin/src/containers/ListView/Footer.js +0 -53
  133. package/admin/src/containers/ListView/Wrapper.js +0 -17
  134. package/admin/src/containers/ListView/components.js +0 -138
  135. package/admin/src/containers/ListView/index.js +0 -45
  136. package/admin/src/containers/Panel/actions.js +0 -5
  137. package/admin/src/containers/Panel/index.js +0 -191
  138. package/admin/src/containers/Panel/index.styled.js +0 -6
  139. package/admin/src/containers/Panel/reducer.js +0 -44
  140. package/admin/src/contexts/DataManagerContext.js +0 -5
  141. package/admin/src/hooks/useDataManager.js +0 -6
  142. package/admin/src/lifecycles.js +0 -3
  143. package/admin/src/translations/index.js +0 -7
  144. package/admin/src/utils/getTrad.js +0 -5
  145. package/admin/src/utils/getTradId.js +0 -5
  146. package/config/functions/bootstrap.js +0 -48
  147. package/config/routes.json +0 -116
  148. package/config/schema.graphql.js +0 -270
  149. package/controllers/comments.js +0 -211
  150. package/models/comment.js +0 -8
  151. package/models/comment.settings.json +0 -98
  152. package/models/report.js +0 -8
  153. package/models/report.settings.json +0 -49
  154. package/services/comments.js +0 -486
@@ -1,63 +0,0 @@
1
- import { colors } from 'strapi-helper-plugin';
2
-
3
- import styled from 'styled-components';
4
-
5
- const TableContainer = styled.div`
6
- table {
7
- thead {
8
- tr {
9
- border-bottom: 1px ${colors.grey} solid;
10
-
11
- td {
12
- background: transparent;
13
-
14
- &:first-child {
15
- padding-left: 0;
16
- }
17
-
18
- &:last-child {
19
- padding-right: 0;
20
- }
21
- }
22
- }
23
- }
24
-
25
- tbody {
26
- tr {
27
- background-color: white;
28
-
29
- td {
30
- &:first-child {
31
- padding-left: 0;
32
- }
33
-
34
- &:last-child {
35
- padding-right: 0;
36
- }
37
- }
38
-
39
- &:last-child {
40
- border-bottom: 0;
41
- }
42
-
43
- &:hover {
44
- background-color: white;
45
-
46
- cursor: default;
47
- }
48
- }
49
- }
50
-
51
- p {
52
- margin: 0;
53
- padding: 0;
54
- }
55
- }
56
-
57
- &>div {
58
- box-shadow: none;
59
- border: 0;
60
- }
61
- `;
62
-
63
- export default TableContainer;
@@ -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,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;