strapi-plugin-comments 2.2.1 → 2.2.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 (67) hide show
  1. package/README.md +1 -1
  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/Hint/index.d.ts +1 -1
  15. package/admin/src/components/IconButton/styles.d.ts +1 -1
  16. package/admin/src/components/LoadingIndicatorOverlay/styles.d.ts +2 -2
  17. package/admin/src/components/ModeratorResponse/index.d.ts +1 -1
  18. package/admin/src/components/ModeratorResponse/styles.d.ts +1 -1
  19. package/admin/src/components/ModeratorResponseModal/ModeratorResponseModal.d.ts +1 -1
  20. package/admin/src/components/PreviewWysiwyg/Wrapper.d.ts +1 -1
  21. package/admin/src/components/PreviewWysiwyg/index.d.ts +1 -1
  22. package/admin/src/components/StatusBadge/styles.d.ts +1 -1
  23. package/admin/src/components/Wysiwyg/Editor.d.ts +1 -1
  24. package/admin/src/components/Wysiwyg/EditorLayout.d.ts +2 -2
  25. package/admin/src/components/Wysiwyg/EditorStylesContainer.d.ts +1 -1
  26. package/admin/src/components/Wysiwyg/WysiwygFooter.d.ts +1 -1
  27. package/admin/src/components/Wysiwyg/WysiwygNav.d.ts +1 -1
  28. package/admin/src/components/Wysiwyg/WysiwygStyles.d.ts +7 -7
  29. package/admin/src/components/Wysiwyg/index.d.ts +1 -1
  30. package/admin/src/components/icons/strapiIcons.d.ts +1 -0
  31. package/admin/src/components/icons/strapiIcons.js +2 -1
  32. package/admin/src/custom-fields/comments/components/input/consts.d.ts +3 -0
  33. package/admin/src/custom-fields/comments/components/input/consts.js +9 -0
  34. package/admin/src/custom-fields/comments/components/input/input.js +2 -6
  35. package/admin/src/custom-fields/comments/components/input/types.d.ts +2 -2
  36. package/admin/src/custom-fields/comments/components/input/utils.js +8 -1
  37. package/admin/src/index.js +2 -1
  38. package/admin/src/pages/Details/components/DetailsFilters/styles.d.ts +1 -1
  39. package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +12 -11
  40. package/admin/src/pages/Discover/components/DiscoverTableRow/styles.d.ts +1 -1
  41. package/admin/src/pages/Discover/utils/filtersSchema.d.ts +17 -2
  42. package/admin/src/pages/Discover/utils/filtersSchema.js +28 -0
  43. package/admin/src/pages/Reports/components/ReportsTableRow/styles.d.ts +1 -1
  44. package/admin/src/pages/Reports/utils/filtersSchema.d.ts +17 -2
  45. package/admin/src/pages/Reports/utils/filtersSchema.js +21 -0
  46. package/admin/src/pages/Settings/components/RestartAlert/styles.d.ts +1 -1
  47. package/admin/src/utils/getRelatedGroups.d.ts +1 -1
  48. package/admin/src/utils/resolveCommentStatus.d.ts +1 -1
  49. package/content-types/comment.d.ts +4 -0
  50. package/content-types/comment.js +4 -0
  51. package/content-types/index.d.ts +4 -0
  52. package/package.json +6 -4
  53. package/server/controllers/index.d.ts +1 -1
  54. package/server/controllers/utils/functions.d.ts +1 -1
  55. package/server/graphql/mutations/createComment.d.ts +1 -1
  56. package/server/graphql/queries/findAllFlat.d.ts +1 -1
  57. package/server/graphql/queries/findAllInHierarchy.d.ts +1 -1
  58. package/server/routes/index.d.ts +2 -2
  59. package/server/services/admin.js +33 -14
  60. package/server/services/client.js +4 -1
  61. package/server/services/utils/functions.d.ts +2 -1
  62. package/server/services/utils/functions.js +9 -1
  63. package/server/utils/error.d.ts +1 -1
  64. package/strapi-server.d.ts +4 -0
  65. package/tsconfig.tsbuildinfo +1 -1
  66. package/types/contentTypes.d.ts +10 -9
  67. package/types/utils.d.ts +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-comments",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
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.7",
18
- "@strapi/utils": "^4.4.7",
17
+ "@strapi/plugin-graphql": "^4.5.4",
18
+ "@strapi/utils": "^4.5.4",
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": {
@@ -1,4 +1,4 @@
1
- declare type PluginControllers = {
1
+ type PluginControllers = {
2
2
  [key: string]: Function | Object;
3
3
  };
4
4
  declare const controllers: PluginControllers;
@@ -1,6 +1,6 @@
1
1
  import { Id, StringMap, StrapiRequestContext } from "strapi-typed";
2
2
  import PluginError from "../../utils/error";
3
- declare type ParseResponse = StringMap<string | number | Id>;
3
+ type ParseResponse = StringMap<string | number | Id>;
4
4
  export declare const parseParams: <T extends ParseResponse>(params: StringMap<string | number>) => T;
5
5
  export declare const throwError: <T extends {} = never>(ctx: StrapiRequestContext<T, StringMap<string | number>, StringMap<string | number>>, e: PluginError | Error | unknown) => PluginError | Error | unknown | never;
6
6
  export {};
@@ -1,6 +1,6 @@
1
1
  import { StrapiRequestContext } from "strapi-typed";
2
2
  import { StrapiGraphQLContext, ToBeFixed } from "../../../types";
3
- declare type CreateCommentProps = {
3
+ type CreateCommentProps = {
4
4
  input: ToBeFixed;
5
5
  };
6
6
  declare const _default: ({ nexus }: StrapiGraphQLContext) => {
@@ -1,5 +1,5 @@
1
1
  import { Id, StrapiGraphQLContext, ToBeFixed } from "../../../types";
2
- declare type ResponseFindAllResolverProps = {
2
+ type ResponseFindAllResolverProps = {
3
3
  relation: Id;
4
4
  filters: ToBeFixed;
5
5
  sort: ToBeFixed;
@@ -1,6 +1,6 @@
1
1
  import { Id } from "strapi-typed";
2
2
  import { StrapiGraphQLContext, ToBeFixed } from "../../../types";
3
- declare type findAllInHierarchyProps = {
3
+ type findAllInHierarchyProps = {
4
4
  relation: Id;
5
5
  filters: ToBeFixed;
6
6
  sort: ToBeFixed;
@@ -1,8 +1,8 @@
1
1
  import { StrapiRoute } from "strapi-typed";
2
- declare type PluginRoutes = {
2
+ type PluginRoutes = {
3
3
  [key: string]: PluginScopeRoutes;
4
4
  };
5
- declare type PluginScopeRoutes = {
5
+ type PluginScopeRoutes = {
6
6
  type: string;
7
7
  routes: Array<StrapiRoute>;
8
8
  };
@@ -94,19 +94,25 @@ module.exports = ({ strapi }) => ({
94
94
  },
95
95
  };
96
96
  }
97
+ const basePopulate = {
98
+ threadOf: true,
99
+ reports: {
100
+ where: {
101
+ resolved: false,
102
+ },
103
+ },
104
+ };
105
+ const populate = defaultAuthorUserPopulate
106
+ ? {
107
+ ...basePopulate,
108
+ authorUser: defaultAuthorUserPopulate,
109
+ }
110
+ : basePopulate;
97
111
  const entities = await strapi.db
98
112
  .query((0, functions_2.getModelUid)("comment"))
99
113
  .findMany({
100
114
  ...params,
101
- populate: {
102
- authorUser: defaultAuthorUserPopulate,
103
- threadOf: true,
104
- reports: {
105
- where: {
106
- resolved: false,
107
- },
108
- },
109
- },
115
+ populate,
110
116
  });
111
117
  const total = await strapi.db.query((0, functions_2.getModelUid)("comment")).count({
112
118
  where: params.where,
@@ -216,18 +222,30 @@ module.exports = ({ strapi }) => ({
216
222
  },
217
223
  },
218
224
  };
219
- const defaultPopulate = {
225
+ const basePopulate = {
220
226
  populate: {
221
- authorUser: defaultAuthorUserPopulate,
222
227
  threadOf: {
223
228
  populate: {
224
- authorUser: defaultAuthorUserPopulate,
225
229
  ...reportsPopulation,
226
230
  },
227
231
  },
228
232
  ...reportsPopulation,
229
233
  },
230
234
  };
235
+ const defaultPopulate = defaultAuthorUserPopulate
236
+ ? {
237
+ populate: {
238
+ ...basePopulate.populate,
239
+ authorUser: defaultAuthorUserPopulate,
240
+ threadOf: {
241
+ populate: {
242
+ ...basePopulate.populate.threadOf.populate,
243
+ authorUser: defaultAuthorUserPopulate,
244
+ },
245
+ },
246
+ },
247
+ }
248
+ : basePopulate;
231
249
  const entity = await strapi.db
232
250
  .query((0, functions_2.getModelUid)("comment"))
233
251
  .findOne({
@@ -450,11 +468,12 @@ module.exports = ({ strapi }) => ({
450
468
  data: {
451
469
  approvalStatus: "APPROVED",
452
470
  authorId: author.id,
453
- authorName: author.username,
471
+ authorName: (0, functions_2.getAuthorName)(author),
454
472
  authorEmail: author.email,
455
473
  content: body,
456
474
  threadOf: threadId,
457
- related: entity.related
475
+ related: entity.related,
476
+ isAdminComment: true,
458
477
  },
459
478
  });
460
479
  },
@@ -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) {
@@ -1,4 +1,4 @@
1
- import { Id, StrapiUser } from "strapi-typed";
1
+ import { Id, StrapiAdmin, StrapiUser } from "strapi-typed";
2
2
  import { Comment, ToBeFixed } from "../../../types";
3
3
  import PluginError from "./../../utils/error";
4
4
  export declare const buildNestedStructure: (entities: Array<Comment>, id?: Id | null, field?: string, dropBlockedThreads?: boolean, blockNestedThreads?: boolean) => Array<Comment>;
@@ -10,4 +10,5 @@ export declare const convertContentTypeNameToSlug: (str: string) => string;
10
10
  export declare const buildAuthorModel: (item: Comment, fieldsToPopulate?: Array<string>) => Comment;
11
11
  export declare const buildConfigQueryProp: (prop?: undefined | string | Array<string>) => string;
12
12
  export declare const resolveUserContextError: (user: StrapiUser) => PluginError;
13
+ export declare const getAuthorName: (author: StrapiAdmin) => any;
13
14
  //# sourceMappingURL=functions.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.resolveUserContextError = exports.buildConfigQueryProp = exports.buildAuthorModel = exports.convertContentTypeNameToSlug = exports.filterOurResolvedReports = exports.getModelUid = exports.getRelatedGroups = exports.isEqualEntity = exports.buildNestedStructure = void 0;
6
+ exports.getAuthorName = exports.resolveUserContextError = exports.buildConfigQueryProp = exports.buildAuthorModel = exports.convertContentTypeNameToSlug = exports.filterOurResolvedReports = exports.getModelUid = exports.getRelatedGroups = exports.isEqualEntity = exports.buildNestedStructure = void 0;
7
7
  const error_1 = __importDefault(require("./../../utils/error"));
8
8
  const constants_1 = require("./../../utils/constants");
9
9
  const lodash_1 = require("lodash");
@@ -105,4 +105,12 @@ const resolveUserContextError = (user) => {
105
105
  }
106
106
  };
107
107
  exports.resolveUserContextError = resolveUserContextError;
108
+ const getAuthorName = (author) => {
109
+ const { lastname, username, firstname } = author;
110
+ if (lastname)
111
+ return `${firstname} ${lastname}`;
112
+ else
113
+ return username || firstname;
114
+ };
115
+ exports.getAuthorName = getAuthorName;
108
116
  //# sourceMappingURL=functions.js.map
@@ -1,4 +1,4 @@
1
- declare type ErrorPayload = {
1
+ type ErrorPayload = {
2
2
  [key: string]: any;
3
3
  } | undefined;
4
4
  interface IPluginError extends Error {
@@ -64,6 +64,10 @@ declare const _default: () => {
64
64
  type: string;
65
65
  configurable: boolean;
66
66
  };
67
+ isAdminComment: {
68
+ type: string;
69
+ configurable: boolean;
70
+ };
67
71
  removed: {
68
72
  type: string;
69
73
  configurable: boolean;