strapi-plugin-comments 2.2.0 → 2.2.2-beta.1

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 (47) hide show
  1. package/README.md +2 -2
  2. package/admin/src/components/ActionButton/styles.d.ts +1 -1
  3. package/admin/src/components/AdminAvatar/index.d.ts +4 -0
  4. package/admin/src/components/AdminAvatar/index.js +17 -0
  5. package/admin/src/components/AdminAvatar/styles.d.ts +3 -0
  6. package/admin/src/components/AdminAvatar/styles.js +17 -0
  7. package/admin/src/components/Avatar/index.d.ts +8 -11
  8. package/admin/src/components/Avatar/index.js +7 -8
  9. package/admin/src/components/DiscussionThreadItem/styles.d.ts +3 -3
  10. package/admin/src/components/DiscussionThreadItemActions/styles.d.ts +1 -1
  11. package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.d.ts +1 -1
  12. package/admin/src/components/DiscussionThreadItemFooter/styles.d.ts +2 -2
  13. package/admin/src/components/FormSwitch/styles.d.ts +1 -1
  14. package/admin/src/components/IconButton/styles.d.ts +1 -1
  15. package/admin/src/components/LoadingIndicatorOverlay/styles.d.ts +2 -2
  16. package/admin/src/components/ModeratorResponse/styles.d.ts +1 -1
  17. package/admin/src/components/PreviewWysiwyg/Wrapper.d.ts +1 -1
  18. package/admin/src/components/StatusBadge/styles.d.ts +1 -1
  19. package/admin/src/components/Wysiwyg/EditorLayout.d.ts +1 -1
  20. package/admin/src/components/Wysiwyg/EditorStylesContainer.d.ts +1 -1
  21. package/admin/src/components/Wysiwyg/WysiwygStyles.d.ts +7 -7
  22. package/admin/src/components/icons/strapiIcons.d.ts +1 -0
  23. package/admin/src/components/icons/strapiIcons.js +2 -1
  24. package/admin/src/pages/Details/components/DetailsFilters/styles.d.ts +1 -1
  25. package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +12 -11
  26. package/admin/src/pages/Discover/components/DiscoverTableRow/styles.d.ts +1 -1
  27. package/admin/src/pages/Discover/utils/filtersSchema.d.ts +17 -2
  28. package/admin/src/pages/Discover/utils/filtersSchema.js +28 -0
  29. package/admin/src/pages/Reports/components/ReportsTableRow/styles.d.ts +1 -1
  30. package/admin/src/pages/Reports/utils/filtersSchema.d.ts +17 -2
  31. package/admin/src/pages/Reports/utils/filtersSchema.js +21 -0
  32. package/admin/src/pages/Settings/components/RestartAlert/styles.d.ts +1 -1
  33. package/content-types/comment.d.ts +4 -0
  34. package/content-types/comment.js +4 -0
  35. package/content-types/index.d.ts +4 -0
  36. package/package.json +7 -5
  37. package/server/controllers/utils/parsers.js +21 -1
  38. package/server/graphql/queries/findAllInHierarchy.d.ts +1 -0
  39. package/server/graphql/queries/findAllInHierarchy.js +2 -0
  40. package/server/services/admin.js +3 -2
  41. package/server/services/client.js +4 -1
  42. package/server/services/graphql.js +29 -4
  43. package/server/services/utils/functions.d.ts +2 -1
  44. package/server/services/utils/functions.js +9 -1
  45. package/strapi-server.d.ts +4 -0
  46. package/tsconfig.tsbuildinfo +1 -1
  47. package/types/contentTypes.d.ts +1 -0
package/README.md CHANGED
@@ -127,14 +127,14 @@ Complete installation requirements are exact same as for Strapi itself and can b
127
127
 
128
128
  **Minimum environment requirements**
129
129
 
130
- - Node.js `>=14.x.x`
130
+ - Node.js `>=14.19.1 <=18.x.x`
131
131
  - NPM `>=7.x.x`
132
132
 
133
133
  In our minimum support we're following [official Node.js releases timelines](https://nodejs.org/en/about/releases/).
134
134
 
135
135
  **Supported Strapi versions**:
136
136
 
