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,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 CardHeaderIndicatorRed = styled(CardHeaderIndicator)`
|
|
7
|
-
color: ${colors.beige};
|
|
8
|
-
background: red;
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
export default CardHeaderIndicatorRed;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const CardHeaderIndicatorsContainer = styled.span`
|
|
6
|
-
display: flex;
|
|
7
|
-
height: 1.8rem;
|
|
8
|
-
|
|
9
|
-
position: absolute;
|
|
10
|
-
top: -.9rem;
|
|
11
|
-
right: -.9rem;
|
|
12
|
-
|
|
13
|
-
font-size: 1rem;
|
|
14
|
-
color: ${colors.beige};
|
|
15
|
-
line-height: 1.8rem;
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
export default CardHeaderIndicatorsContainer;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { colors } from 'strapi-helper-plugin';
|
|
4
|
-
|
|
5
|
-
const CardHeaderReports = styled.a`
|
|
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: red;
|
|
15
|
-
text-decoration: none;
|
|
16
|
-
|
|
17
|
-
border: 1px dotted red;
|
|
18
|
-
border-radius: 1.25rem;
|
|
19
|
-
background: transparent;
|
|
20
|
-
|
|
21
|
-
transition: .25s ease-in-out all;
|
|
22
|
-
|
|
23
|
-
svg {
|
|
24
|
-
margin-right: .5rem;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&:hover {
|
|
28
|
-
color: ${colors.beige};
|
|
29
|
-
text-decoration: none;
|
|
30
|
-
|
|
31
|
-
border-style: solid;
|
|
32
|
-
background: red;
|
|
33
|
-
|
|
34
|
-
transform: translateY(-.25rem);
|
|
35
|
-
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
|
-
export default CardHeaderReports;
|
|
@@ -1,16 +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: row;
|
|
8
|
-
justify-content: space-between;
|
|
9
|
-
margin-bottom: ${props => props.hasMargin ? '1rem' : 0};
|
|
10
|
-
|
|
11
|
-
color: ${colors.leftMenu.grey};
|
|
12
|
-
font-size: 1.25rem;
|
|
13
|
-
font-weight: 500;
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
export default Wrapper;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { FormattedMessage } from 'react-intl';
|
|
4
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
-
import { useGlobalContext, CheckPermissions } from 'strapi-helper-plugin';
|
|
6
|
-
import { faLock, faStream, faAsterisk, faFire } from '@fortawesome/free-solid-svg-icons';
|
|
7
|
-
import Wrapper from './Wrapper';
|
|
8
|
-
import CardHeaderBlocked from './CardHeaderBlocked';
|
|
9
|
-
import pluginId from '../../pluginId';
|
|
10
|
-
import CardHeaderIndicatorsContainer from './CardHeaderIndicatorsContainer';
|
|
11
|
-
import CardHeaderIndicatorBlue from './CardHeaderIndicatorBlue';
|
|
12
|
-
import CardHeaderIndicatorRed from './CardHeaderIndicatorRed';
|
|
13
|
-
import CardHeaderReports from './CardHeaderReports';
|
|
14
|
-
import pluginPermissions from '../../permissions';
|
|
15
|
-
|
|
16
|
-
const ItemHeader = ({ active, isDelailedView, blocked, blockedThread, isNew, isAbuseReported, isRemoved, abuseReports, onReportsClick }) => {
|
|
17
|
-
const { formatMessage } = useGlobalContext();
|
|
18
|
-
const isBlocked = blocked || blockedThread;
|
|
19
|
-
const hasAnyIndicators = isNew || (isAbuseReported && !isDelailedView);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<Wrapper hasMargin={isBlocked || isRemoved || (isAbuseReported && isDelailedView)}>
|
|
23
|
-
{ isBlocked && (
|
|
24
|
-
<CheckPermissions permissions={pluginPermissions.moderate}>
|
|
25
|
-
<CardHeaderBlocked>
|
|
26
|
-
<FontAwesomeIcon icon={faLock} />
|
|
27
|
-
{blockedThread && <FontAwesomeIcon icon={faStream} />}
|
|
28
|
-
<FormattedMessage id={`${pluginId}.list.item.header.blocked${blockedThread ? '.thread' : ''}`} />
|
|
29
|
-
</CardHeaderBlocked>
|
|
30
|
-
</CheckPermissions>
|
|
31
|
-
) }
|
|
32
|
-
{
|
|
33
|
-
isRemoved && (
|
|
34
|
-
<CheckPermissions permissions={pluginPermissions.moderate}>
|
|
35
|
-
<CardHeaderBlocked>
|
|
36
|
-
<FontAwesomeIcon icon={faLock} />
|
|
37
|
-
{blockedThread && <FontAwesomeIcon icon={faStream} />}
|
|
38
|
-
<FormattedMessage id={`${pluginId}.list.item.header.removed`} />
|
|
39
|
-
</CardHeaderBlocked>
|
|
40
|
-
</CheckPermissions>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
{ (isDelailedView && active) && (<>
|
|
44
|
-
{ isAbuseReported && (
|
|
45
|
-
<CheckPermissions permissions={pluginPermissions.moderateReports}>
|
|
46
|
-
<CardHeaderReports href="#abuse-reports" onClick={onReportsClick}>
|
|
47
|
-
<FontAwesomeIcon icon={faFire} />
|
|
48
|
-
<FormattedMessage id={`${pluginId}.list.item.header.abuse`} values={{ count: abuseReports.length }} />
|
|
49
|
-
</CardHeaderReports>
|
|
50
|
-
</CheckPermissions>
|
|
51
|
-
)}
|
|
52
|
-
</>)}
|
|
53
|
-
{hasAnyIndicators && <CardHeaderIndicatorsContainer>
|
|
54
|
-
{ isNew && (<CardHeaderIndicatorBlue title={formatMessage({ id: `${pluginId}.list.item.indication.new`})}>
|
|
55
|
-
<FontAwesomeIcon icon={faAsterisk} />
|
|
56
|
-
</CardHeaderIndicatorBlue>) }
|
|
57
|
-
<CheckPermissions permissions={pluginPermissions.moderateReports}>
|
|
58
|
-
{ isAbuseReported && (<CardHeaderIndicatorRed title={formatMessage({ id: `${pluginId}.list.item.indication.abuse`})}>
|
|
59
|
-
<FontAwesomeIcon icon={faFire} />
|
|
60
|
-
</CardHeaderIndicatorRed>) }
|
|
61
|
-
</CheckPermissions>
|
|
62
|
-
</CardHeaderIndicatorsContainer>
|
|
63
|
-
}
|
|
64
|
-
</Wrapper>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
ItemHeader.propTypes = {
|
|
69
|
-
active: PropTypes.bool,
|
|
70
|
-
isDelailedView: PropTypes.bool,
|
|
71
|
-
blocked: PropTypes.bool,
|
|
72
|
-
blockedThread: PropTypes.bool,
|
|
73
|
-
isNew: PropTypes.bool,
|
|
74
|
-
removed: PropTypes.bool,
|
|
75
|
-
isAbuseReported: PropTypes.bool,
|
|
76
|
-
abuseReports: PropTypes.array,
|
|
77
|
-
onReportsClick: PropTypes.func,
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export default ItemHeader;
|
|
@@ -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';
|