137
- - Strapi v4.4.3 (recently tested)
137
+ - Strapi v4.5.2 (recently tested)
138
138
  - Strapi v4.x
139
139
 
140
140
  > This plugin is designed for **Strapi v4** and is not working with v3.x. To get version for **Strapi v3** install version [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/tree/strapi-v3).
@@ -1,2 +1,2 @@
1
- export declare const ActionButton: any;
1
+ export declare const ActionButton: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ declare const AdminAvatar: React.FC<React.PropsWithChildren<{}>>;
3
+ export default AdminAvatar;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const styles_1 = require("./styles");
8
+ const icons_1 = require("@strapi/icons");
9
+ const Icon_1 = require("@strapi/design-system/Icon");
10
+ const AdminAvatar = ({ children }) => {
11
+ return (react_1.default.createElement(styles_1.AdminAvatarWrapper, null,
12
+ react_1.default.createElement(styles_1.AdminShield, null,
13
+ react_1.default.createElement(Icon_1.Icon, { as: icons_1.Shield, color: "neutral800" })),
14
+ children));
15
+ };
16
+ exports.default = AdminAvatar;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ export declare const AdminAvatarWrapper: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
+ export declare const AdminShield: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
3
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AdminShield = exports.AdminAvatarWrapper = void 0;
7
+ const styled_components_1 = __importDefault(require("styled-components"));
8
+ const Box_1 = require("@strapi/design-system/Box");
9
+ exports.AdminAvatarWrapper = (0, styled_components_1.default)(Box_1.Box) `
10
+ position: relative;
11
+ `;
12
+ exports.AdminShield = (0, styled_components_1.default)(Box_1.Box) `
13
+ position: absolute;
14
+ right: -30%;
15
+ top: -30%;
16
+ `;
17
+ //# sourceMappingURL=styles.js.map
@@ -1,13 +1,10 @@
1
- import PropTypes from "prop-types";
2
- declare const UserAvatar: {
3
- ({ avatar, name }: {
4
- avatar: any;
5
- name: any;
6
- }): any;
7
- propTypes: {
8
- avatar: PropTypes.Validator<any>;
9
- name: PropTypes.Requireable<string>;
10
- };
11
- };
1
+ import React from "react";
2
+ import { ToBeFixed } from "../../../../types";
3
+ interface IProps {
4
+ avatar: string | ToBeFixed;
5
+ name: string;
6
+ isAdminComment?: boolean;
7
+ }
8
+ declare const UserAvatar: React.FC<IProps>;
12
9
  export default UserAvatar;
13
10
  //# sourceMappingURL=index.d.ts.map
@@ -4,23 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const prop_types_1 = __importDefault(require("prop-types"));
8
7
  const lodash_1 = require("lodash");
9
8
  const Avatar_1 = require("@strapi/design-system/Avatar");
10
9
  const utils_1 = require("../../utils");
11
- const UserAvatar = ({ avatar, name }) => {
10
+ const AdminAvatar_1 = __importDefault(require("../AdminAvatar"));
11
+ ;
12
+ const UserAvatar = ({ avatar, name, isAdminComment = false }) => {
12
13
  if (avatar) {
13
14
  let image = avatar;
14
15
  if ((0, lodash_1.isObject)(avatar)) {
15
16
  image = avatar?.formats?.thumbnail.url || avatar.url;
16
17
  }
17
- return image && (react_1.default.createElement(Avatar_1.Avatar, { src: image, alt: name }));
18
+ return (isAdminComment ? react_1.default.createElement(AdminAvatar_1.default, null, image && (react_1.default.createElement(Avatar_1.Avatar, { src: image, alt: name })))
19
+ : image && (react_1.default.createElement(Avatar_1.Avatar, { src: image, alt: name })));
18
20
  }
19
- return name && (react_1.default.createElement(Avatar_1.Initials, null, (0, utils_1.renderInitials)(name)));
20
- };
21
- UserAvatar.propTypes = {
22
- avatar: prop_types_1.default.oneOfType(prop_types_1.default.string, prop_types_1.default.object).isRequired,
23
- name: prop_types_1.default.string,
21
+ return (isAdminComment ? react_1.default.createElement(AdminAvatar_1.default, null, name && (react_1.default.createElement(Avatar_1.Initials, null, (0, utils_1.renderInitials)(name))))
22
+ : name && (react_1.default.createElement(Avatar_1.Initials, null, (0, utils_1.renderInitials)(name))));
24
23
  };
25
24
  exports.default = UserAvatar;
26
25
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export declare const DiscussionThreadFullsize: any;
2
- export declare const DiscussionThreadItemContent: any;
3
- export declare const DiscussionThreadItemContainer: any;
1
+ export declare const DiscussionThreadFullsize: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
+ export declare const DiscussionThreadItemContent: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
3
+ export declare const DiscussionThreadItemContainer: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
4
4
  //# sourceMappingURL=styles.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const DiscussionThreadItemActionsWrapper: any;
1
+ export declare const DiscussionThreadItemActionsWrapper: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const DiscussionThreadItemActionsGroupWrapper: any;
1
+ export declare const DiscussionThreadItemActionsGroupWrapper: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -1,3 +1,3 @@
1
- export declare const DiscussionThreadItemFooterStyled: any;
2
- export declare const DiscussionThreadItemFooterMeta: any;
1
+ export declare const DiscussionThreadItemFooterStyled: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
+ export declare const DiscussionThreadItemFooterMeta: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
3
3
  //# sourceMappingURL=styles.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const StyledSwitch: any;
1
+ export declare const StyledSwitch: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const IconButtonGroupStyled: any;
1
+ export declare const IconButtonGroupStyled: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -1,3 +1,3 @@
1
- export declare const LoadingIndicatorOverlayWrapper: any;
2
- export declare const LoadingIndicatorContainer: any;
1
+ export declare const LoadingIndicatorOverlayWrapper: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
+ export declare const LoadingIndicatorContainer: import("styled-components").StyledComponent<(props: any) => any, any, {}, never>;
3
3
  //# sourceMappingURL=styles.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const ModeratorResponseStyled: any;
1
+ export declare const ModeratorResponseStyled: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -1,3 +1,3 @@
1
- declare const Wrapper: any;
1
+ declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
2
  export default Wrapper;
3
3
  //# sourceMappingURL=Wrapper.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const StatusBadge: any;
1
+ export declare const StatusBadge: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare const ExpandButton: any;
2
+ export declare const ExpandButton: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
3
3
  declare type EditorLayoutProps = {
4
4
  children: React.ReactNode;
5
5
  error: string | undefined;
@@ -1,2 +1,2 @@
1
- export declare const EditorStylesContainer: any;
1
+ export declare const EditorStylesContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
2
2
  //# sourceMappingURL=EditorStylesContainer.d.ts.map
@@ -1,8 +1,8 @@
1
- export declare const CustomIconButton: any;
2
- export declare const CustomLinkIconButton: any;
3
- export declare const MainButtons: any;
4
- export declare const MoreButton: any;
5
- export declare const IconButtonGroupMargin: any;
6
- export declare const EditorAndPreviewWrapper: any;
7
- export declare const ExpandButton: any;
1
+ export declare const CustomIconButton: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
+ export declare const CustomLinkIconButton: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
3
+ export declare const MainButtons: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
4
+ export declare const MoreButton: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
5
+ export declare const IconButtonGroupMargin: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
6
+ export declare const EditorAndPreviewWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
7
+ export declare const ExpandButton: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
8
8
  //# sourceMappingURL=WysiwygStyles.d.ts.map
@@ -21,4 +21,5 @@ export declare const comments: JSX.Element;
21
21
  export declare const trash: JSX.Element;
22
22
  export declare const pencil: JSX.Element;
23
23
  export declare const plus: JSX.Element;
24
+ export declare const shield: JSX.Element;
24
25
  //# sourceMappingURL=strapiIcons.d.ts.map
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.plus = exports.pencil = exports.trash = exports.comments = exports.unlock = exports.lock = exports.review = exports.refresh = exports.play = exports.information = exports.illo = exports.filter = exports.eye = exports.exclamationMarkCircle = exports.emptyPictures = exports.cross = exports.check = exports.carretDown = exports.arrowUp = exports.arrowRight = exports.arrowLeft = exports.apps = void 0;
6
+ exports.shield = exports.plus = exports.pencil = exports.trash = exports.comments = exports.unlock = exports.lock = exports.review = exports.refresh = exports.play = exports.information = exports.illo = exports.filter = exports.eye = exports.exclamationMarkCircle = exports.emptyPictures = exports.cross = exports.check = exports.carretDown = exports.arrowUp = exports.arrowRight = exports.arrowLeft = exports.apps = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const icons_1 = require("@strapi/icons");
9
9
  const review_1 = __importDefault(require("./review"));
@@ -32,4 +32,5 @@ exports.comments = react_1.default.createElement(comments_1.default, null);
32
32
  exports.trash = react_1.default.createElement(icons_1.Trash, null);
33
33
  exports.pencil = react_1.default.createElement(icons_1.Pencil, null);
34
34
  exports.plus = react_1.default.createElement(icons_1.Plus, null);
35
+ exports.shield = react_1.default.createElement(icons_1.Shield, null);
35
36
  //# sourceMappingURL=strapiIcons.js.map
@@ -1,2 +1,2 @@
1
- export declare const TableLink: any;
1
+ export declare const TableLink: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -47,24 +47,25 @@ const DiscoverTableRow = ({ config, item, allowedActions: { canModerate, canAcce
47
47
  if (reviewFlowEnabled || needsApproval) {
48
48
  actionItemsCount = 2;
49
49
  }
50
- return (react_1.default.createElement(Table_1.Tr, { key: item.id },
50
+ const { author, isAdminComment, id, content, threadOf, related, createdAt, updatedAt } = item;
51
+ return (react_1.default.createElement(Table_1.Tr, { key: id },
51
52
  react_1.default.createElement(Table_1.Td, null,
52
53
  react_1.default.createElement(Typography_1.Typography, { textColor: "neutral800", fontWeight: "bold" },
53
54
  "#",
54
- item.id)),
55
+ id)),
55
56
  react_1.default.createElement(Table_1.Td, null,
56
57
  react_1.default.createElement(Stack_1.Stack, { size: 2, horizontal: true },
57
- item.author && (react_1.default.createElement(Avatar_1.default, { avatar: item?.author?.avatar, name: item?.author?.name })),
58
- react_1.default.createElement(Typography_1.Typography, { textColor: "neutral800", variant: "pi" }, item?.author?.name || (0, utils_1.getMessage)('compontents.author.unknown')))),
58
+ author && (react_1.default.createElement(Avatar_1.default, { avatar: author.avatar, name: author.name, isAdminComment: isAdminComment })),
59
+ react_1.default.createElement(Typography_1.Typography, { textColor: "neutral800", variant: "pi" }, author?.name || (0, utils_1.getMessage)('compontents.author.unknown')))),
59
60
  react_1.default.createElement(Table_1.Td, { style: { maxWidth: "30vw" } },
60
- react_1.default.createElement(Typography_1.Typography, { textColor: "neutral800", ellipsis: true }, item.content)),
61
- react_1.default.createElement(Table_1.Td, null, item.threadOf?.id ? (react_1.default.createElement(Link_1.Link, { to: renderDetailsUrl(item.threadOf) }, (0, utils_1.getMessage)({
61
+ react_1.default.createElement(Typography_1.Typography, { textColor: "neutral800", ellipsis: true }, content)),
62
+ react_1.default.createElement(Table_1.Td, null, threadOf?.id ? (react_1.default.createElement(Link_1.Link, { to: renderDetailsUrl(threadOf) }, (0, utils_1.getMessage)({
62
63
  id: "page.discover.table.cell.thread",
63
- props: { id: item.threadOf.id },
64
- }, "#" + item.threadOf.id))) : ("-")),
65
- react_1.default.createElement(Table_1.Td, { style: { maxWidth: "15vw" } }, item.related ? (react_1.default.createElement(styles_1.TableLink, { to: renderEntryUrl(item.related) }, (0, renderEntryTitle_1.default)(item.related, config))) : ("-")),
64
+ props: { id: threadOf.id },
65
+ }, "#" + threadOf.id))) : ("-")),
66
+ react_1.default.createElement(Table_1.Td, { style: { maxWidth: "15vw" } }, related ? (react_1.default.createElement(styles_1.TableLink, { to: renderEntryUrl(related) }, (0, renderEntryTitle_1.default)(related, config))) : ("-")),
66
67
  react_1.default.createElement(Table_1.Td, null,
67
- react_1.default.createElement(Typography_1.Typography, { textColor: "neutral800" }, formatDate(item.updatedAt || item.createdAt, {
68
+ react_1.default.createElement(Typography_1.Typography, { textColor: "neutral800" }, formatDate(updatedAt || createdAt, {
68
69
  dateStyle: "long",
69
70
  timeStyle: "short",
70
71
  }))),
@@ -73,7 +74,7 @@ const DiscoverTableRow = ({ config, item, allowedActions: { canModerate, canAcce
73
74
  react_1.default.createElement(Table_1.Td, null,
74
75
  react_1.default.createElement(Flex_1.Flex, { direction: "column", alignItems: "flex-end" },
75
76
  react_1.default.createElement(styles_2.IconButtonGroupStyled, { isSingle: !(reviewFlowEnabled || (canModerate && needsApproval)) },
76
- canModerate && needsApproval && (react_1.default.createElement(DiscussionThreadItemApprovalFlowActions_1.default, { id: item.id, allowedActions: { canModerate } })),
77
+ canModerate && needsApproval && (react_1.default.createElement(DiscussionThreadItemApprovalFlowActions_1.default, { id: id, allowedActions: { canModerate } })),
77
78
  react_1.default.createElement(DiscussionThreadItemReviewAction_1.default, { item: item, queryToInvalidate: "get-data", allowedActions: {
78
79
  canModerate,
79
80
  canAccessReports,
@@ -1,2 +1,2 @@
1
- export declare const TableLink: any;
1
+ export declare const TableLink: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -1,11 +1,26 @@
1
- declare const filtersSchema: {
1
+ declare const filtersSchema: ({
2
2
  name: string;
3
3
  metadatas: {
4
4
  label: string;
5
5
  };
6
6
  fieldSchema: {
7
7
  type: string;
8
+ mainField?: undefined;
8
9
  };
9
- }[];
10
+ } | {
11
+ name: string;
12
+ metadatas: {
13
+ label: string;
14
+ };
15
+ fieldSchema: {
16
+ type: string;
17
+ mainField: {
18
+ name: string;
19
+ schema: {
20
+ type: string;
21
+ };
22
+ };
23
+ };
24
+ })[];
10
25
  export default filtersSchema;
11
26
  //# sourceMappingURL=filtersSchema.d.ts.map
@@ -6,6 +6,34 @@ const filtersSchema = [
6
6
  metadatas: { label: "Message" },
7
7
  fieldSchema: { type: "string" },
8
8
  },
9
+ {
10
+ name: "createdAt",
11
+ metadatas: { label: "CreatedAt" },
12
+ fieldSchema: { type: "datetime" },
13
+ },
14
+ {
15
+ name: "updatedAt",
16
+ metadatas: { label: "UpdatedAt" },
17
+ fieldSchema: { type: "datetime" },
18
+ },
19
+ {
20
+ name: "authorName",
21
+ metadatas: { label: "Author" },
22
+ fieldSchema: { type: "string" },
23
+ },
24
+ {
25
+ name: "threadOf",
26
+ metadatas: { label: "threadOf" },
27
+ fieldSchema: {
28
+ type: "relation",
29
+ mainField: {
30
+ name: "id",
31
+ schema: {
32
+ type: "number"
33
+ }
34
+ }
35
+ }
36
+ }
9
37
  ];
10
38
  exports.default = filtersSchema;
11
39
  //# sourceMappingURL=filtersSchema.js.map
@@ -1,2 +1,2 @@
1
- export declare const TableLink: any;
1
+ export declare const TableLink: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -1,11 +1,26 @@
1
- declare const filtersSchema: {
1
+ declare const filtersSchema: ({
2
2
  name: string;
3
3
  metadatas: {
4
4
  label: string;
5
5
  };
6
6
  fieldSchema: {
7
7
  type: string;
8
+ mainField?: undefined;
8
9
  };
9
- }[];
10
+ } | {
11
+ name: string;
12
+ metadatas: {
13
+ label: string;
14
+ };
15
+ fieldSchema: {
16
+ type: string;
17
+ mainField: {
18
+ name: string;
19
+ schema: {
20
+ type: string;
21
+ };
22
+ };
23
+ };
24
+ })[];
10
25
  export default filtersSchema;
11
26
  //# sourceMappingURL=filtersSchema.d.ts.map
@@ -6,6 +6,27 @@ const filtersSchema = [
6
6
  metadatas: { label: 'Message' },
7
7
  fieldSchema: { type: 'string' },
8
8
  },
9
+ {
10
+ name: 'reason',
11
+ metadatas: { label: 'Reason' },
12
+ fieldSchema: { type: 'enum' },
13
+ }, {
14
+ name: 'resolved',
15
+ metadatas: { label: 'Resolved' },
16
+ fieldSchema: { type: 'boolean' },
17
+ }, {
18
+ name: 'related',
19
+ metadatas: { label: 'Comment author' },
20
+ fieldSchema: {
21
+ type: "relation",
22
+ mainField: {
23
+ name: "authorName",
24
+ schema: {
25
+ type: "string"
26
+ }
27
+ }
28
+ }
29
+ },
9
30
  ];
10
31
  exports.default = filtersSchema;
11
32
  //# sourceMappingURL=filtersSchema.js.map
@@ -1,2 +1,2 @@
1
- export declare const RestartAlert: any;
1
+ export declare const RestartAlert: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
2
2
  //# sourceMappingURL=styles.d.ts.map
@@ -60,6 +60,10 @@ declare const _default: {
60
60
  type: string;
61
61
  configurable: boolean;
62
62
  };
63
+ isAdminComment: {
64
+ type: string;
65
+ configurable: boolean;
66
+ };
63
67
  removed: {
64
68
  type: string;
65
69
  configurable: boolean;
@@ -62,6 +62,10 @@ exports.default = {
62
62
  type: "string",
63
63
  configurable: false,
64
64
  },
65
+ isAdminComment: {
66
+ type: "boolean",
67
+ configurable: false,
68
+ },
65
69
  removed: {
66
70
  type: "boolean",
67
71
  configurable: false,
@@ -62,6 +62,10 @@ declare const _default: {
62
62
  type: string;
63
63
  configurable: boolean;
64
64
  };
65
+ isAdminComment: {
66
+ type: string;
67
+ configurable: boolean;
68
+ };
65
69
  removed: {
66
70
  type: string;
67
71
  configurable: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-comments",
3
- "version": "2.2.0",
3
+ "version": "2.2.2-beta.1",
4
4
  "description": "Strapi - Comments plugin",
5
5
  "strapi": {
6
6
  "name": "comments",
@@ -14,12 +14,14 @@
14
14
  "url": "https://github.com/VirtusLab-Open-Source/strapi-plugin-comments"
15
15
  },
16
16
  "dependencies": {
17
- "@strapi/plugin-graphql": "^4.4.3",
18
- "@strapi/utils": "^4.4.3",
17
+ "@strapi/plugin-graphql": "^4.5.2",
18
+ "@strapi/utils": "^4.5.2",
19
19
  "@types/axios": "^0.14.0",
20
20
  "@types/react-intl": "^3.0.0",
21
21
  "@types/react-query": "^1.2.9",
22
- "bad-words": "^3.0.4"
22
+ "@types/styled-components": "^5.1.26",
23
+ "bad-words": "^3.0.4",
24
+ "styled-components": "^5.3.6"
23
25
  },
24
26
  "devDependencies": {},
25
27
  "peerDependencies": {
@@ -56,7 +58,7 @@
56
58
  }
57
59
  ],
58
60
  "engines": {
59
- "node": ">=14.19.1 <=17.x.x",
61
+ "node": ">=14.19.1 <=18.x.x",
60
62
  "npm": ">=7.x.x"
61
63
  },
62
64
  "keywords": [
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.flatInput = void 0;
7
+ const error_1 = __importDefault(require("../../utils/error"));
8
+ const functions_1 = require("../../utils/functions");
4
9
  const flatInput = (payload) => {
5
10
  const { relation, query, sort, pagination, fields } = payload;
6
- const { populate = {}, ...restQuery } = query;
11
+ const { populate = {}, filterBy, filterByValue, ...restQuery } = query;
7
12
  const filters = restQuery?.filters || restQuery;
8
13
  const orOperator = (filters?.$or || []).filter((_) => !Object.keys(_).includes("removed"));
9
14
  let basePopulate = {
@@ -32,6 +37,21 @@ const flatInput = (payload) => {
32
37
  },
33
38
  };
34
39
  }
40
+ if (filterBy === "DATE_CREATED") {
41
+ const date = new Date(filterByValue);
42
+ if (!filterByValue || Number.isNaN(+date)) {
43
+ throw new error_1.default(400, 'Invalid date specified in "filterByValue"');
44
+ }
45
+ const start = date.setHours(0, 0, 0, 0);
46
+ const end = date.setHours(23, 59, 59, 999);
47
+ filters.createdAt = {
48
+ $between: [start, end],
49
+ };
50
+ }
51
+ if (filterBy === "APPROVAL_STATUS") {
52
+ (0, functions_1.assertNotEmpty)(filterByValue, new error_1.default(400, 'Empty "filterByValue" parameter'));
53
+ filters.approvalStatus = filterByValue;
54
+ }
35
55
  return {
36
56
  query: {
37
57
  ...filters,
@@ -10,6 +10,7 @@ declare const _default: ({ strapi, nexus }: StrapiGraphQLContext) => {
10
10
  args: {
11
11
  relation: any;
12
12
  sort: any;
13
+ filters: any;
13
14
  };
14
15
  resolve(obj: Object, args: findAllInHierarchyProps): Promise<import("../../../types").Comment<import("../../../types").CommentAuthor>[]>;
15
16
  };
@@ -9,11 +9,13 @@ module.exports = ({ strapi, nexus }) => {
9
9
  const { nonNull, list, stringArg } = nexus;
10
10
  const { service: getService } = strapi.plugin("graphql");
11
11
  const { args } = getService("internals");
12
+ const { naming: { getFiltersInputTypeName }, } = getService("utils");
12
13
  return {
13
14
  type: nonNull(list("CommentNested")),
14
15
  args: {
15
16
  relation: nonNull(stringArg()),
16
17
  sort: args.SortArg,
18
+ filters: getFiltersInputTypeName(comment_1.default),
17
19
  },
18
20
  async resolve(obj, args) {
19
21
  const { relation, filters, sort } = args;
@@ -450,11 +450,12 @@ module.exports = ({ strapi }) => ({
450
450
  data: {
451
451
  approvalStatus: "APPROVED",
452
452
  authorId: author.id,
453
- authorName: author.username,
453
+ authorName: (0, functions_2.getAuthorName)(author),
454
454
  authorEmail: author.email,
455
455
  content: body,
456
456
  threadOf: threadId,
457
- related: entity.related
457
+ related: entity.related,
458
+ isAdminComment: true,
458
459
  },
459
460
  });
460
461
  },
@@ -143,6 +143,9 @@ module.exports = ({ strapi }) => ({
143
143
  id,
144
144
  related: relation,
145
145
  });
146
+ if (reportAgainstEntity.isAdminComment) {
147
+ throw new error_1.default(403, `You're not allowed to take an action on that entity. This in a admin comment.`);
148
+ }
146
149
  if (reportAgainstEntity) {
147
150
  const entity = await strapi.db
148
151
  .query((0, functions_2.getModelUid)("comment-report"))
@@ -173,7 +176,7 @@ module.exports = ({ strapi }) => ({
173
176
  throw new error_1.default(403, `You're not allowed to take an action on that entity. Make sure that comment exist or you've authenticated your request properly.`);
174
177
  }
175
178
  catch (e) {
176
- throw new error_1.default(403, `You're not allowed to take an action on that entity. Make sure that comment exist or you've authenticated your request properly.`);
179
+ throw e;
177
180
  }
178
181
  },
179
182
  async markAsRemoved(id, relation, authorId, user) {